Uninstalling Cloud Agent
Uninstalling Cloud Agent from Cloud Agent UI or API
You can uninstall the Qualys Cloud Agent for Gentoo Linux from the Cloud Agent user interface or using APIs. When you uninstall a Cloud Agent from the user interface or API, agent license is removed from the Qualys subscription and agent log data is removed from the host.
Uninstalling Cloud Agent from Agent Host
When you uninstall a Cloud Agent from the host itself, the Cloud Agent stops working, but the Cloud Agent license, data, and log files are still present in the Qualys Subscription. You have to remove these files and data manually.
Following are the steps to uninstall Cloud Agent from the agent host itself:
- Run the following uninstallation command:
emerge --unmerge qualys-cloud-agent
- Once the uninstallation command is successfully executed, run the following uninstallation script to remove all the data and log files.
#!/bin/bash
if [ -f "/etc/qualys/cloud-agent/qualys-cloud-agent.conf" ]; then
username=$(grep "^SudoUser=" /etc/qualys/cloud-agent/qualys-cloudagent.conf | awk -F= '{print $2}')
group=$(grep "^UserGroup=" /etc/qualys/cloud-agent/qualys-cloudagent.conf | awk -F= '{print $2}')
fi
checksystemd=$(ps -p1 | grep 1 | awk '{ print $4}')
case "$checksystemd" in "systemd")
systemctl stop qualys-cloud-agent.service 0<&- &>/dev/null || true
systemctl disable qualys-cloud-agent.service 0<&- &>/dev/null || true
touch /etc/init.d/qualys-cloud-agent ;;
*)
rc-service qualys-cloud-agent stop || true
rc-update del qualys-cloud-agent default
if
[ -f /etc/init.d/qualys-cloud-agent ];
then
rm -rf /etc/init.d/qualys-cloud-agent
fi;;
esac
REMEDIATION_TOOL=/usr/local/qualys/cloud-agent/bin/qualys-remediationtool
if
pgrep -x -f ${REMEDIATION_TOOL} >/dev/null;
then
pkill -15 -f ${REMEDIATION_TOOL}
fi
if
[ -d "/usr/local/qualys/cloud-agent/remediation" ];
then
rm -rf /usr/local/qualys/cloud-agent/remediation
fi
if
[ -d "/usr/local/qualys/cloud-agent/correlation" ];
then
rm -rf /usr/local/qualys/cloud-agent/correlation
fi
if
[ -f "/usr/local/qualys/cloud-agent/bin/agentid-service" ]; then
rm -f /usr/local/qualys/cloud-agent/bin/agentid-service
fi
if
[ -f "/etc/qualys/cloud-agent/agentid-service.conf" ];
then
rm -f /etc/qualys/cloud-agent/agentid-service.conf
fi
rm -rf /usr/local/qualys/cloud-agent/{manifests,setup}
rm -rf /usr/local/qualys/cloud-agent/{Snapshot*,ChangeList*}.db
rm -rf /usr/local/qualys/cloud-agent/ChangeList*.db.xz
rm -rf /usr/local/qualys/cloud-agent/Config.db
if
[ -f /usr/local/qualys/cloud-agent/Status.db ];
then
rm -f /usr/local/qualys/cloud-agent/Status.db
fi
checksystemd=$(ps -p1 | grep systemd | awk '{ print $4}')
case "$checksystemd" in
"systemd")
rm -rf /usr/lib/systemd/system/qualys-cloud-agent.service
rm -rf /usr/lib/systemd/system/qualys-cloud-agentuninstall.service
rm -rf /etc/init.d/qualys-cloud-agent
systemctl daemon-reload
;;
*)
rm -rf /etc/init.d/qualys-cloud-agent;;
esac
rm -rf /etc/qualys/cloud-agent/*.conf.*
rm -rf /etc/qualys/cloud-agent
rm -rf /usr/local/qualys/cloud-agent/Status.db
rm -rf /usr/local/qualys/cloud-agent/TempSnapshot*.db
echo "cleaning log files"
rm -rf /var/log/qualys/qualys-*.log*
rm -rf /var/log/qualys/agentid*.log*
#copy the hostid file to default location before uninstallation
if [ ! -d "/etc/qualys" ]; then mkdir "/etc/qualys"; fi
#cp -r /etc/.qualys_bk/hostid /etc/qualys/hostid
if [ -f "/etc/.qualys_bk/hostid" ];
then
mv /etc/.qualys_bk/hostid /etc/qualys/hostid
fi
rm -rf /etc/.qualys_bk
echo "removing var log qualys using find"
find /var/log/qualys -empty -type d -delete 2>/dev/null || true
echo "removing /etc/qualys using find"
find /etc/qualys -empty -type d -delete 2>/dev/null || true
# remove ondemandScan dir.
if [ -d "/usr/local/qualys/cloud-agent/.on-demand-scan" ];
then
rm -rf "/usr/local/qualys/cloud-agent/.on-demand-scan"
fi
#remove temp directory
if [ -d "/usr/local/qualys/cloud-agent/.temp" ];
then
rm -rf "/usr/local/qualys/cloud-agent/.temp"
fi
find /usr/local/qualys -empty -type d -delete 2>/dev/null || true - Once the uninstallation script is executed, run the following commands based on your system architecture to update the system.
- For SystemD architecture:systemctl daemon-reload
- For OpenRC architecture:rc-update