mirror of
https://git.zepheris.com/zepheris/LinuxRMM-Script.git
synced 2024-11-27 04:37:17 +00:00
Added the following:
- uninstall_agent function - uninstall_mesh function - User input support for forcibly uninstalling TRMM and Mesh agent. Updated the following: - Updated readme.md with how to use the uninstall feature.
This commit is contained in:
parent
39a78fcaa2
commit
60fb82a49f
31
README.md
31
README.md
@ -30,7 +30,7 @@ The argument are:
|
||||
|
||||
3. Mesh agent
|
||||
|
||||
The url givent by mesh for installing new agent.
|
||||
The url given by mesh for installing new agent.
|
||||
Go to mesh.fqdn.com > Add agent > Installation Executable Linux / BSD / macOS > **Select the good system type**
|
||||
Copy **ONLY** the URL with the quote.
|
||||
|
||||
@ -69,3 +69,32 @@ Simply launch the script that match your system with *update* as argument.
|
||||
```bash
|
||||
./rmmagent-linux.sh update
|
||||
```
|
||||
|
||||
## Uninstall
|
||||
To uninstall agent launch the script with this arguement:
|
||||
|
||||
```bash
|
||||
./rmmagent-linux.sh uninstall 'Mesh FQDN' 'Mesh ID'
|
||||
```
|
||||
Note: Single quotes must be around the Mesh ID for it to uninstall the mesh agent properly
|
||||
|
||||
The argument are:
|
||||
|
||||
2. Mesh FQDN
|
||||
|
||||
Example of FQDN: mesh.fqdn.com
|
||||
|
||||
3. Mesh ID
|
||||
|
||||
The url givent by mesh for installing new agent.
|
||||
Go to mesh.fqdn.com > Add agent > Linux / BSD (Uninstall) > Copy **ONLY** the last value with the single quotes.
|
||||
You are looking for a 64 charaters long value of random letter case, numbers, and special characters.
|
||||
|
||||
### Example
|
||||
```bash
|
||||
./rmmagent-linux.sh uninstall mesh.fqdn.com 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
```
|
||||
|
||||
### WARNING
|
||||
- You should **only** attempt this if the agent removal feaure on TacticalRMM is not working.
|
||||
- Running uninstall will **not** remove the connections from the TacticalRMM and MeshCentral Dashboard. You will need to manually remove them. It only forcefully removes the agents from your linux box.
|
@ -14,7 +14,7 @@ fi
|
||||
if [[ $1 == "help" ]]; then
|
||||
echo "There is help but more information is available at github.com/ZoLuSs/rmmagent-script"
|
||||
echo ""
|
||||
echo "List of argument (no argument name):"
|
||||
echo "List of INSTALL/UPDATE argument (no argument name):"
|
||||
echo "Arg 1: 'install' or 'update'"
|
||||
echo "Arg 2: System type 'amd64' 'x86' 'arm64' 'armv6'"
|
||||
echo "Arg 3: Mesh agent URL"
|
||||
@ -24,12 +24,18 @@ if [[ $1 == "help" ]]; then
|
||||
echo "Arg 7: Auth Key"
|
||||
echo "Arg 8: Agent Type 'server' or 'workstation'"
|
||||
echo ""
|
||||
echo "List of UNINSTALL argument (no argument name):"
|
||||
echo "Arg 1: 'uninstall'"
|
||||
echo "Arg 2: Mesh agent FQDN (i.e. mesh.domain.com)"
|
||||
echo "Arg 3: Mesh agent id (The id needs to have single quotes around it)"
|
||||
echo ""
|
||||
echo "Only argument 1 is needed for update"
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $1 != "install" && $1 != "update" ]]; then
|
||||
echo "First argument can only be 'install' or 'update' !"
|
||||
if [[ $1 != "install" && $1 != "update" && $1 != "uninstall" ]]; then
|
||||
echo "First argument can only be 'install' or 'update' or 'uninstall' !"
|
||||
echo "Type help for more information"
|
||||
exit 1
|
||||
fi
|
||||
@ -40,7 +46,7 @@ if [[ $1 == "install" && $2 == "" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $2 != "amd64" && $2 != "x86" && $2 != "arm64" && $2 != "armv6" ]]; then
|
||||
if [[ $1 == "install" && $2 != "amd64" && $2 != "x86" && $2 != "arm64" && $2 != "armv6" ]]; then
|
||||
echo "This argument can only be 'amd64' 'x86' 'arm64' 'armv6' !"
|
||||
echo "Type help for more information"
|
||||
exit 1
|
||||
@ -88,6 +94,18 @@ if [[ $1 == "install" && $8 != "server" && $8 != "workstation" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $1 == "uninstall" && $2 == "" ]]; then
|
||||
echo "Argument 2 (Mesh agent FQDN) is empty !"
|
||||
echo "Type help for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $1 == "uninstall" && $3 == "" ]]; then
|
||||
echo "Argument 3 (Mesh agent id) is empty !"
|
||||
echo "Type help for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
## Setting var for easy scription
|
||||
system=$2
|
||||
mesh_url=$3
|
||||
@ -96,6 +114,9 @@ rmm_client_id=$5
|
||||
rmm_site_id=$6
|
||||
rmm_auth=$7
|
||||
rmm_agent_type=$8
|
||||
## Uninstall var for easy scription
|
||||
mesh_fqdn=$2
|
||||
mesh_id=$3
|
||||
|
||||
go_url_amd64="https://go.dev/dl/go1.18.3.linux-amd64.tar.gz"
|
||||
go_url_x86="https://go.dev/dl/go1.18.3.linux-386.tar.gz"
|
||||
@ -215,6 +236,25 @@ function check_profile () {
|
||||
source $profile_file
|
||||
}
|
||||
|
||||
function uninstall_agent() {
|
||||
systemctl stop tacticalagent
|
||||
systemctl disable tacticalagent
|
||||
rm /etc/systemd/system/tacticalagent.service
|
||||
systemctl daemon-reload
|
||||
rm /usr/local/bin/rmmagent
|
||||
rm /etc/tacticalagent
|
||||
sed -i "/export\ PATH\=\$PATH\:\/usr\/local\/go\/bin/d" /root/.profile
|
||||
}
|
||||
|
||||
function uninstall_mesh() {
|
||||
(wget "https://$mesh_fqdn/meshagents?script=1" -O /tmp/meshinstall.sh || wget "https://$mesh_fqdn/meshagents?script=1" --no-proxy -O /tmp/meshinstall.sh)
|
||||
chmod 755 /tmp/meshinstall.sh
|
||||
(/tmp/meshinstall.sh uninstall https://$mesh_fqdn $mesh_id || /tmp/meshinstall.sh uninstall uninstall uninstall https://$mesh_fqdn $mesh_id)
|
||||
rm /tmp/meshinstall.sh
|
||||
rm meshagent
|
||||
rm meshagent.msh
|
||||
}
|
||||
|
||||
case $1 in
|
||||
install)
|
||||
check_profile
|
||||
@ -231,4 +271,11 @@ update)
|
||||
update_agent
|
||||
echo "Tactical Agent Update is done"
|
||||
exit 0;;
|
||||
uninstall)
|
||||
check_profile
|
||||
uninstall_agent
|
||||
uninstall_mesh
|
||||
echo "Tactical Agent Uninstall is done"
|
||||
echo "You may need to manually remove the agents orphaned connections on TacticalRMM and MeshCentral"
|
||||
exit 0;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user