Finalized script and added synopsis
This commit is contained in:
@@ -1,4 +1,33 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# Usage: "Linux - Schedule agent update.sh"
|
||||||
|
#
|
||||||
|
# Description:
|
||||||
|
# This script is used from inside of Tactical RMM instances to schedule an update of a linux agent.
|
||||||
|
# The script will download the update script and schedule it to run after 2 minutes,
|
||||||
|
# this is done because the update script needs to stop and replace the agent files on the host.
|
||||||
|
#
|
||||||
|
# Options:
|
||||||
|
# n/a
|
||||||
|
#
|
||||||
|
# Author: D. de Kooker (info@dcomputers.nl)
|
||||||
|
# Sources: n/a
|
||||||
|
|
||||||
|
#Check if at is installed in order to schedule the update script
|
||||||
|
check_at=$(which at 2> /dev/null)
|
||||||
|
if [[ $check_at == "" || $check_at =~ .*"no at".* ]]; then
|
||||||
|
echo "'at' could not be found. Trying to install automatically."
|
||||||
|
if [[ `which yum` ]]; then
|
||||||
|
yum -y install at
|
||||||
|
echo "'at' command installed successfully."
|
||||||
|
elif [[ `which apt` ]]; then
|
||||||
|
apt-get -y update
|
||||||
|
apt-get -y install at
|
||||||
|
echo "'at' command installed successfully."
|
||||||
|
else
|
||||||
|
echo "Failed to install 'at' command. Please install it manually."
|
||||||
|
fi
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# GitHub script URL
|
# GitHub script URL
|
||||||
GITHUB_URL="https://gittea.dannydekooker.nl/Dcomputers/TacticalRMM_Scripts/raw/branch/main/Supporting_scripts/Linux%20-%20Update%20TRMM%20agent.sh"
|
GITHUB_URL="https://gittea.dannydekooker.nl/Dcomputers/TacticalRMM_Scripts/raw/branch/main/Supporting_scripts/Linux%20-%20Update%20TRMM%20agent.sh"
|
||||||
@@ -7,7 +36,7 @@ GITHUB_URL="https://gittea.dannydekooker.nl/Dcomputers/TacticalRMM_Scripts/raw/b
|
|||||||
DEST_DIR="/tmp"
|
DEST_DIR="/tmp"
|
||||||
|
|
||||||
# Name of the script file
|
# Name of the script file
|
||||||
SCRIPT_FILE="trmm-agentupdate.sh"
|
SCRIPT_FILE="temp-trmm-agentupdate.sh"
|
||||||
|
|
||||||
# Download the script from GitHub
|
# Download the script from GitHub
|
||||||
wget -O "$DEST_DIR/$SCRIPT_FILE" "$GITHUB_URL"
|
wget -O "$DEST_DIR/$SCRIPT_FILE" "$GITHUB_URL"
|
||||||
@@ -18,6 +47,12 @@ if [ $? -eq 0 ]; then
|
|||||||
# Schedule the script to run after 2 minutes
|
# Schedule the script to run after 2 minutes
|
||||||
echo "bash $DEST_DIR/$SCRIPT_FILE update amd64" | at now + 2 minutes
|
echo "bash $DEST_DIR/$SCRIPT_FILE update amd64" | at now + 2 minutes
|
||||||
echo "Script scheduled to run after 2 minutes."
|
echo "Script scheduled to run after 2 minutes."
|
||||||
|
|
||||||
|
# Schedule Cleanup of the update script
|
||||||
|
echo "rm -rf $DEST_DIR/$SCRIPT_FILE" | at now + 15 minutes
|
||||||
|
|
||||||
|
exit 1
|
||||||
else
|
else
|
||||||
echo "Failed to download the script from GitHub."
|
echo "Failed to download the script from GitHub."
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user