From c8941d7296acfad14582f34149ff4b4af2f85b35 Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Sun, 10 Mar 2024 21:14:38 +0000 Subject: [PATCH 1/5] Update agent_linux.sh --- api/tacticalrmm/core/agent_linux.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/tacticalrmm/core/agent_linux.sh b/api/tacticalrmm/core/agent_linux.sh index 3b15921636..7a22c5b2f8 100755 --- a/api/tacticalrmm/core/agent_linux.sh +++ b/api/tacticalrmm/core/agent_linux.sh @@ -5,6 +5,8 @@ if [ $EUID -ne 0 ]; then exit 1 fi +CUSTOM_BIN_PATH="" + HAS_SYSTEMD=$(ps --no-headers -o comm 1) if [ "${HAS_SYSTEMD}" != 'systemd' ]; then echo "This install script only supports systemd" @@ -35,7 +37,7 @@ siteID='siteIDChange' agentType='agentTypeChange' proxy='' -agentBinPath='/usr/local/bin' +agentBinPath="${CUSTOM_BIN_PATH:-/usr/local/bin}" binName='tacticalagent' agentBin="${agentBinPath}/${binName}" agentConf='/etc/tacticalagent' @@ -149,6 +151,7 @@ while [[ "$#" -gt 0 ]]; do -debug | --debug | debug) DEBUG=1 ;; -insecure | --insecure | insecure) INSECURE=1 ;; -nomesh | --nomesh | nomesh) NOMESH=1 ;; + -binpath | --binpath) CUSTOM_BIN_PATH="$2"; shift ;; *) echo "ERROR: Unknown parameter: $1" exit 1 From 3ca9648433be1995c06245ea38a2d3a766730446 Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Thu, 14 Mar 2024 23:23:02 +0000 Subject: [PATCH 2/5] Update agent_linux.sh --- api/tacticalrmm/core/agent_linux.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/tacticalrmm/core/agent_linux.sh b/api/tacticalrmm/core/agent_linux.sh index 7a22c5b2f8..0ed757d72e 100755 --- a/api/tacticalrmm/core/agent_linux.sh +++ b/api/tacticalrmm/core/agent_linux.sh @@ -5,8 +5,6 @@ if [ $EUID -ne 0 ]; then exit 1 fi -CUSTOM_BIN_PATH="" - HAS_SYSTEMD=$(ps --no-headers -o comm 1) if [ "${HAS_SYSTEMD}" != 'systemd' ]; then echo "This install script only supports systemd" @@ -26,6 +24,7 @@ fi DEBUG=0 INSECURE=0 NOMESH=0 +CUSTOM_BIN_PATH="$2" agentDL='agentDLChange' meshDL='meshDLChange' From dcc9b2e490254a7cdbf66e1ec245321ab01e8f3e Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Fri, 15 Mar 2024 00:28:15 +0000 Subject: [PATCH 3/5] Update agent_linux.sh --- api/tacticalrmm/core/agent_linux.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/tacticalrmm/core/agent_linux.sh b/api/tacticalrmm/core/agent_linux.sh index 0ed757d72e..26f7b1255b 100755 --- a/api/tacticalrmm/core/agent_linux.sh +++ b/api/tacticalrmm/core/agent_linux.sh @@ -24,7 +24,7 @@ fi DEBUG=0 INSECURE=0 NOMESH=0 -CUSTOM_BIN_PATH="$2" +CUSTOM_BIN_PATH="" agentDL='agentDLChange' meshDL='meshDLChange' From 566ce0d6b9891ac16730b360ef18e4939ed30571 Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Fri, 15 Mar 2024 00:42:57 +0000 Subject: [PATCH 4/5] Update agent_linux.sh --- api/tacticalrmm/core/agent_linux.sh | 52 +++++++++++++++++------------ 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/api/tacticalrmm/core/agent_linux.sh b/api/tacticalrmm/core/agent_linux.sh index 26f7b1255b..736f590006 100755 --- a/api/tacticalrmm/core/agent_linux.sh +++ b/api/tacticalrmm/core/agent_linux.sh @@ -21,10 +21,19 @@ if [[ $DISPLAY ]]; then exit 1 fi +agentSvcName='tacticalagent.service' +agentSysD="/etc/systemd/system/${agentSvcName}" + +if [ -f "${agentSysD}" ]; then + CUSTOM_BIN_PATH=$(awk -F'=' '/ExecStart/ {print $2}' ${agentSysD} | awk '{print $1}' | xargs dirname) +else + CUSTOM_BIN_PATH="" +fi + DEBUG=0 INSECURE=0 NOMESH=0 -CUSTOM_BIN_PATH="" +UNINSTALL=0 agentDL='agentDLChange' meshDL='meshDLChange' @@ -36,6 +45,21 @@ siteID='siteIDChange' agentType='agentTypeChange' proxy='' +while [[ "$#" -gt 0 ]]; do + case $1 in + -debug | --debug | debug) DEBUG=1 ;; + -insecure | --insecure | insecure) INSECURE=1 ;; + -nomesh | --nomesh | nomesh) NOMESH=1 ;; + -uninstall | --uninstall | uninstall) UNINSTALL=1 ;; + -binpath | --binpath) CUSTOM_BIN_PATH="$2"; shift ;; + *) + echo "ERROR: Unknown parameter: $1" + exit 1 + ;; + esac + shift +done + agentBinPath="${CUSTOM_BIN_PATH:-/usr/local/bin}" binName='tacticalagent' agentBin="${agentBinPath}/${binName}" @@ -138,29 +162,20 @@ Uninstall() { RemoveOldAgent } -if [ $# -ne 0 ] && [[ $1 =~ ^(uninstall|-uninstall|--uninstall)$ ]]; then +if [[ $UNINSTALL -eq 1 ]]; then Uninstall # Remove the current script rm "$0" exit 0 fi -while [[ "$#" -gt 0 ]]; do - case $1 in - -debug | --debug | debug) DEBUG=1 ;; - -insecure | --insecure | insecure) INSECURE=1 ;; - -nomesh | --nomesh | nomesh) NOMESH=1 ;; - -binpath | --binpath) CUSTOM_BIN_PATH="$2"; shift ;; - *) - echo "ERROR: Unknown parameter: $1" - exit 1 - ;; - esac - shift -done - RemoveOldAgent +if [ ! -d "${agentBinPath}" ]; then + echo "Creating ${agentBinPath}" + mkdir -p ${agentBinPath} +fi + echo "Downloading tactical agent..." wget -q -O ${agentBin} "${agentDL}" if [ $? -ne 0 ]; then @@ -184,11 +199,6 @@ else MESH_NODE_ID=$(env XAUTHORITY=foo DISPLAY=bar ${agentBin} -m nixmeshnodeid) fi -if [ ! -d "${agentBinPath}" ]; then - echo "Creating ${agentBinPath}" - mkdir -p ${agentBinPath} -fi - INSTALL_CMD="${agentBin} -m install -api ${apiURL} -client-id ${clientID} -site-id ${siteID} -agent-type ${agentType} -auth ${token}" if [ "${MESH_NODE_ID}" != '' ]; then From 480890bd3476d3d4472a09bc1ff7f703271bd2bc Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Tue, 19 Mar 2024 23:20:34 +0000 Subject: [PATCH 5/5] Update views.py --- api/tacticalrmm/clients/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/tacticalrmm/clients/views.py b/api/tacticalrmm/clients/views.py index 475e8ee876..b5c5c84e11 100644 --- a/api/tacticalrmm/clients/views.py +++ b/api/tacticalrmm/clients/views.py @@ -93,6 +93,10 @@ def post(self, request): core = get_core_settings() core.default_time_zone = request.data["timezone"] core.save(update_fields=["default_time_zone"]) + # add in mesh company name + if "mesh_company_name" in request.data: + core.mesh_company_name = request.data["mesh_company_name"] + update_fields_list.append("mesh_company_name") # save custom fields if "custom_fields" in request.data.keys():