Kerala Cyber Warriors
KCW Uploader V1.1

Path : /usr/local/src/
File Upload :
Current File : //usr/local/src/cpguard_uninstall.sh

#!/bin/bash

#Uninstall script for  cPGuard
#Written by OPSSHIELD LLP https://www.opsshield.com


echo "########################"
echo "########################"
echo "#####cPGuard manage script"
echo "#####Written and maintained by https://www.opsshield.com"
echo "#####Please email sales@opsshield.com for any questions regarding this software"
echo "########################"
echo "########################"
sleep 1

#Main
red='\e[0;31m'
green='\e[0;32m'
blue='\e[4;34m'
NC='\e[0m'

rm -f /etc/cron.d/cpguard
kill -9 `ps aux | grep cpguard | grep -v uninstall | awk -F" " {'print $2'}` > /dev/null 2>&1
/opt/cpguard/cpg-php-fpm/bin/php /opt/cpguard/app/setup/uninstall.php
cpgcli license --remove=true

if [ -f /etc/redhat-release ]; then
	rpm -e cpg-clamav-libs > /dev/null 2>&1
	rpm -e cpg-nginx > /dev/null 2>&1
	rpm -e cpg-php-fpm > /dev/null 2>&1

elif [ -f /etc/os-release ] && [ ! -f /etc/debian_version ]; then
        rpm -e cpg-clamav-libs > /dev/null 2>&1
        rpm -e cpg-nginx > /dev/null 2>&1
        rpm -e cpg-php-fpm > /dev/null 2>&1

elif [ -f /etc/debian_version ]; then
	apt-get remove cpg-clamav-libs cpg-nginx cpg-php-fpm -y > /dev/null 2>&1
else
        echo -ne "\r${red} Unsupported OS...please check the system requirements for cPGuard ${NC}"
        echo -ne '\n'
        exit
fi


if [ -f /usr/local/cpanel/cpsrvd ]; then
	if [ -d /usr/local/cpanel/base/frontend/jupiter/cpguard ]; then
		/usr/local/cpanel/scripts/uninstall_plugin /usr/local/cpanel/base/frontend/jupiter/cpguard/cpanel/
	fi
	/usr/local/cpanel/bin/unregister_appconfig cPGuard
	rm -rf  /usr/local/cpanel/whostmgr/docroot/cgi/cpguard
	rm -rf /usr/local/cpanel/base/frontend/jupiter/cpguard
	rm -rf  /usr/local/cpanel/base/frontend/paper_lantern/cpguard
	sed -i '/acl_abuseat_rbl/d' /etc/exim.conf.localopts > /dev/null 2>&1
	sed -i '/acl_barracuda_rbl/d' /etc/exim.conf.localopts > /dev/null 2>&1
	sed -i '/acl_spameatingmonkey_rbl/d' /etc/exim.conf.localopts > /dev/null 2>&1
	rm -f /var/cpanel/rbl_info/abuseat.yaml
	rm -f /var/cpanel/rbl_info/barracuda.yaml
	rm -f /var/cpanel/rbl_info/spameatingmonkey.yaml
	rm -f /var/cpanel/rbl_info/srbl_cpguard.yaml
	rm -f /usr/local/cpanel/etc/exim/acls/ACL_RBL_BLOCK/barracuda_rbl
	rm -f /usr/local/cpanel/etc/exim/acls/ACL_RBL_BLOCK/spameatingmonkey_rbl
	rm -f /usr/local/cpanel/etc/exim/acls/ACL_RBL_BLOCK/abuseat_rbl
	rm -f /usr/local/cpanel/etc/exim/acls/ACL_RBL_BLOCK/cpguardsrbl_rbl
	sed -i '/cpguard_modsec100.conf/d' /etc/apache2/conf.d/modsec/modsec2.user.conf > /dev/null 2>&1

	/scripts/buildeximconf > /dev/null
	/scripts/restartsrv exim > /dev/null
	/scripts/restartsrv httpd > /dev/null
elif [ -f /usr/local/directadmin/directadmin ]; then
	rm -rf  /usr/local/directadmin/plugins/cpguard
	rm -f /usr/local/directadmin/custombuild/custom/modsecurity/conf/cpguard_waf.conf
	rm -f /etc/modsecurity.d/cpguard_waf.conf
fi

if [ -f /home/interworx/bin/iworx-web ]; then
	/usr/bin/nodeworx -u -n -c Plugins -a edit --plugin_name cpguard --status 0
	rm -rf ~iworx/plugins/cpguard
	rm -rf /home/interworx/html/plugins/assets/cpguard
fi

if [ -d /var/webuzo  ]; then
	rm -rf /usr/local/webuzo/plugins/cpguard
fi

userdel -r cpguard > /dev/null 2>&1

if [ -f /etc/csf/csf.allow ]; then
	sed -i '/cpgips.txt/d' /etc/csf/csf.allow
	sed -i '/cpgips.txt/d' /etc/csf/csf.ignore
fi

if [ -f /usr/local/cpanel/cpsrvd ]; then
	rpm -e cpguard-core  >/dev/null 2>&1
	rpm -e cpguard-whm  >/dev/null 2>&1
	rpm -e cpguard-cpanel  >/dev/null 2>&1
fi

rm -rf /opt/cpguard
rm -rf /etc/cpguard
rm -f /usr/bin/cpgcli

echo " "
echo " "
echo -ne "\r${red}Sorry to see that you have uninstalled cPGuard from your server  \n
Please leave your feedback at https://opsshield.surveysparrow.com/s/cpguard-feedback/tt-63b19b ${NC}"
echo -ne '\n'

-=[ KCW uplo4d3r c0ded by cJ_n4p573r ]=-
Ⓒ2017 ҠЄГѦLѦ СүѣЄГ ЩѦГГіѺГՏ