Actually some real stuff

This commit is contained in:
rperper
2018-10-26 16:25:13 -04:00
parent c2b09182c2
commit cb379b9281
3 changed files with 61 additions and 35 deletions

View File

@@ -25,7 +25,7 @@ ubuntu=1
class preFlightsChecks: class preFlightsChecks:
cyberPanelMirror = "mirror.cyberpanel.net/pip" cyberPanelMirror = "mirror.cyberpanel.net/pip"
def __init__(self,rootPath,ip,path,cwd,cyberPanelPath,distro): def __init__(self, rootPath, ip, path, cwd, cyberPanelPath, distro):
self.ipAddr = ip self.ipAddr = ip
self.path = path self.path = path
self.cwd = cwd self.cwd = cwd
@@ -3148,7 +3148,7 @@ def main():
os.mkdir("/etc/cyberpanel") os.mkdir("/etc/cyberpanel")
except OSError as e: except OSError as e:
if e.errno != errno.EEXIST: if e.errno != errno.EEXIST:
self.stdOut("Error creating /etc/cyberpanel directory: " + str(e), 1, 1, os.EX_CANTCREAT) preFlightsChecks.stdOut("Error creating /etc/cyberpanel directory: " + str(e), 1, 1, os.EX_CANTCREAT)
else: else:
pass pass
@@ -3159,7 +3159,7 @@ def main():
cwd = os.getcwd() cwd = os.getcwd()
distro = get_distro() distro = get_distro()
checks = preFlightsChecks("/usr/local/lsws/",args.publicip,"/usr/local",cwd,"/usr/local/CyberCP", distro) checks = preFlightsChecks("/usr/local/lsws/", args.publicip, "/usr/local", cwd, "/usr/local/CyberCP", distro)
if distro == ubuntu: if distro == ubuntu:
os.chdir("/etc/cyberpanel") os.chdir("/etc/cyberpanel")

View File

@@ -3,7 +3,7 @@ import subprocess
import os import os
import pexpect import pexpect
from mysqlUtilities import mysqlUtilities from mysqlUtilities import mysqlUtilities
from install import preflightsChecks import install
import installLog as logging import installLog as logging
import shlex import shlex
import randomPassword import randomPassword
@@ -467,12 +467,16 @@ class InstallCyberPanel:
while(1): while(1):
command = "systemctl enable mysql" if self.distro == ubuntu:
command = "systemctl enable mariadb"
else:
command = "systemctl enable mysql"
res = subprocess.call(shlex.split(command)) res = subprocess.call(shlex.split(command))
if res == 1: if res == 1:
count = count + 1 count = count + 1
InstallCyberPanel.stdOut("Trying to enable MariaDB instance to start and system restart, trying again, try number: " + str(count)) InstallCyberPanel.stdOut("Trying to enable MariaDB instance to start at system restart, "
"trying again, try number: " + str(count))
if count == 3: if count == 3:
logging.InstallLog.writeToFile("Failed to enable MariaDB instance to run at system restart, " logging.InstallLog.writeToFile("Failed to enable MariaDB instance to run at system restart, "
"you can do this later using systemctl enable mysql! [installMySQL]") "you can do this later using systemctl enable mysql! [installMySQL]")
@@ -895,7 +899,7 @@ class InstallCyberPanel:
while(1): while(1):
if self.distro == ubuntu: if self.distro == ubuntu:
command = "apt-get -y install pdns-backend-mysql" command = "apt-get -y install pdns-server pdns-backend-mysql"
else: else:
command = 'yum -y install pdns pdns-backend-mysql' command = 'yum -y install pdns pdns-backend-mysql'
cmd = shlex.split(command) cmd = shlex.split(command)
@@ -1166,11 +1170,11 @@ def Main(cwd, mysql, distro):
InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass() InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass()
password = open("/etc/cyberpanel/mysqlPassword","w") password = open("/etc/cyberpanel/mysqlPassword", "w")
password.writelines(InstallCyberPanel.mysql_Root_password) password.writelines(InstallCyberPanel.mysql_Root_password)
password.close() password.close()
installer = InstallCyberPanel("/usr/local/lsws/",cwd,distro) installer = InstallCyberPanel("/usr/local/lsws/", cwd, distro)
installer.installLiteSpeed() installer.installLiteSpeed()
installer.changePortTo80() installer.changePortTo80()
@@ -1184,7 +1188,7 @@ def Main(cwd, mysql, distro):
installer.changeMYSQLRootPasswordCyberPanel(mysql) installer.changeMYSQLRootPasswordCyberPanel(mysql)
installer.startMariaDB() installer.startMariaDB()
mysqlUtilities.createDatabaseCyberPanel("cyberpanel","cyberpanel",InstallCyberPanel.mysqlPassword, mysql) mysqlUtilities.createDatabaseCyberPanel("cyberpanel", "cyberpanel", InstallCyberPanel.mysqlPassword, mysql)
installer.installPureFTPD() installer.installPureFTPD()
installer.installPureFTPDConfigurations(mysql) installer.installPureFTPDConfigurations(mysql)

View File

@@ -6,20 +6,25 @@ import argparse
import os import os
import shlex import shlex
import socket import socket
from install import preFlightsChecks import install
#distros
centos=0
ubuntu=1
distro = install.get_distro()
class unInstallCyberPanel: class unInstallCyberPanel:
def unInstallCyberPanelRepo(self): def unInstallCyberPanelRepo(self):
try: if distro == centos:
copyPath = "/etc/yum.repos.d/cyberpanel.repo" try:
os.remove(copyPath) copyPath = "/etc/yum.repos.d/cyberpanel.repo"
os.remove(copyPath)
except OSError,msg: except OSError,msg:
logging.InstallLog.writeToFile(str(msg)+ " [unInstallCyberPanelRepo]") logging.InstallLog.writeToFile(str(msg)+ " [unInstallCyberPanelRepo]")
def removeGunicorn(self): def removeGunicorn(self):
try: try:
@@ -41,7 +46,10 @@ class unInstallCyberPanel:
def removePostfixDovecot(self): def removePostfixDovecot(self):
try: try:
command = 'yum -y remove postfix' if distro == centos:
command = 'yum -y remove postfix'
else:
command = 'apt-get -y remove postfix'
cmd = shlex.split(command) cmd = shlex.split(command)
@@ -63,7 +71,10 @@ class unInstallCyberPanel:
def removeMysql(self): def removeMysql(self):
try: try:
command = 'yum -y remove mariadb mariadb-server' if distro == centos:
command = 'yum -y remove mariadb mariadb-server'
else:
command = 'apt-get -y remove mariadb-server'
cmd = shlex.split(command) cmd = shlex.split(command)
@@ -85,13 +96,16 @@ class unInstallCyberPanel:
def removeLiteSpeed(self): def removeLiteSpeed(self):
try: try:
command = 'yum -y remove openlitespeed' if distro == centos:
command = 'yum -y remove openlitespeed'
else:
command = 'apt-get -y remove openlitespeed'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
shutil.rmtree("/usr/local/lsws") shutil.rmtree("/usr/local/lsws")
except OSError, msg: except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [removeLiteSpeed]") logging.InstallLog.writeToFile(str(msg) + " [removeLiteSpeed]")
@@ -119,13 +133,16 @@ class unInstallCyberPanel:
def removePureFTPD(self): def removePureFTPD(self):
try: try:
command = 'yum -y remove pure-ftpd' if distro == centos:
command = 'yum -y remove pure-ftpd'
else:
command = 'apt-get -y remove pure-ftpd'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
shutil.rmtree("/etc/pure-ftpd") shutil.rmtree("/etc/pure-ftpd")
except OSError, msg: except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [removePureFTPD]") logging.InstallLog.writeToFile(str(msg) + " [removePureFTPD]")
@@ -137,14 +154,16 @@ class unInstallCyberPanel:
def removePowerDNS(self): def removePowerDNS(self):
try: try:
if distro == centos:
command = 'yum -y remove pdns'
else:
command = 'apt-get -y remove pdns-server'
command = 'yum -y remove pdns' cmd = shlex.split(command)
cmd = shlex.split(command) res = subprocess.call(cmd)
res = subprocess.call(cmd) shutil.rmtree("/etc/pdns")
shutil.rmtree("/etc/pdns")
except OSError, msg: except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [removePowerDNS]") logging.InstallLog.writeToFile(str(msg) + " [removePowerDNS]")
@@ -157,13 +176,16 @@ class unInstallCyberPanel:
def removePHP(self): def removePHP(self):
try: try:
command = 'yum -y remove lsphp*' if distro == centos:
command = 'yum -y remove lsphp*'
else:
command = 'apt-get -y remove lsphp*'
cmd = shlex.split(command) cmd = shlex.split(command)
res = subprocess.call(cmd) res = subprocess.call(cmd)
shutil.rmtree("/etc/pdns") shutil.rmtree("/etc/pdns")
except OSError, msg: except OSError, msg:
logging.InstallLog.writeToFile(str(msg) + " [removePHP]") logging.InstallLog.writeToFile(str(msg) + " [removePHP]")