????

Your IP : 3.15.4.135


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

#!/usr/bin/env bash
#
#  cPMalScan Uninstaller by Tijeers.com
#
GREEN='\e[1;32m'
RED='\e[0;31m'
NOCOLOR='\e[0m'


echo -e "${GREEN}UnInstalling cPMalScan${NOCOLOR}"

if [ ! `id -u` = 0 ]; then
        echo
        echo -e "${RED}ERROR: You must be looged in as root to uninstall cPMalScan ${NOCOLOR}"
        exit 1
fi

if [ ! -d /etc/cPMalScan ]; then
    echo -e "${RED}ERROR: cPMalScan is not installed on this Server${NOCOLOR}"
    exit 1
fi

/usr/bin/mysqladmin ping| grep 'mysqld is alive' > /dev/null 2>&1
if [ $? != 0 ]
then
    echo -e "${RED}ERROR: MySQL is not running. You will have to delete the 'cpmalscan' database manually ${NOCOLOR}"
fi

if test `cat /proc/1/comm` = "systemd"
then

	systemctl stop cpmalscan.service
    rm -vf  /usr/lib/systemd/system/cpmalscan.service
    systemctl daemon-reload
	
else
	/etc/init.d/cpmalscan stop
	/sbin/chkconfig cpmalscan off
	rm -vf /etc/init.d/cpmalscan
	
fi

#Registration
/usr/local/cpanel/bin/unregister_appconfig /usr/local/cpanel/whostmgr/cgi/cpmalscan/cpmalscan.conf
/scripts/uninstall_plugin /usr/local/cpanel/base/3rdparty/cpmalscan/cpmalscan.tar.bz2
rm -vf /usr/local/cpanel/whostmgr/docroot/addon_plugins/cpmalscan.png

if [ -e /etc/pure-ftpd.conf ]; then
	sed -i 's@CallUploadScript.*@CallUploadScript no@g' /etc/pure-ftpd.conf
fi

if [ -e /etc/init.d/pure-ftpd ]; then
	/etc/init.d/pure-ftpd stop
	grep -v ftp_scanner /etc/init.d/pure-ftpd > /tmp/ftpinit.cpmstmp
	cat /tmp/ftpinit.cpmstmp > /etc/init.d/pure-ftpd 
	/etc/init.d/pure-ftpd restart
fi

if [ -e /etc/systemd/system/cpmalscan.service ]; then
	systemctl stop cpmalscan.service
	systemctl disable cpmalscan.service
	rm -vf /etc/systemd/system/cpmalscan.service
	systemctl --system daemon-reload	
fi

if [ -e /usr/lib/systemd/system/cpmalscan.service ]; then
	systemctl stop cpmalscan.service
	systemctl disable cpmalscan.service
	rm -vf /usr/lib/systemd/system/cpmalscan.service
	systemctl daemon-reload	
fi

if [ -e /etc/systemd/system/cpmalscan.pure-ftpd.service ]; then
	systemctl stop cpmalscan.pure-ftpd.service
	systemctl disable cpmalscan.pure-ftpd.service
	rm -vf /etc/systemd/system/cpmalscan.pure-ftpd.service
	systemctl --system daemon-reload
	systemctl restart pure-ftpd.service
fi

if [ -e /usr/local/apache/conf/modsec2.user.conf ]; then
    grep -v "cpmalscan" /usr/local/apache/conf/modsec2.user.conf > /tmp/cpms.modsec.tmp
	cat /tmp/cpms.modsec.tmp > /usr/local/apache/conf/modsec2.user.conf
	rm -f /tmp/cpms.modsec.tmp
fi


if [ -e /etc/apache2/conf.d/modsec/modsec2.user.conf ]; then
    grep -v "cpmalscan" /etc/apache2/conf.d/modsec/modsec2.user.conf > /tmp/cpms.modsec.tmp
	cat /tmp/cpms.modsec.tmp > /etc/apache2/conf.d/modsec/modsec2.user.conf
	rm -f /tmp/cpms.modsec.tmp
fi

if [ -e /etc/cagefs/cagefs.mp ]; then
    grep -v "cPMalScan" /etc/cagefs/cagefs.mp > /tmp/cpms.cagefs.tmp
        cat /tmp/cpms.cagefs.tmp > /etc/cagefs/cagefs.mp
        rm -f /tmp/cpms.cagefs.tmp
	cagefsctl --remount-all
fi

/scripts/restartsrv_httpd

rm -rvf /etc/cPMalScan
rm -rvf  /usr/local/cpanel/whostmgr/cgi/cpmalscan
rm -rvf  /usr/local/cpanel/base/3rdparty/cpmalscan/
rm -rvf  /cpms_quar
rm -vf  /etc/cron.d/cpmalscan

mysql -v -e "drop database cpmalscan;"

echo -e "${GREEN}Uninstall Complete ...${NOCOLOR}"