MacOS RMM Deployment Script and Steps.
What the script is doing:
Checking the Activation Token - this determines where the application is installed from on the clients dashboard, since this is organisation specific.
Checking for ‘–force’ commands to complete a reinstall if the app already exists.
Checking for existing installations, unless –force command is used the script will not push an install on the machine if it detects there is an existing instance of Active Protect.
Install the app to the devices.
Steps to Install
Add the below script to your RMM tool, in a new/separate policy. Create "CybersmartActiveProtectInstaller.sh":
#!/bin/bash
UUID=$1
forceParam=$2is_valid_uuid() {
local uuid="$1"
local regex='^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$'
if [[ $uuid =~ $regex ]]; then
return 0
else
return 1
fi
}will_force_install() {
if [ "$forceParam" == "--force" ]; then
return 0
else
return 1
fi
}is_webapp_installed() {
if [ -d /Applications/CyberSmartActiveProtect.app ]; then
return 1
else
return 0;
fi
}is_installed() {
SERVICE_LABEL="uk.co.cybersmart.app"
if launchctl list | grep -q "$SERVICE_LABEL"; then
if is_webapp_installed; then
return 1
fi
else
return 0
fi
}install_app(){
echo "Downloading and installing app" curl https://cs-prod-macos-distribution.cybersmart.co.uk/build/$UUID -L -o ./CSOnlineInstaller.dmg
sudo hdiutil detach /Volumes/CSOnlineInstaller > /dev/null
sudo hdiutil attach ./CSOnlineInstaller.dmg
sudo /Volumes/CSOnlineInstaller/CSOnlineInstaller.app/Contents/Library/LaunchServices/uk.co.cybersmart.CSInstallerHelper --install
sudo hdiutil detach /Volumes/CSOnlineInstaller
}if ! is_valid_uuid "$UUID"; then
echo "Invalid UUID"
exit 1
fiif will_force_install "$@"; then
echo "Force install"
install_app
exit 0
fiif is_installed; then
echo "App is already installed"
exit 0
else
install_app
fi
3. Locate Activation Token from the dashboard, this is a long string of letters and numbers found at the bottom of the “Deploy Mac” pop up. This is used in your Script Parameters or Arguments.
4. When deploying, the command should look like this:
CyberSmartActiveProtectInstaller.sh *ActivationToken*
5. If an existing install is on the machine, and you need to reinstall add –force to the command like below:
CyberSmartActiveProtectInstaller.sh *ActivationToken* --force
6. If your RMM doesn’t support script arguments and parameters, you can modify the script directly by replacing UUID=$1 with your Activation token:
UUID=ActivationToken
7. To force a reinstall by modifying the script, edit the forceParam=$1 line to the below:
forceParam="--force"