Files
CyberPanel/install/unInstall.py

197 lines
4.7 KiB
Python
Raw Normal View History

2017-10-24 19:16:36 +05:00
import sys
import subprocess
import shutil
2019-12-12 11:04:05 +05:00
from . import installLog as logging
2017-10-24 19:16:36 +05:00
import argparse
import os
import shlex
import socket
class unInstallCyberPanel:
def unInstallCyberPanelRepo(self):
2018-11-06 00:19:58 +05:00
try:
copyPath = "/etc/yum.repos.d/cyberpanel.repo"
os.remove(copyPath)
2017-10-24 19:16:36 +05:00
2019-12-10 15:09:10 +05:00
except OSError as msg:
2018-11-06 00:19:58 +05:00
logging.InstallLog.writeToFile(str(msg)+ " [unInstallCyberPanelRepo]")
2017-10-24 19:16:36 +05:00
def removeGunicorn(self):
try:
os.chdir(self.cwd)
service = "/etc/systemd/system/gunicorn.service"
socket = "/etc/systemd/system/gunicorn.socket"
conf = "/etc/tmpfiles.d/gunicorn.conf"
os.remove(service)
os.remove(socket)
os.remove(conf)
2019-12-10 15:09:10 +05:00
except BaseException as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removeGunicorn]")
def removePostfixDovecot(self):
try:
2018-11-06 00:19:58 +05:00
command = 'yum -y remove postfix'
2017-10-24 19:16:36 +05:00
cmd = shlex.split(command)
2019-03-26 16:19:03 +05:00
res = subprocess.call(cmd)
2017-10-24 19:16:36 +05:00
shutil.rmtree("/etc/postfix")
shutil.rmtree("etc/dovecot")
2019-12-10 15:09:10 +05:00
except OSError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removePostfixDovecot]")
return 0
2019-12-10 15:09:10 +05:00
except ValueError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removePostfixDovecot]")
return 0
return 1
def removeMysql(self):
try:
2018-11-06 00:19:58 +05:00
command = 'yum -y remove mariadb mariadb-server'
2017-10-24 19:16:36 +05:00
cmd = shlex.split(command)
2019-03-26 16:19:03 +05:00
res = subprocess.call(cmd)
2017-10-24 19:16:36 +05:00
shutil.rmtree("/var/lib/mysql")
os.remove("/etc/my.cnf")
2019-12-10 15:09:10 +05:00
except OSError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removeMysql]")
return 0
2019-12-10 15:09:10 +05:00
except ValueError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removeMysql]")
return 0
return 1
def removeLiteSpeed(self):
try:
2018-11-06 00:19:58 +05:00
command = 'yum -y remove openlitespeed'
2017-10-24 19:16:36 +05:00
2018-11-06 00:19:58 +05:00
cmd = shlex.split(command)
2017-10-24 19:16:36 +05:00
2019-03-26 16:19:03 +05:00
res = subprocess.call(cmd)
2017-10-24 19:16:36 +05:00
2018-11-06 00:19:58 +05:00
shutil.rmtree("/usr/local/lsws")
2017-10-24 19:16:36 +05:00
2019-12-10 15:09:10 +05:00
except OSError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removeLiteSpeed]")
return 0
2019-12-10 15:09:10 +05:00
except ValueError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removeLiteSpeed]")
return 0
return 1
def removeCyberPanel(self):
try:
shutil.rmtree("/usr/local/CyberCP")
os.remove("/usr/local/CyberCP2.tar.gz")
shutil.rmtree("/etc/cyberpanel")
2019-12-10 15:09:10 +05:00
except OSError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removeCyberPanel]")
return 0
2019-12-10 15:09:10 +05:00
except ValueError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removeCyberPanel]")
return 0
return 1
def removePureFTPD(self):
try:
2018-11-06 00:19:58 +05:00
command = 'yum -y remove pure-ftpd'
2017-10-24 19:16:36 +05:00
2018-11-06 00:19:58 +05:00
cmd = shlex.split(command)
2017-10-24 19:16:36 +05:00
2019-03-26 16:19:03 +05:00
res = subprocess.call(cmd)
2017-10-24 19:16:36 +05:00
2018-11-06 00:19:58 +05:00
shutil.rmtree("/etc/pure-ftpd")
2017-10-24 19:16:36 +05:00
2019-12-10 15:09:10 +05:00
except OSError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removePureFTPD]")
return 0
2019-12-10 15:09:10 +05:00
except ValueError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removePureFTPD]")
return 0
return 1
def removePowerDNS(self):
try:
2018-11-06 00:19:58 +05:00
command = 'yum -y remove pdns'
2017-10-24 19:16:36 +05:00
2018-11-06 00:19:58 +05:00
cmd = shlex.split(command)
2017-10-24 19:16:36 +05:00
2019-03-26 16:19:03 +05:00
res = subprocess.call(cmd)
2018-11-06 00:19:58 +05:00
shutil.rmtree("/etc/pdns")
2017-10-24 19:16:36 +05:00
2019-12-10 15:09:10 +05:00
except OSError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removePowerDNS]")
return 0
2019-12-10 15:09:10 +05:00
except ValueError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removePowerDNS]")
return 0
return 1
def removePHP(self):
try:
2018-11-06 00:19:58 +05:00
command = 'yum -y remove lsphp*'
2017-10-24 19:16:36 +05:00
2018-11-06 00:19:58 +05:00
cmd = shlex.split(command)
2017-10-24 19:16:36 +05:00
2019-03-26 16:19:03 +05:00
res = subprocess.call(cmd)
2017-10-24 19:16:36 +05:00
2018-11-06 00:19:58 +05:00
shutil.rmtree("/etc/pdns")
2017-10-24 19:16:36 +05:00
2019-12-10 15:09:10 +05:00
except OSError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removePHP]")
return 0
2019-12-10 15:09:10 +05:00
except ValueError as msg:
2017-10-24 19:16:36 +05:00
logging.InstallLog.writeToFile(str(msg) + " [removePHP]")
return 0
return 1
def Main():
remove = unInstallCyberPanel()
remove.removeLiteSpeed()
remove.removeMysql()
remove.removePostfixDovecot()
remove.removePureFTPD()
remove.removeCyberPanel()
remove.removeGunicorn()
remove.unInstallCyberPanelRepo()
remove.removePowerDNS()
remove.removePHP()
print("##########################################")
print(" Successfully Uninstalled ")
print("##########################################")
Main()