#!/usr/bin/bash

/usr/bin/echo "Removing the server monitoring configuration before an image snapshot"

/usr/bin/rm -vf "/root/.360monitoring/config"
/usr/bin/rm -vf "/etc/agent360-token.ini"
/usr/bin/rm -vf "/etc/agent360.ini"

( systemctl list-unit-files | grep "agent360" ) &&
   /usr/bin/echo "Stoping and disabling the server monitoring agent" &&
   /usr/bin/systemctl disable --now agent360

# Note: The above steps are only needed on servers where both the cpanel-monitoring-plugin is installed
# and a 360 Monitoring users, or the 360 monitoring agent have been setup. These preconditions are limited
# to specific company ids. So we exit 0 even if one or more of the above steps fail.
exit 0