From 012195fc51a0463341b6d6355490bb2e19480134 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 25 Oct 2018 10:01:44 -0400 Subject: [PATCH 01/58] Just the minimal first test ubuntu install script --- install-ubuntu.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 install-ubuntu.sh diff --git a/install-ubuntu.sh b/install-ubuntu.sh new file mode 100755 index 000000000..e0acf3bdc --- /dev/null +++ b/install-ubuntu.sh @@ -0,0 +1,29 @@ +#!/bin/bash +#yum autoremove epel-release -y +#rm -f /etc/yum.repos.d/epel.repo +#rm -f /etc/yum.repos.d/epel.repo.rpmsave +#yum install epel-release -y +#some provider's centos7 template come with incorrect or misconfigured epel.repo +#if systemctl is-active named | grep -q 'active'; then +# systemctl stop named +# systemctl disable named +# echo "Disabling named to aviod powerdns conflicts..." +# else +# echo "named is not installed or active, to next step..." +#fi +# above if will check if server has named.service running that occupies port 53 which makes powerdns failed to start +apt-get clean all +apt-get update -y +apt-get install curl -y +#setenforce 0 +#sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config +#wget https://cyberpanel.net/install.tar.gz +#tar xzvf install.tar.gz +apt-get install python -y +apt-get install git -y +#git clone https://github.com/rperper/cyberpanel.git +cd cyberpanel +cd install +chmod +x install.py +server_ip="$(wget -qO- http://whatismyip.akamai.com/)" +python install.py $server_ip From b9d56e2b37619cb9f9993c7d72817232ce65ebd8 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 25 Oct 2018 16:10:01 -0400 Subject: [PATCH 02/58] First real try --- install/.idea/vcs.xml | 6 + install/install.py | 389 +++++++++++++++++++++++++++++------------- 2 files changed, 274 insertions(+), 121 deletions(-) create mode 100644 install/.idea/vcs.xml diff --git a/install/.idea/vcs.xml b/install/.idea/vcs.xml new file mode 100644 index 000000000..6c0b86358 --- /dev/null +++ b/install/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/install/install.py b/install/install.py index 11163393c..5f4a9e442 100644 --- a/install/install.py +++ b/install/install.py @@ -1,4 +1,4 @@ -import sys +pathimport sys import subprocess import shutil import installLog as logging @@ -9,19 +9,26 @@ from firewallUtilities import FirewallUtilities import time import string import random +import os.path +import re # There can not be peace without first a great suffering. +#distros +centos=0 +ubuntu=1 + class preFlightsChecks: cyberPanelMirror = "mirror.cyberpanel.net/pip" - def __init__(self,rootPath,ip,path,cwd,cyberPanelPath): + def __init__(self,rootPath,ip,path,cwd,cyberPanelPath,distro): self.ipAddr = ip self.path = path self.cwd = cwd self.server_root_path = rootPath self.cyberPanelPath = cyberPanelPath + self.distro = distro @staticmethod def stdOut(message): @@ -32,26 +39,6 @@ class preFlightsChecks: print ("[" + time.strftime( "%I-%M-%S-%a-%b-%Y") + "] #########################################################################\n") - def checkIfSeLinuxDisabled(self): - try: - command = "sestatus" - output = subprocess.check_output(shlex.split(command)) - - if output.find("disabled") > -1 or output.find("permissive") > -1: - logging.InstallLog.writeToFile("SELinux Check OK. [checkIfSeLinuxDisabled]") - preFlightsChecks.stdOut("SELinux Check OK.") - return 1 - else: - logging.InstallLog.writeToFile("SELinux is enabled, please disable SELinux and restart the installation!") - preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - - except BaseException,msg: - logging.InstallLog.writeToFile(str(msg) + "[checkIfSeLinuxDisabled]") - logging.InstallLog.writeToFile("SELinux Check OK. [checkIfSeLinuxDisabled]") - preFlightsChecks.stdOut("SELinux Check OK.") - return 1 - def checkPythonVersion(self): if sys.version_info[0] == 2 and sys.version_info[1] == 7: return 1 @@ -63,84 +50,98 @@ class preFlightsChecks: try: count = 0 - while (1): - command = "yum install sudo -y" - cmd = shlex.split(command) - res = subprocess.call(cmd) + if distro == centos: + while (1): + command = "yum install sudo -y" + cmd = shlex.split(command) + res = subprocess.call(cmd) - if res == 1: - count = count + 1 - preFlightsChecks.stdOut("SUDO install failed, trying again, try number: " + str(count)) - if count == 3: - logging.InstallLog.writeToFile("We are not able to install SUDO, exiting the installer. [setup_account_cyberpanel]") - preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("SUDO successfully installed!") - preFlightsChecks.stdOut("SUDO successfully installed!") - break + if res == 1: + count = count + 1 + preFlightsChecks.stdOut("SUDO install failed, trying again, try number: " + str(count)) + if count == 3: + logging.InstallLog.writeToFile("We are not able to install SUDO, exiting the installer. [setup_account_cyberpanel]") + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) + else: + logging.InstallLog.writeToFile("SUDO successfully installed!") + preFlightsChecks.stdOut("SUDO successfully installed!") + break ## count = 0 - while (1): - command = "adduser cyberpanel" + if distro == ubuntu: + command = "useradd cyberpanel -g sudo" cmd = shlex.split(command) res = subprocess.call(cmd) + if res != 0 and res != 9: + logging.InstallLog.writeToFile("Can not create cyberpanel user, error #" + str(res)) + preFlightsChecks.stdOut("Can not create cyberpanel user, error #" + str(res)) + os._exit(0) + if res == 0: + logging.InstallLog.writeToFile("CyberPanel user added") + preFlightsChecks.stdOut("CyberPanel user added") - if res == 1: - count = count + 1 - preFlightsChecks.stdOut("Not able to add user cyberpanel to system, trying again, try number: " + str(count) + "\n") - if count == 3: - logging.InstallLog.writeToFile("We are not able add user cyberpanel to system, exiting the installer. [setup_account_cyberpanel]") - preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("CyberPanel user added!") - preFlightsChecks.stdOut("CyberPanel user added!") - break + else: + while (1): + command = "adduser cyberpanel" + cmd = shlex.split(command) + res = subprocess.call(cmd) - ## + if res == 1: + count = count + 1 + preFlightsChecks.stdOut("Not able to add user cyberpanel to system, trying again, try number: " + str(count) + "\n") + if count == 3: + logging.InstallLog.writeToFile("We are not able add user cyberpanel to system, exiting the installer. [setup_account_cyberpanel]") + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) + else: + logging.InstallLog.writeToFile("CyberPanel user added!") + preFlightsChecks.stdOut("CyberPanel user added!") + break - count = 0 + ## - while (1): + count = 0 - command = "usermod -aG wheel cyberpanel" - cmd = shlex.split(command) - res = subprocess.call(cmd) + while (1): - if res == 1: - count = count + 1 - preFlightsChecks.stdOut("We are trying to add CyberPanel user to SUDO group, trying again, try number: " + str(count) + "\n") - if count == 3: - logging.InstallLog.writeToFile("Not able to add user CyberPanel to SUDO group, exiting the installer. [setup_account_cyberpanel]") - preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("CyberPanel user was successfully added to SUDO group!") - preFlightsChecks.stdOut("CyberPanel user was successfully added to SUDO group!") - break + command = "usermod -aG wheel cyberpanel" + cmd = shlex.split(command) + res = subprocess.call(cmd) + + if res == 1: + count = count + 1 + preFlightsChecks.stdOut("We are trying to add CyberPanel user to SUDO group, trying again, try number: " + str(count) + "\n") + if count == 3: + logging.InstallLog.writeToFile("Not able to add user CyberPanel to SUDO group, exiting the installer. [setup_account_cyberpanel]") + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) + else: + logging.InstallLog.writeToFile("CyberPanel user was successfully added to SUDO group!") + preFlightsChecks.stdOut("CyberPanel user was successfully added to SUDO group!") + break - ############################### + ############################### - path = "/etc/sudoers" + path = "/etc/sudoers" - data = open(path, 'r').readlines() + data = open(path, 'r').readlines() - writeToFile = open(path, 'w') + writeToFile = open(path, 'w') - for items in data: - if items.find("wheel ALL=(ALL) NOPASSWD: ALL") > -1: - writeToFile.writelines("%wheel ALL=(ALL) NOPASSWD: ALL") - else: - writeToFile.writelines(items) + for items in data: + if items.find("wheel ALL=(ALL) NOPASSWD: ALL") > -1: + writeToFile.writelines("%wheel ALL=(ALL) NOPASSWD: ALL") + else: + writeToFile.writelines(items) - writeToFile.close() + writeToFile.close() - ############################### + ############################### count = 0 @@ -203,23 +204,62 @@ class preFlightsChecks: cmd = [] count = 0 - while(1): - cmd.append("rpm") - cmd.append("-ivh") - cmd.append("http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm") - res = subprocess.call(cmd) + if repo == ubuntu: + try: + filename = "enable_lst_debain_repo.sh" + command = "wget http://rpms.litespeedtech.com/debian/" + filename + cmd = shlex.split(command) + res = subprocess.call(cmd) + if res != 0: + logging.InstallLog.writeToFile("Unable to download Ubuntu CyberPanel installer! [installCyberPanelRepo]:"" + " Error #" + str(res)) + preFlightsChecks.stdOut("Unable to download Ubuntu CyberPanel installer! [installCyberPanelRepo]:"" + " Error #" + str(res)) + os._exit(os.EX_NOINPUT); + + os.chmod(filename, stat.S_IRWXU | stat.s_S_IRWXG) + + command = "./" + filename + cmd = shlex.split(command) + res = subprocess.call(cmd) + + if res != 0: + logging.InstallLog.writeToFile("Unable to install Ubuntu CyberPanel! [installCyberPanelRepo]:"" + " Error #" + str(res)) + preFlightsChecks.stdOut("Unable to install Ubuntu CyberPanel! [installCyberPanelRepo]:"" + " Error #" + str(res)) + os._exit(os.EX_NOINPUT); + + except OSError as err: + logging.InstallLog.writeToFile("Exception during CyberPanel install: " + err) + preFlightsChecks.stdOut("Exception during CyberPanel install: " + err) + os._exit(os.EX_OSERR) + + except: + logging.InstallLog.writeToFile("Exception during CyberPanel install") + preFlightsChecks.stdOut("Exception during CyberPanel install") + os._exit(os.EX_SOFTWARE) + + else: + while(1): + cmd.append("rpm") + cmd.append("-ivh") + cmd.append("http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm") + res = subprocess.call(cmd) + + if res == 1: + count = count + 1 + preFlightsChecks.stdOut("Unable to add CyberPanel official repository, trying again, try number: " + str(count) + "\n") + if count == 3: + logging.InstallLog.writeToFile("Unable to add CyberPanel official repository, exiting installer! [installCyberPanelRepo]") + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) + else: + logging.InstallLog.writeToFile("CyberPanel Repo added!") + preFlightsChecks.stdOut("CyberPanel Repo added!") + break + return 0 - if res == 1: - count = count + 1 - preFlightsChecks.stdOut("Unable to add CyberPanel official repository, trying again, try number: " + str(count) + "\n") - if count == 3: - logging.InstallLog.writeToFile("Unable to add CyberPanel official repository, exiting installer! [installCyberPanelRepo]") - preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("CyberPanel Repo added!") - preFlightsChecks.stdOut("CyberPanel Repo added!") - break def enableEPELRepo(self): try: @@ -258,10 +298,14 @@ class preFlightsChecks: return 1 + def install_pip(self): count = 0 while (1): - command = "yum -y install python-pip" + if distro == ubuntu: + command = "apt-get -y install python-pip" + else: + command = "yum -y install python-pip" res = subprocess.call(shlex.split(command)) if res == 1: @@ -276,10 +320,14 @@ class preFlightsChecks: preFlightsChecks.stdOut("PIP successfully installed!") break + def install_python_dev(self): count = 0 while (1): - command = "yum -y install python-devel" + if distro == centos + command = "yum -y install python-devel" + else: + command = "apt-get -y install python-dev" res = subprocess.call(shlex.split(command)) if res == 1: @@ -294,11 +342,15 @@ class preFlightsChecks: preFlightsChecks.stdOut("Python development tools successfully installed!") break + def install_gcc(self): count = 0 while (1): - command = "yum -y install gcc" + if distro == centos: + command = "yum -y install gcc" + else + command = "apt-get -y install gcc" res = subprocess.call(shlex.split(command)) if res == 1: @@ -502,7 +554,10 @@ class preFlightsChecks: def install_python_mysql_library(self): count = 0 while (1): - command = "yum -y install MySQL-python" + if distro == centos: + command = "yum -y install MySQL-python" + else + command = "apt-get -y install libmysqlclient-dev" res = subprocess.call(shlex.split(command)) if res == 1: count = count + 1 @@ -516,10 +571,23 @@ class preFlightsChecks: preFlightsChecks.stdOut("MySQL-python successfully installed!") break + if distro == ubuntu + command = "pip install MySQL-python" + res = subprocess.call(shlex.split()) + if res != 0: + logging.InstallLog.writeToFile( + "Unable to install MySQL-python, exiting installer! [install_python_mysql_library] Error: " + str(res)) + preFlightsChecks.stdOut( + "Unable to install MySQL-python, exiting installer! [install_python_mysql_library] Error: " + str(res)) + os._exit(os.EX_OSERR) + def install_gunicorn(self): count = 0 while (1): - command = "easy_install gunicorn" + if distro == ubuntu: + command = "pip install gunicorn" + else + command = "easy_install gunicorn" res = subprocess.call(shlex.split(command)) if res == 1: count = count + 1 @@ -643,7 +711,10 @@ class preFlightsChecks: def install_psmisc(self): count = 0 while (1): - command = "yum -y install psmisc" + if distro == centos: + command = "yum -y install psmisc" + else: + command = "apt-get -y install psmisc" res = subprocess.call(shlex.split(command)) if res == 1: count = count + 1 @@ -878,7 +949,10 @@ class preFlightsChecks: count = 0 while (1): - command = 'yum -y install unzip' + if distro == centos: + command = 'yum -y install unzip' + else + command = 'apt-get -y install unzip' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -909,7 +983,10 @@ class preFlightsChecks: count = 0 while (1): - command = 'yum -y install zip' + if distro == centos: + command = 'yum -y install zip' + else + command = 'apt-get -y install zip' cmd = shlex.split(command) @@ -1053,13 +1130,19 @@ class preFlightsChecks: def install_postfix_davecot(self): try: + if distro == centos: + command = 'yum remove postfix -y' + else + command = 'apt-get -y remove postfix' - command = 'yum remove postfix -y' subprocess.call(shlex.split(command)) count = 0 while(1): - command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-3.2.4-1.gf.el7.x86_64.rpm' + if distro == centos: + command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-3.2.4-1.gf.el7.x86_64.rpm' + else + command = 'apt-get -y install dovecot-imapd dovecot-pop3d' cmd = shlex.split(command) @@ -1079,7 +1162,10 @@ class preFlightsChecks: count = 0 while (1): - command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-mysql-3.2.4-1.gf.el7.x86_64.rpm' + if distro == centos + command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-mysql-3.2.4-1.gf.el7.x86_64.rpm' + else + command = 'apt-get -y install mysql-server' cmd = shlex.split(command) @@ -1101,7 +1187,10 @@ class preFlightsChecks: while(1): - command = 'yum -y install dovecot dovecot-mysql' + if distro == centos + command = 'yum -y install dovecot dovecot-mysql' + else + command = 'apt-get -y install dovecot-mysql' cmd = shlex.split(command) @@ -2048,6 +2137,9 @@ class preFlightsChecks: def installFirewalld(self): + if distro == ubuntu + return 0 # Uses AppArmor + try: preFlightsChecks.stdOut("Enabling Firewall!") @@ -2245,7 +2337,10 @@ class preFlightsChecks: count = 0 while(1): - command = 'yum install cronie -y' + if distro == centos: + command = 'yum install cronie -y' + else + command = 'apt-get -y install cron' cmd = shlex.split(command) @@ -2266,8 +2361,10 @@ class preFlightsChecks: count = 0 while(1): - - command = 'systemctl enable crond' + if distro == centos: + command = 'systemctl enable crond' + else + command = 'systemctl enable cron' cmd = shlex.split(command) res = subprocess.call(cmd, stdout=file) @@ -2285,7 +2382,11 @@ class preFlightsChecks: count = 0 while(1): - command = 'systemctl start crond' + if distro == centos: + command = 'systemctl start crond' + else + command = 'systemctl start cron' + cmd = shlex.split(command) res = subprocess.call(cmd, stdout=file) @@ -2330,7 +2431,11 @@ class preFlightsChecks: count = 0 while(1): - command = 'systemctl restart crond.service' + if distro == centos: + command = 'systemctl restart crond.service' + else + command = 'systemctl restart cron.service' + cmd = shlex.split(command) res = subprocess.call(cmd, stdout=file) @@ -2396,8 +2501,11 @@ class preFlightsChecks: try: count = 0 while (1): + if distro == centos + command = 'yum -y install rsync' + else + command = 'apt-get -y install rsync' - command = 'yum -y install rsync' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -2609,8 +2717,11 @@ class preFlightsChecks: try: count = 0 while (1): + if distro == centos: + command = 'yum -y install opendkim' + else: + command = 'apt-get -y install opendkim' - command = 'yum -y install opendkim' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -2948,9 +3059,38 @@ milter_default_action = accept +def get_distro(): + distro = -1 + distroFile = "" + if os.path.exists("/etc/lsb-release"): + distroFile = "/etc/lsb-release" + with open(distroFile) as f: + for line in f: + if line == "DISTRIB_ID=Ubuntu": + distro = ubuntu + + else if (exists("/etc/os-release")): + distroFile = "/etc/os-release" + with open(distroFile) as f: + for line in f: + if line == "ID=\"centos\"": + distro = centos + + else: + logging.InstallLog.writeToFile("Can't find linux release file - fatal error") + preFlightsChecks.stdOut("Can't find linux release file - fatal error") + os._exit(os.EX_UNAVAILABLE) + + if distro == -1: + logging.InstallLog.writeToFile("Can't find distro name in " + distroFile + " - fatal error") + preFlightsChecks.stdOut("Can't find distro name in " + distroFile + " - fatal error") + os._exit(os.EX_UNAVAILABLE) + + return distro -def main(): + +def pgm_main(): parser = argparse.ArgumentParser(description='CyberPanel Installer') parser.add_argument('publicip', help='Please enter public IP for your VPS or dedicated server.') @@ -2973,25 +3113,32 @@ def main(): cwd = os.getcwd() - checks = preFlightsChecks("/usr/local/lsws/",args.publicip,"/usr/local",cwd,"/usr/local/CyberCP") + + checks = preFlightsChecks("/usr/local/lsws/",args.publicip,"/usr/local",cwd,"/usr/local/CyberCP", get_distro()) + + if distro == ubuntu: + os.chdir("/etc/cyberpanel") if args.mysql == None: mysql = 'One' preFlightsChecks.stdOut("Single MySQL instance version will be installed.") else: mysql = args.mysql - preFlightsChecks.stdOut("Dobule MySQL instance version will be installed.") + preFlightsChecks.stdOut("Double MySQL instance version will be installed.") checks.checkPythonVersion() checks.setup_account_cyberpanel() - checks.yum_update() + if distro == centos: + checks.yum_update() checks.installCyberPanelRepo() - checks.enableEPELRepo() + if distro == centos: + checks.enableEPELRepo() checks.install_pip() checks.install_python_dev() checks.install_gcc() - checks.install_python_setup_tools() + if distro == centos: + checks.install_python_setup_tools() checks.install_django() checks.install_pexpect() checks.install_python_mysql_library() @@ -3063,5 +3210,5 @@ def main(): logging.InstallLog.writeToFile("CyberPanel installation successfully completed!") -if __name__ == "__main__": - main() +pgm_main() + From b8e11e5ab1751cde63ea39096eb86399bfda53cb Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 25 Oct 2018 16:18:47 -0400 Subject: [PATCH 03/58] Minor string handling bugs. --- install/install.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/install/install.py b/install/install.py index 5f4a9e442..f087164ce 100644 --- a/install/install.py +++ b/install/install.py @@ -1,4 +1,4 @@ -pathimport sys +import sys import subprocess import shutil import installLog as logging @@ -211,10 +211,10 @@ class preFlightsChecks: cmd = shlex.split(command) res = subprocess.call(cmd) if res != 0: - logging.InstallLog.writeToFile("Unable to download Ubuntu CyberPanel installer! [installCyberPanelRepo]:"" - " Error #" + str(res)) - preFlightsChecks.stdOut("Unable to download Ubuntu CyberPanel installer! [installCyberPanelRepo]:"" + logging.InstallLog.writeToFile("Unable to download Ubuntu CyberPanel installer! [installCyberPanelRepo]:" " Error #" + str(res)) + preFlightsChecks.stdOut("Unable to download Ubuntu CyberPanel installer! [installCyberPanelRepo]:" + " Error #" + str(res)) os._exit(os.EX_NOINPUT); os.chmod(filename, stat.S_IRWXU | stat.s_S_IRWXG) @@ -224,9 +224,9 @@ class preFlightsChecks: res = subprocess.call(cmd) if res != 0: - logging.InstallLog.writeToFile("Unable to install Ubuntu CyberPanel! [installCyberPanelRepo]:"" + logging.InstallLog.writeToFile("Unable to install Ubuntu CyberPanel! [installCyberPanelRepo]:" " Error #" + str(res)) - preFlightsChecks.stdOut("Unable to install Ubuntu CyberPanel! [installCyberPanelRepo]:"" + preFlightsChecks.stdOut("Unable to install Ubuntu CyberPanel! [installCyberPanelRepo]:" " Error #" + str(res)) os._exit(os.EX_NOINPUT); From ae45dd45e412e394a0e25e67c9a95ba29404a9e5 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 25 Oct 2018 16:47:26 -0400 Subject: [PATCH 04/58] Finally found the inspect code button for syntax errors. --- install/install.py | 52 +++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/install/install.py b/install/install.py index f087164ce..cf34c4fea 100644 --- a/install/install.py +++ b/install/install.py @@ -9,8 +9,8 @@ from firewallUtilities import FirewallUtilities import time import string import random -import os.path -import re +from os.path import * +from stat import * # There can not be peace without first a great suffering. @@ -18,6 +18,9 @@ import re centos=0 ubuntu=1 +distro = centos + + class preFlightsChecks: cyberPanelMirror = "mirror.cyberpanel.net/pip" @@ -204,7 +207,7 @@ class preFlightsChecks: cmd = [] count = 0 - if repo == ubuntu: + if distro == ubuntu: try: filename = "enable_lst_debain_repo.sh" command = "wget http://rpms.litespeedtech.com/debian/" + filename @@ -215,9 +218,9 @@ class preFlightsChecks: " Error #" + str(res)) preFlightsChecks.stdOut("Unable to download Ubuntu CyberPanel installer! [installCyberPanelRepo]:" " Error #" + str(res)) - os._exit(os.EX_NOINPUT); + os._exit(os.EX_NOINPUT) - os.chmod(filename, stat.S_IRWXU | stat.s_S_IRWXG) + os.chmod(filename, S_IRWXU | S_IRWXG) command = "./" + filename cmd = shlex.split(command) @@ -228,11 +231,11 @@ class preFlightsChecks: " Error #" + str(res)) preFlightsChecks.stdOut("Unable to install Ubuntu CyberPanel! [installCyberPanelRepo]:" " Error #" + str(res)) - os._exit(os.EX_NOINPUT); + os._exit(os.EX_NOINPUT) except OSError as err: - logging.InstallLog.writeToFile("Exception during CyberPanel install: " + err) - preFlightsChecks.stdOut("Exception during CyberPanel install: " + err) + logging.InstallLog.writeToFile("Exception during CyberPanel install: " + str(err)) + preFlightsChecks.stdOut("Exception during CyberPanel install: " + str(err)) os._exit(os.EX_OSERR) except: @@ -324,7 +327,7 @@ class preFlightsChecks: def install_python_dev(self): count = 0 while (1): - if distro == centos + if distro == centos: command = "yum -y install python-devel" else: command = "apt-get -y install python-dev" @@ -349,7 +352,7 @@ class preFlightsChecks: while (1): if distro == centos: command = "yum -y install gcc" - else + else: command = "apt-get -y install gcc" res = subprocess.call(shlex.split(command)) @@ -573,7 +576,7 @@ class preFlightsChecks: if distro == ubuntu command = "pip install MySQL-python" - res = subprocess.call(shlex.split()) + res = subprocess.call(shlex.split(command)) if res != 0: logging.InstallLog.writeToFile( "Unable to install MySQL-python, exiting installer! [install_python_mysql_library] Error: " + str(res)) @@ -3061,17 +3064,17 @@ milter_default_action = accept def get_distro(): distro = -1 - distroFile = "" - if os.path.exists("/etc/lsb-release"): - distroFile = "/etc/lsb-release" - with open(distroFile) as f: + distro_file = "" + if exists("/etc/lsb-release"): + distro_file = "/etc/lsb-release" + with open(distro_file) as f: for line in f: if line == "DISTRIB_ID=Ubuntu": distro = ubuntu - else if (exists("/etc/os-release")): - distroFile = "/etc/os-release" - with open(distroFile) as f: + elif exists("/etc/os-release"): + distro_file = "/etc/os-release" + with open(distro_file) as f: for line in f: if line == "ID=\"centos\"": distro = centos @@ -3082,15 +3085,15 @@ def get_distro(): os._exit(os.EX_UNAVAILABLE) if distro == -1: - logging.InstallLog.writeToFile("Can't find distro name in " + distroFile + " - fatal error") - preFlightsChecks.stdOut("Can't find distro name in " + distroFile + " - fatal error") + logging.InstallLog.writeToFile("Can't find distro name in " + distro_file + " - fatal error") + preFlightsChecks.stdOut("Can't find distro name in " + distro_file + " - fatal error") os._exit(os.EX_UNAVAILABLE) return distro -def pgm_main(): +def main(): parser = argparse.ArgumentParser(description='CyberPanel Installer') parser.add_argument('publicip', help='Please enter public IP for your VPS or dedicated server.') @@ -3113,8 +3116,8 @@ def pgm_main(): cwd = os.getcwd() - - checks = preFlightsChecks("/usr/local/lsws/",args.publicip,"/usr/local",cwd,"/usr/local/CyberCP", get_distro()) + distro = get_distro() + checks = preFlightsChecks("/usr/local/lsws/",args.publicip,"/usr/local",cwd,"/usr/local/CyberCP", distro) if distro == ubuntu: os.chdir("/etc/cyberpanel") @@ -3210,5 +3213,6 @@ def pgm_main(): logging.InstallLog.writeToFile("CyberPanel installation successfully completed!") -pgm_main() +if __name__ == "__main"_: + main() From 84b80aa07ed6962b2277f91414eb24c8315ac908 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 25 Oct 2018 16:58:15 -0400 Subject: [PATCH 05/58] More dumb syntax errors... --- install/install.py | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/install/install.py b/install/install.py index cf34c4fea..fd759c064 100644 --- a/install/install.py +++ b/install/install.py @@ -559,7 +559,7 @@ class preFlightsChecks: while (1): if distro == centos: command = "yum -y install MySQL-python" - else + else: command = "apt-get -y install libmysqlclient-dev" res = subprocess.call(shlex.split(command)) if res == 1: @@ -589,7 +589,7 @@ class preFlightsChecks: while (1): if distro == ubuntu: command = "pip install gunicorn" - else + else: command = "easy_install gunicorn" res = subprocess.call(shlex.split(command)) if res == 1: @@ -954,7 +954,7 @@ class preFlightsChecks: while (1): if distro == centos: command = 'yum -y install unzip' - else + else: command = 'apt-get -y install unzip' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -988,7 +988,7 @@ class preFlightsChecks: if distro == centos: command = 'yum -y install zip' - else + else: command = 'apt-get -y install zip' cmd = shlex.split(command) @@ -1135,7 +1135,7 @@ class preFlightsChecks: try: if distro == centos: command = 'yum remove postfix -y' - else + else: command = 'apt-get -y remove postfix' subprocess.call(shlex.split(command)) @@ -1144,7 +1144,7 @@ class preFlightsChecks: while(1): if distro == centos: command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-3.2.4-1.gf.el7.x86_64.rpm' - else + else: command = 'apt-get -y install dovecot-imapd dovecot-pop3d' cmd = shlex.split(command) @@ -1165,9 +1165,9 @@ class preFlightsChecks: count = 0 while (1): - if distro == centos + if distro == centos: command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-mysql-3.2.4-1.gf.el7.x86_64.rpm' - else + else: command = 'apt-get -y install mysql-server' cmd = shlex.split(command) @@ -1190,9 +1190,9 @@ class preFlightsChecks: while(1): - if distro == centos + if distro == centos: command = 'yum -y install dovecot dovecot-mysql' - else + else: command = 'apt-get -y install dovecot-mysql' cmd = shlex.split(command) @@ -1343,7 +1343,6 @@ class preFlightsChecks: os.chdir(self.cwd) - mysql_virtual_domains = "/etc/postfix/mysql-virtual_domains.cf" mysql_virtual_forwardings = "/etc/postfix/mysql-virtual_forwardings.cf" mysql_virtual_mailboxes = "/etc/postfix/mysql-virtual_mailboxes.cf" @@ -1353,8 +1352,6 @@ class preFlightsChecks: davecot = "/etc/dovecot/dovecot.conf" davecotmysql = "/etc/dovecot/dovecot-sql.conf.ext" - - if os.path.exists(mysql_virtual_domains): os.remove(mysql_virtual_domains) @@ -2140,7 +2137,7 @@ class preFlightsChecks: def installFirewalld(self): - if distro == ubuntu + if distro == ubuntu: return 0 # Uses AppArmor try: @@ -2342,7 +2339,7 @@ class preFlightsChecks: if distro == centos: command = 'yum install cronie -y' - else + else: command = 'apt-get -y install cron' cmd = shlex.split(command) @@ -2366,7 +2363,7 @@ class preFlightsChecks: while(1): if distro == centos: command = 'systemctl enable crond' - else + else: command = 'systemctl enable cron' cmd = shlex.split(command) res = subprocess.call(cmd, stdout=file) @@ -2387,7 +2384,7 @@ class preFlightsChecks: while(1): if distro == centos: command = 'systemctl start crond' - else + else: command = 'systemctl start cron' cmd = shlex.split(command) @@ -2436,7 +2433,7 @@ class preFlightsChecks: while(1): if distro == centos: command = 'systemctl restart crond.service' - else + else: command = 'systemctl restart cron.service' cmd = shlex.split(command) @@ -2506,7 +2503,7 @@ class preFlightsChecks: while (1): if distro == centos command = 'yum -y install rsync' - else + else: command = 'apt-get -y install rsync' cmd = shlex.split(command) From 4d18ef40a7cdfbcc0f10c6bd380be79481d94af5 Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 26 Oct 2018 09:11:17 -0400 Subject: [PATCH 06/58] Adding progress messages --- install/install.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index fd759c064..a33a84f04 100644 --- a/install/install.py +++ b/install/install.py @@ -50,6 +50,7 @@ class preFlightsChecks: os._exit(0) def setup_account_cyberpanel(self): + self.stdOut("Setup Cyberpanel account") try: count = 0 @@ -204,6 +205,7 @@ class preFlightsChecks: return 1 def installCyberPanelRepo(self): + self.stdOut("Install Cyberpanel repo") cmd = [] count = 0 @@ -303,6 +305,7 @@ class preFlightsChecks: def install_pip(self): + self.stdOut("Install pip") count = 0 while (1): if distro == ubuntu: @@ -325,6 +328,7 @@ class preFlightsChecks: def install_python_dev(self): + self.stdOut("Install python development environment") count = 0 while (1): if distro == centos: @@ -347,6 +351,7 @@ class preFlightsChecks: def install_gcc(self): + self.stdOut("Install gcc") count = 0 while (1): @@ -369,6 +374,7 @@ class preFlightsChecks: break def install_python_setup_tools(self): + self.stdOut("Install python setup tools"); count = 0 while (1): command = "yum -y install python-setuptools" @@ -390,6 +396,7 @@ class preFlightsChecks: break def install_python_requests(self): + self.stdOut("Install python requests") try: import requests @@ -536,6 +543,7 @@ class preFlightsChecks: break def install_django(self): + self.stdOut("Install Django") count = 0 while (1): command = "pip install django==1.11" @@ -555,6 +563,7 @@ class preFlightsChecks: break def install_python_mysql_library(self): + self.stdOut("Install MySQL python library") count = 0 while (1): if distro == centos: @@ -574,7 +583,7 @@ class preFlightsChecks: preFlightsChecks.stdOut("MySQL-python successfully installed!") break - if distro == ubuntu + if distro == ubuntu: command = "pip install MySQL-python" res = subprocess.call(shlex.split(command)) if res != 0: @@ -584,7 +593,9 @@ class preFlightsChecks: "Unable to install MySQL-python, exiting installer! [install_python_mysql_library] Error: " + str(res)) os._exit(os.EX_OSERR) + def install_gunicorn(self): + self.stdOut("Install GUnicorn") count = 0 while (1): if distro == ubuntu: @@ -604,6 +615,7 @@ class preFlightsChecks: preFlightsChecks.stdOut("GUNICORN successfully installed!") break + def setup_gunicorn(self): try: @@ -649,6 +661,7 @@ class preFlightsChecks: preFlightsChecks.stdOut("Not able to setup gunicorn, see install log.") def install_psutil(self): + self.stdOut("Install psutil") try: import psutil @@ -712,6 +725,7 @@ class preFlightsChecks: logging.InstallLog.writeToFile("fix_selinux_issue problem") def install_psmisc(self): + self.stdOut("Install psmisc") count = 0 while (1): if distro == centos: @@ -732,6 +746,7 @@ class preFlightsChecks: break def download_install_CyberPanel(self,mysqlPassword, mysql): + self.stdOut("Download and install Cyberpanel") try: ## On OpenVZ there is an issue with requests module, which needs to upgrade requests module @@ -947,6 +962,7 @@ class preFlightsChecks: def install_unzip(self): + self.stdOut("Install unzip") try: count = 0 @@ -982,6 +998,7 @@ class preFlightsChecks: return 1 def install_zip(self): + self.stdOut("Install zip") try: count = 0 while (1): @@ -1018,6 +1035,7 @@ class preFlightsChecks: return 1 def download_install_phpmyadmin(self): + self.stdOut("Install PHP MyAdmin") try: os.chdir("/usr/local/lscp/cyberpanel/") count = 0 @@ -1132,6 +1150,7 @@ class preFlightsChecks: def install_postfix_davecot(self): + self.stdOut("Install dovecot") try: if distro == centos: command = 'yum remove postfix -y' @@ -1223,6 +1242,7 @@ class preFlightsChecks: def setup_email_Passwords(self,mysqlPassword, mysql): + self.stdOut("Setup email passwords") try: logging.InstallLog.writeToFile("Setting up authentication for Postfix and Dovecot...") @@ -1338,6 +1358,7 @@ class preFlightsChecks: def setup_postfix_davecot_config(self, mysql): + self.stdOut("Configuring postfix and dovecot") try: logging.InstallLog.writeToFile("Configuring postfix and dovecot...") @@ -2106,6 +2127,7 @@ class preFlightsChecks: def reStartLiteSpeed(self): + self.stdOut("Restarting Litespeed") try: count = 0 while(1): @@ -2330,6 +2352,7 @@ class preFlightsChecks: return 1 def setup_cron(self): + self.stdOut("Install and setup cron") try: ## first install crontab @@ -2463,6 +2486,7 @@ class preFlightsChecks: return 1 def install_default_keys(self): + self.stdOut("Installing default certificates") try: count = 0 @@ -2498,6 +2522,7 @@ class preFlightsChecks: return 1 def install_rsync(self): + self.stdOut("Installing rsync") try: count = 0 while (1): @@ -2531,6 +2556,7 @@ class preFlightsChecks: return 1 def test_Requests(self): + self.stdOut("Testing Requests...") try: import requests getVersion = requests.get('https://cyberpanel.net/version.txt') From 454d680d33747329965cfb49873c1a31344e41a5 Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 26 Oct 2018 09:52:07 -0400 Subject: [PATCH 07/58] More syntax stuff --- install-ubuntu.sh | 4 +++- install.sh | 9 +++++++++ install/install.py | 25 +++++++++++++------------ 3 files changed, 25 insertions(+), 13 deletions(-) mode change 100644 => 100755 install.sh mode change 100644 => 100755 install/install.py diff --git a/install-ubuntu.sh b/install-ubuntu.sh index e0acf3bdc..3d2c3f074 100755 --- a/install-ubuntu.sh +++ b/install-ubuntu.sh @@ -21,7 +21,9 @@ apt-get install curl -y #tar xzvf install.tar.gz apt-get install python -y apt-get install git -y -#git clone https://github.com/rperper/cyberpanel.git +if [ ! -d cyberpanel ]; then + git clone https://github.com/rperper/cyberpanel.git +fi cd cyberpanel cd install chmod +x install.py diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index b923418cb..b0cecfc07 --- a/install.sh +++ b/install.sh @@ -1,4 +1,13 @@ #!/bin/bash +if [ -a /etc/lsb-release ]; then + if [ ! -x ./install-ubuntu.sh ]; then + echo "Download install-ubuntu.sh and make it executable" + exit 1 + fi + echo "Running Ubuntu install" + ./install-ubuntu.sh + exit $? +fi yum autoremove epel-release -y rm -f /etc/yum.repos.d/epel.repo rm -f /etc/yum.repos.d/epel.repo.rpmsave diff --git a/install/install.py b/install/install.py old mode 100644 new mode 100755 index a33a84f04..be3017e62 --- a/install/install.py +++ b/install/install.py @@ -18,7 +18,6 @@ from stat import * centos=0 ubuntu=1 -distro = centos class preFlightsChecks: @@ -50,7 +49,7 @@ class preFlightsChecks: os._exit(0) def setup_account_cyberpanel(self): - self.stdOut("Setup Cyberpanel account") + self.stdOut("Setup Cyberpanel account, distro: " + str(self.distro)) try: count = 0 @@ -77,6 +76,7 @@ class preFlightsChecks: count = 0 if distro == ubuntu: + self.stdOut("Add Cyberpanel user") command = "useradd cyberpanel -g sudo" cmd = shlex.split(command) res = subprocess.call(cmd) @@ -148,7 +148,7 @@ class preFlightsChecks: ############################### count = 0 - + self.stdOut("Create /etc/letsencrypt directory") while (1): command = "mkdir /etc/letsencrypt" @@ -2526,7 +2526,7 @@ class preFlightsChecks: try: count = 0 while (1): - if distro == centos + if distro == centos: command = 'yum -y install rsync' else: command = 'apt-get -y install rsync' @@ -3086,21 +3086,18 @@ milter_default_action = accept def get_distro(): - distro = -1 + distro = centos distro_file = "" if exists("/etc/lsb-release"): distro_file = "/etc/lsb-release" with open(distro_file) as f: for line in f: - if line == "DISTRIB_ID=Ubuntu": + if line == "DISTRIB_ID=Ubuntu\n": distro = ubuntu elif exists("/etc/os-release"): distro_file = "/etc/os-release" - with open(distro_file) as f: - for line in f: - if line == "ID=\"centos\"": - distro = centos + distro = centos else: logging.InstallLog.writeToFile("Can't find linux release file - fatal error") @@ -3131,7 +3128,10 @@ def main(): ## Writing public IP - os.mkdir("/etc/cyberpanel") + try: + os.mkdir("/etc/cyberpanel") + except: + pass machineIP = open("/etc/cyberpanel/machineIP", "w") machineIP.writelines(args.publicip) @@ -3140,6 +3140,7 @@ def main(): cwd = os.getcwd() distro = get_distro() + preFlightsChecks.stdOut("Distro: " + str(distro)) checks = preFlightsChecks("/usr/local/lsws/",args.publicip,"/usr/local",cwd,"/usr/local/CyberCP", distro) if distro == ubuntu: @@ -3236,6 +3237,6 @@ def main(): logging.InstallLog.writeToFile("CyberPanel installation successfully completed!") -if __name__ == "__main"_: +if __name__ == "__main__": main() From 1943a8e4164331106b472c24efe3c2cbfb8a3804 Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 26 Oct 2018 09:56:12 -0400 Subject: [PATCH 08/58] Fixing more syntax --- install/install.py | 55 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/install/install.py b/install/install.py index be3017e62..4f8185b7d 100755 --- a/install/install.py +++ b/install/install.py @@ -14,7 +14,7 @@ from stat import * # There can not be peace without first a great suffering. -#distros +#self.distros centos=0 ubuntu=1 @@ -24,7 +24,7 @@ class preFlightsChecks: cyberPanelMirror = "mirror.cyberpanel.net/pip" - def __init__(self,rootPath,ip,path,cwd,cyberPanelPath,distro): + def __init__(self,rootPath,ip,path,cwd,cyberPanelPath,self.distro): self.ipAddr = ip self.path = path self.cwd = cwd @@ -49,11 +49,11 @@ class preFlightsChecks: os._exit(0) def setup_account_cyberpanel(self): - self.stdOut("Setup Cyberpanel account, distro: " + str(self.distro)) + self.stdOut("Setup Cyberpanel account") try: count = 0 - if distro == centos: + if self.distro == centos: while (1): command = "yum install sudo -y" cmd = shlex.split(command) @@ -75,7 +75,7 @@ class preFlightsChecks: count = 0 - if distro == ubuntu: + if self.distro == ubuntu: self.stdOut("Add Cyberpanel user") command = "useradd cyberpanel -g sudo" cmd = shlex.split(command) @@ -209,7 +209,7 @@ class preFlightsChecks: cmd = [] count = 0 - if distro == ubuntu: + if self.distro == ubuntu: try: filename = "enable_lst_debain_repo.sh" command = "wget http://rpms.litespeedtech.com/debian/" + filename @@ -308,7 +308,7 @@ class preFlightsChecks: self.stdOut("Install pip") count = 0 while (1): - if distro == ubuntu: + if self.distro == ubuntu: command = "apt-get -y install python-pip" else: command = "yum -y install python-pip" @@ -331,7 +331,7 @@ class preFlightsChecks: self.stdOut("Install python development environment") count = 0 while (1): - if distro == centos: + if self.distro == centos: command = "yum -y install python-devel" else: command = "apt-get -y install python-dev" @@ -355,7 +355,7 @@ class preFlightsChecks: count = 0 while (1): - if distro == centos: + if self.distro == centos: command = "yum -y install gcc" else: command = "apt-get -y install gcc" @@ -566,7 +566,7 @@ class preFlightsChecks: self.stdOut("Install MySQL python library") count = 0 while (1): - if distro == centos: + if self.distro == centos: command = "yum -y install MySQL-python" else: command = "apt-get -y install libmysqlclient-dev" @@ -583,7 +583,7 @@ class preFlightsChecks: preFlightsChecks.stdOut("MySQL-python successfully installed!") break - if distro == ubuntu: + if self.distro == ubuntu: command = "pip install MySQL-python" res = subprocess.call(shlex.split(command)) if res != 0: @@ -598,7 +598,7 @@ class preFlightsChecks: self.stdOut("Install GUnicorn") count = 0 while (1): - if distro == ubuntu: + if self.distro == ubuntu: command = "pip install gunicorn" else: command = "easy_install gunicorn" @@ -728,7 +728,7 @@ class preFlightsChecks: self.stdOut("Install psmisc") count = 0 while (1): - if distro == centos: + if self.distro == centos: command = "yum -y install psmisc" else: command = "apt-get -y install psmisc" @@ -968,7 +968,7 @@ class preFlightsChecks: count = 0 while (1): - if distro == centos: + if self.distro == centos: command = 'yum -y install unzip' else: command = 'apt-get -y install unzip' @@ -1003,7 +1003,7 @@ class preFlightsChecks: count = 0 while (1): - if distro == centos: + if self.distro == centos: command = 'yum -y install zip' else: command = 'apt-get -y install zip' @@ -1152,7 +1152,7 @@ class preFlightsChecks: def install_postfix_davecot(self): self.stdOut("Install dovecot") try: - if distro == centos: + if self.distro == centos: command = 'yum remove postfix -y' else: command = 'apt-get -y remove postfix' @@ -1161,7 +1161,7 @@ class preFlightsChecks: count = 0 while(1): - if distro == centos: + if self.distro == centos: command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-3.2.4-1.gf.el7.x86_64.rpm' else: command = 'apt-get -y install dovecot-imapd dovecot-pop3d' @@ -1184,7 +1184,7 @@ class preFlightsChecks: count = 0 while (1): - if distro == centos: + if self.distro == centos: command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-mysql-3.2.4-1.gf.el7.x86_64.rpm' else: command = 'apt-get -y install mysql-server' @@ -1209,7 +1209,7 @@ class preFlightsChecks: while(1): - if distro == centos: + if self.distro == centos: command = 'yum -y install dovecot dovecot-mysql' else: command = 'apt-get -y install dovecot-mysql' @@ -2159,7 +2159,7 @@ class preFlightsChecks: def installFirewalld(self): - if distro == ubuntu: + if self.distro == ubuntu: return 0 # Uses AppArmor try: @@ -2360,7 +2360,7 @@ class preFlightsChecks: count = 0 while(1): - if distro == centos: + if self.distro == centos: command = 'yum install cronie -y' else: command = 'apt-get -y install cron' @@ -2384,7 +2384,7 @@ class preFlightsChecks: count = 0 while(1): - if distro == centos: + if self.distro == centos: command = 'systemctl enable crond' else: command = 'systemctl enable cron' @@ -2405,7 +2405,7 @@ class preFlightsChecks: count = 0 while(1): - if distro == centos: + if self.distro == centos: command = 'systemctl start crond' else: command = 'systemctl start cron' @@ -2454,7 +2454,7 @@ class preFlightsChecks: count = 0 while(1): - if distro == centos: + if self.distro == centos: command = 'systemctl restart crond.service' else: command = 'systemctl restart cron.service' @@ -2526,7 +2526,7 @@ class preFlightsChecks: try: count = 0 while (1): - if distro == centos: + if self.distro == centos: command = 'yum -y install rsync' else: command = 'apt-get -y install rsync' @@ -2743,7 +2743,7 @@ class preFlightsChecks: try: count = 0 while (1): - if distro == centos: + if self.distro == centos: command = 'yum -y install opendkim' else: command = 'apt-get -y install opendkim' @@ -3086,7 +3086,7 @@ milter_default_action = accept def get_distro(): - distro = centos + distro = -1 distro_file = "" if exists("/etc/lsb-release"): distro_file = "/etc/lsb-release" @@ -3140,7 +3140,6 @@ def main(): cwd = os.getcwd() distro = get_distro() - preFlightsChecks.stdOut("Distro: " + str(distro)) checks = preFlightsChecks("/usr/local/lsws/",args.publicip,"/usr/local",cwd,"/usr/local/CyberCP", distro) if distro == ubuntu: From 5f7776ac394b16ac4e2a6a1a02180bf461209cdc Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 26 Oct 2018 10:50:58 -0400 Subject: [PATCH 09/58] Fixed postfix to work right --- install/install.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/install/install.py b/install/install.py index 4f8185b7d..eaac8c6c6 100755 --- a/install/install.py +++ b/install/install.py @@ -9,6 +9,7 @@ from firewallUtilities import FirewallUtilities import time import string import random +import socket from os.path import * from stat import * @@ -1164,7 +1165,9 @@ class preFlightsChecks: if self.distro == centos: command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-3.2.4-1.gf.el7.x86_64.rpm' else: - command = 'apt-get -y install dovecot-imapd dovecot-pop3d' + command = 'debconf-set-selections <<< ' '"postfix postfix/mailname string ' + str(socket.getfqdn()) + ";' \ + ' debconf-set-selections <<< "postfix postfix/main_mailer_type string \'Internet Site\'";' \ + ' apt-get install -y postfix' cmd = shlex.split(command) @@ -1187,7 +1190,7 @@ class preFlightsChecks: if self.distro == centos: command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-mysql-3.2.4-1.gf.el7.x86_64.rpm' else: - command = 'apt-get -y install mysql-server' + command = 'apt-get -y install dovecot-imapd dovecot-pop3d postfix-mysql' cmd = shlex.split(command) @@ -1195,10 +1198,10 @@ class preFlightsChecks: if res == 1: count = count + 1 - preFlightsChecks.stdOut("Unable to install Postfix, trying again, try number: " + str(count)) + preFlightsChecks.stdOut("Unable to install Postfix agent, trying again, try number: " + str(count)) if count == 3: logging.InstallLog.writeToFile( - "Unable to install Postfix, you will not be able to send mails and rest should work fine! [install_postfix_davecot]") + "Unable to install Postfix agent, you will not be able to send mails and rest should work fine! [install_postfix_davecot]") break else: logging.InstallLog.writeToFile("Postfix successfully installed!") From 1cbc0e4abe0e450dd403fd8dc56c92c8400c9b5f Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 26 Oct 2018 10:56:39 -0400 Subject: [PATCH 10/58] Postfix still not right --- install/install.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/install.py b/install/install.py index eaac8c6c6..72c6275b0 100755 --- a/install/install.py +++ b/install/install.py @@ -25,7 +25,7 @@ class preFlightsChecks: cyberPanelMirror = "mirror.cyberpanel.net/pip" - def __init__(self,rootPath,ip,path,cwd,cyberPanelPath,self.distro): + def __init__(self,rootPath,ip,path,cwd,cyberPanelPath,distro): self.ipAddr = ip self.path = path self.cwd = cwd @@ -1165,7 +1165,7 @@ class preFlightsChecks: if self.distro == centos: command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-3.2.4-1.gf.el7.x86_64.rpm' else: - command = 'debconf-set-selections <<< ' '"postfix postfix/mailname string ' + str(socket.getfqdn()) + ";' \ + command = 'debconf-set-selections <<< "postfix postfix/mailname string ' + str(socket.getfqdn()) + '";' \ ' debconf-set-selections <<< "postfix postfix/main_mailer_type string \'Internet Site\'";' \ ' apt-get install -y postfix' From ca003f792aeddc2be623b23f6e6822c73b09b594 Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 26 Oct 2018 11:34:56 -0400 Subject: [PATCH 11/58] Updated messaging to include logging and exiting, also fixed creation issues. --- install/install.py | 66 +++++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/install/install.py b/install/install.py index 72c6275b0..17b919af2 100755 --- a/install/install.py +++ b/install/install.py @@ -10,6 +10,7 @@ import time import string import random import socket +import errno from os.path import * from stat import * @@ -34,13 +35,17 @@ class preFlightsChecks: self.distro = distro @staticmethod - def stdOut(message): + def stdOut(message, log = 0, exit = 0, code = os.EX_OK): print("\n\n") print ("[" + time.strftime( "%I-%M-%S-%a-%b-%Y") + "] #########################################################################\n") print("[" + time.strftime("%I-%M-%S-%a-%b-%Y") + "] " + message + "\n") print ("[" + time.strftime( "%I-%M-%S-%a-%b-%Y") + "] #########################################################################\n") + if log: + logging.InstallLog.writeToFile(message) + if exit: + sys.exit(code) def checkPythonVersion(self): if sys.version_info[0] == 2 and sys.version_info[1] == 7: @@ -150,23 +155,14 @@ class preFlightsChecks: count = 0 self.stdOut("Create /etc/letsencrypt directory") - while (1): - - command = "mkdir /etc/letsencrypt" - - cmd = shlex.split(command) - - res = subprocess.call(cmd) - - if res == 1: - count = count + 1 - preFlightsChecks.stdOut("We are trying to create Let's Encrypt directory to store SSLs, trying again, try number: " + str(count)) - if count == 3: - logging.InstallLog.writeToFile("Failed to create Let's Encrypt directory to store SSLs. Installer can continue without this.. [setup_account_cyberpanel]") - else: - logging.InstallLog.writeToFile("Successfully created Let's Encrypt directory!") - preFlightsChecks.stdOut("Successfully created Let's Encrypt directory!") - break + try: + os.mkdir("/etc/letsencrypt") + except OSError as e: + if e.errno != errno.EEXIST: + self.stdOut("Error creating /etc/letsencrypt directory: " + str(e) + + " Installer can continue without this [setup_account_cyberpanel] ",1) + else + pass ## @@ -869,7 +865,10 @@ class preFlightsChecks: ### Applying migrations - os.chdir("CyberCP") + try: + os.chdir("CyberCP") + except: + self.stdOut("Error changing to CyberCP directory - internal error!", 1, 1, os.USAGE) count = 0 @@ -1038,7 +1037,13 @@ class preFlightsChecks: def download_install_phpmyadmin(self): self.stdOut("Install PHP MyAdmin") try: - os.chdir("/usr/local/lscp/cyberpanel/") + dir = "/usr/local/lscp/cyberpanel/" + try: + os.chdir(dir) + except OSError as e: + msg = "Error changing to " + "/usr/local/lscp/cyberpanel/ :" + str(e) + " [download_install_phpmyadmin]" + self.stdOut(msg, 1, 1, os.EX_USAGE) + count = 0 while(1): @@ -1132,7 +1137,13 @@ class preFlightsChecks: writeToFile.close() - os.mkdir('/usr/local/lscp/cyberpanel/phpmyadmin/tmp') + try: + os.mkdir('/usr/local/lscp/cyberpanel/phpmyadmin/tmp') + except OSError as e: + if e.errno != errno.EEXIST: + self.stdOut("Error ceating: '/usr/local/lscp/cyberpanel/phpmyadmin/tmp' " + str(e), 1, 1, os.EX_CANTCREAT) + else + pass command = 'chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/phpmyadmin' subprocess.call(shlex.split(command)) @@ -2004,7 +2015,11 @@ class preFlightsChecks: ####### - os.chdir("/usr/local/lscp/cyberpanel") + try: + os.chdir("/usr/local/lscp/cyberpanel") + except OSError as e: + self.stdOut("Can't change to cyberpanel directory, fatal error at this point") + count = 1 @@ -3133,8 +3148,11 @@ def main(): try: os.mkdir("/etc/cyberpanel") - except: - pass + except OSError as e: + if e.errno != errno.EEXIST: + self.stdOut("Error creating /etc/cyberpanel directory: " + str(e), 1, 1, os.EX_CANTCREAT) + else + pass machineIP = open("/etc/cyberpanel/machineIP", "w") machineIP.writelines(args.publicip) From ce74c22b91f21ca30a47e480bb6574e5e04b6d19 Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 26 Oct 2018 11:36:39 -0400 Subject: [PATCH 12/58] Syntax again. --- install/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index 17b919af2..51b0c646d 100755 --- a/install/install.py +++ b/install/install.py @@ -161,7 +161,7 @@ class preFlightsChecks: if e.errno != errno.EEXIST: self.stdOut("Error creating /etc/letsencrypt directory: " + str(e) + " Installer can continue without this [setup_account_cyberpanel] ",1) - else + else: pass ## From 0b62563aef4e97f3fbb4e0d0eecf221a8393c940 Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 26 Oct 2018 11:40:34 -0400 Subject: [PATCH 13/58] Again syntax! --- install/install.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/install.py b/install/install.py index 51b0c646d..ca65ae124 100755 --- a/install/install.py +++ b/install/install.py @@ -868,7 +868,7 @@ class preFlightsChecks: try: os.chdir("CyberCP") except: - self.stdOut("Error changing to CyberCP directory - internal error!", 1, 1, os.USAGE) + self.stdOut("Error changing to CyberCP directory - internal error!", 1, 1, os.EX_USAGE) count = 0 @@ -1142,7 +1142,7 @@ class preFlightsChecks: except OSError as e: if e.errno != errno.EEXIST: self.stdOut("Error ceating: '/usr/local/lscp/cyberpanel/phpmyadmin/tmp' " + str(e), 1, 1, os.EX_CANTCREAT) - else + else: pass command = 'chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/phpmyadmin' @@ -3151,7 +3151,7 @@ def main(): except OSError as e: if e.errno != errno.EEXIST: self.stdOut("Error creating /etc/cyberpanel directory: " + str(e), 1, 1, os.EX_CANTCREAT) - else + else: pass machineIP = open("/etc/cyberpanel/machineIP", "w") From c2b09182c22990cef3c43baa169f63e46e7f26d6 Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 26 Oct 2018 14:24:28 -0400 Subject: [PATCH 14/58] More... --- install-ubuntu.sh | 31 ----- install.sh | 44 ++++++- install/install.py | 6 +- install/installCyberPanel.py | 217 +++++++++++++++++++++-------------- install/unInstall.py | 1 + 5 files changed, 171 insertions(+), 128 deletions(-) delete mode 100755 install-ubuntu.sh diff --git a/install-ubuntu.sh b/install-ubuntu.sh deleted file mode 100755 index 3d2c3f074..000000000 --- a/install-ubuntu.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -#yum autoremove epel-release -y -#rm -f /etc/yum.repos.d/epel.repo -#rm -f /etc/yum.repos.d/epel.repo.rpmsave -#yum install epel-release -y -#some provider's centos7 template come with incorrect or misconfigured epel.repo -#if systemctl is-active named | grep -q 'active'; then -# systemctl stop named -# systemctl disable named -# echo "Disabling named to aviod powerdns conflicts..." -# else -# echo "named is not installed or active, to next step..." -#fi -# above if will check if server has named.service running that occupies port 53 which makes powerdns failed to start -apt-get clean all -apt-get update -y -apt-get install curl -y -#setenforce 0 -#sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config -#wget https://cyberpanel.net/install.tar.gz -#tar xzvf install.tar.gz -apt-get install python -y -apt-get install git -y -if [ ! -d cyberpanel ]; then - git clone https://github.com/rperper/cyberpanel.git -fi -cd cyberpanel -cd install -chmod +x install.py -server_ip="$(wget -qO- http://whatismyip.akamai.com/)" -python install.py $server_ip diff --git a/install.sh b/install.sh index b0cecfc07..fb7b12788 100755 --- a/install.sh +++ b/install.sh @@ -1,11 +1,43 @@ #!/bin/bash -if [ -a /etc/lsb-release ]; then - if [ ! -x ./install-ubuntu.sh ]; then - echo "Download install-ubuntu.sh and make it executable" - exit 1 +install-ubuntu() +{ + #!/bin/bash + #yum autoremove epel-release -y + #rm -f /etc/yum.repos.d/epel.repo + #rm -f /etc/yum.repos.d/epel.repo.rpmsave + #yum install epel-release -y + #some provider's centos7 template come with incorrect or misconfigured epel.repo + #if systemctl is-active named | grep -q 'active'; then + # systemctl stop named + # systemctl disable named + # echo "Disabling named to aviod powerdns conflicts..." + # else + # echo "named is not installed or active, to next step..." + #fi + # above if will check if server has named.service running that occupies port 53 which makes powerdns failed to start + apt-get clean all + apt-get update -y + apt-get install curl -y + #setenforce 0 + #sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config + #wget https://cyberpanel.net/install.tar.gz + #tar xzvf install.tar.gz + apt-get install python -y + apt-get install git -y + if [ ! -d cyberpanel ]; then + git clone https://github.com/rperper/cyberpanel.git fi - echo "Running Ubuntu install" - ./install-ubuntu.sh + cd cyberpanel + cd install + chmod +x install.py + server_ip="$(wget -qO- http://whatismyip.akamai.com/)" + python install.py $server_ip + exit $? +} + + +if [ -a /etc/lsb-release ]; then + install-ubuntu exit $? fi yum autoremove epel-release -y diff --git a/install/install.py b/install/install.py index ca65ae124..2724ebb0e 100755 --- a/install/install.py +++ b/install/install.py @@ -16,14 +16,13 @@ from stat import * # There can not be peace without first a great suffering. -#self.distros +#distros centos=0 ubuntu=1 class preFlightsChecks: - cyberPanelMirror = "mirror.cyberpanel.net/pip" def __init__(self,rootPath,ip,path,cwd,cyberPanelPath,distro): @@ -3102,7 +3101,6 @@ milter_default_action = accept return 0 - def get_distro(): distro = -1 distro_file = "" @@ -3195,7 +3193,7 @@ def main(): import installCyberPanel - installCyberPanel.Main(cwd, mysql) + installCyberPanel.Main(cwd, mysql, distro) checks.fix_selinux_issue() checks.install_psmisc() checks.install_postfix_davecot() diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 82011d03a..546e1bd39 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -3,21 +3,27 @@ import subprocess import os import pexpect from mysqlUtilities import mysqlUtilities +from install import preflightsChecks import installLog as logging import shlex import randomPassword import time import sys +#distros +centos=0 +ubuntu=1 + class InstallCyberPanel: mysql_Root_password = "" mysqlPassword = "" - def __init__(self,rootPath,cwd): + def __init__(self,rootPath,cwd,distro): self.server_root_path = rootPath self.cwd = cwd + self.distro=distro @staticmethod def stdOut(message): @@ -34,7 +40,10 @@ class InstallCyberPanel: count = 0 while (1): - command = 'yum install -y openlitespeed' + if self.distro == ubuntu: + command = "apt-get -y openlitespeed" + else: + command = 'yum install -y openlitespeed' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -224,7 +233,10 @@ class InstallCyberPanel: while (1): - command = 'yum -y groupinstall lsphp-all' + if self.distro == ubuntu: + command = 'apt-get -y install lsphp*' + else: + command = 'yum -y groupinstall lsphp-all' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -240,42 +252,43 @@ class InstallCyberPanel: InstallCyberPanel.stdOut("LiteSpeed PHPs successfully installed!") ## only php 71 - count = 0 - while(1): - command = 'yum install lsphp71 lsphp71-json lsphp71-xmlrpc lsphp71-xml lsphp71-tidy lsphp71-soap lsphp71-snmp lsphp71-recode lsphp71-pspell lsphp71-process lsphp71-pgsql lsphp71-pear lsphp71-pdo lsphp71-opcache lsphp71-odbc lsphp71-mysqlnd lsphp71-mcrypt lsphp71-mbstring lsphp71-ldap lsphp71-intl lsphp71-imap lsphp71-gmp lsphp71-gd lsphp71-enchant lsphp71-dba lsphp71-common lsphp71-bcmath -y' - cmd = shlex.split(command) - res = subprocess.call(cmd) - if res == 1: - count = count + 1 - InstallCyberPanel.stdOut("Trying to install LiteSpeed PHP 7.1, trying again, try number: " + str(count)) - if count == 3: - logging.InstallLog.writeToFile("Failed to install LiteSpeed PHP 7.1, exiting installer! [installAllPHPVersions]") - InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("LiteSpeed PHP 7.1 successfully installed!") - InstallCyberPanel.stdOut("LiteSpeed PHP 7.1 successfully installed!") - break + if self.distro == centos: + count = 0 + while(1): + command = 'yum install lsphp71 lsphp71-json lsphp71-xmlrpc lsphp71-xml lsphp71-tidy lsphp71-soap lsphp71-snmp lsphp71-recode lsphp71-pspell lsphp71-process lsphp71-pgsql lsphp71-pear lsphp71-pdo lsphp71-opcache lsphp71-odbc lsphp71-mysqlnd lsphp71-mcrypt lsphp71-mbstring lsphp71-ldap lsphp71-intl lsphp71-imap lsphp71-gmp lsphp71-gd lsphp71-enchant lsphp71-dba lsphp71-common lsphp71-bcmath -y' + cmd = shlex.split(command) + res = subprocess.call(cmd) + if res == 1: + count = count + 1 + InstallCyberPanel.stdOut("Trying to install LiteSpeed PHP 7.1, trying again, try number: " + str(count)) + if count == 3: + logging.InstallLog.writeToFile("Failed to install LiteSpeed PHP 7.1, exiting installer! [installAllPHPVersions]") + InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) + else: + logging.InstallLog.writeToFile("LiteSpeed PHP 7.1 successfully installed!") + InstallCyberPanel.stdOut("LiteSpeed PHP 7.1 successfully installed!") + break - ## only php 72 - count = 0 - while (1): - command = 'yum install -y lsphp72 lsphp72-json lsphp72-xmlrpc lsphp72-xml lsphp72-tidy lsphp72-soap lsphp72-snmp lsphp72-recode lsphp72-pspell lsphp72-process lsphp72-pgsql lsphp72-pear lsphp72-pdo lsphp72-opcache lsphp72-odbc lsphp72-mysqlnd lsphp72-mcrypt lsphp72-mbstring lsphp72-ldap lsphp72-intl lsphp72-imap lsphp72-gmp lsphp72-gd lsphp72-enchant lsphp72-dba lsphp72-common lsphp72-bcmath' - cmd = shlex.split(command) - res = subprocess.call(cmd) - if res == 1: - count = count + 1 - InstallCyberPanel.stdOut( - "Trying to install LiteSpeed PHP 7.1, trying again, try number: " + str(count)) - if count == 3: - logging.InstallLog.writeToFile( - "Failed to install LiteSpeed PHP 7.1, exiting installer! [installAllPHPVersions]") - InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("LiteSpeed PHP 7.1 successfully installed!") - InstallCyberPanel.stdOut("LiteSpeed PHP 7.1 successfully installed!") - break + ## only php 72 + count = 0 + while (1): + command = 'yum install -y lsphp72 lsphp72-json lsphp72-xmlrpc lsphp72-xml lsphp72-tidy lsphp72-soap lsphp72-snmp lsphp72-recode lsphp72-pspell lsphp72-process lsphp72-pgsql lsphp72-pear lsphp72-pdo lsphp72-opcache lsphp72-odbc lsphp72-mysqlnd lsphp72-mcrypt lsphp72-mbstring lsphp72-ldap lsphp72-intl lsphp72-imap lsphp72-gmp lsphp72-gd lsphp72-enchant lsphp72-dba lsphp72-common lsphp72-bcmath' + cmd = shlex.split(command) + res = subprocess.call(cmd) + if res == 1: + count = count + 1 + InstallCyberPanel.stdOut( + "Trying to install LiteSpeed PHP 7.1, trying again, try number: " + str(count)) + if count == 3: + logging.InstallLog.writeToFile( + "Failed to install LiteSpeed PHP 7.1, exiting installer! [installAllPHPVersions]") + InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) + else: + logging.InstallLog.writeToFile("LiteSpeed PHP 7.1 successfully installed!") + InstallCyberPanel.stdOut("LiteSpeed PHP 7.1 successfully installed!") + break ## break for outer loop @@ -292,8 +305,14 @@ class InstallCyberPanel: def setup_mariadb_repo(self): - try: + if self.distro == ubuntu: + # Only needed if the repo is broken or we need the latest version. + #command = "apt-get -y install software-properties-common" + #command = "apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8" + #command = "add-apt-repository 'deb [arch=amd64] http://mirror.zol.co.zw/mariadb/repo/10.3/ubuntu bionic main'" + return + try: logging.InstallLog.writeToFile("Setting up MariaDB Repo..") InstallCyberPanel.stdOut("Setting up MariaDB Repo..") @@ -318,8 +337,10 @@ class InstallCyberPanel: count = 0 while (1): - - command = 'yum -y install mariadb-server' + if self.distro == ubuntu: + command = "apt-get -y install mariadb-server" + else: + command = 'yum -y install mariadb-server' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -453,7 +474,8 @@ class InstallCyberPanel: count = count + 1 InstallCyberPanel.stdOut("Trying to enable MariaDB instance to start and system restart, trying again, try number: " + str(count)) if count == 3: - logging.InstallLog.writeToFile("Failed to enable MariaDB instance to run at system restart, you can do this later using systemctl enable mysql! [installMySQL]") + logging.InstallLog.writeToFile("Failed to enable MariaDB instance to run at system restart, " + "you can do this later using systemctl enable mysql! [installMySQL]") break else: logging.InstallLog.writeToFile("MariaDB instance successfully enabled at system restart!") @@ -599,7 +621,10 @@ class InstallCyberPanel: count = 0 while (1): - command = "yum install -y pure-ftpd" + if self.distro == ubuntu: + command = 'apt-get -y install pure-ftpd' + else: + command = "yum install -y pure-ftpd" res = subprocess.call(shlex.split(command)) if res == 1: @@ -729,7 +754,8 @@ class InstallCyberPanel: count = count + 1 InstallCyberPanel.stdOut("Trying to start PureFTPD instance, trying again, try number: " + str(count)) if count == 3: - logging.InstallLog.writeToFile("Failed to start PureFTPD instance, you can do this manually later using systemctl start pure-ftpd [startPureFTPD]") + logging.InstallLog.writeToFile("Failed to start PureFTPD instance, you can do this manually " + "later using systemctl start pure-ftpd [startPureFTPD]") break else: logging.InstallLog.writeToFile("PureFTPD instance successfully started!") @@ -762,7 +788,9 @@ class InstallCyberPanel: count = 0 while(1): - command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem' + command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj ' \ + '"/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" ' \ + '-keyout /etc/ssl/private/pure-ftpd.pem -out /etc/ssl/private/pure-ftpd.pem' res = subprocess.call(shlex.split(command)) if res == 1: @@ -822,49 +850,54 @@ class InstallCyberPanel: count = 0 - while (1): - command = 'yum -y install epel-release yum-plugin-priorities' - cmd = shlex.split(command) - res = subprocess.call(cmd) + if self.distro == centos: + while (1): + command = 'yum -y install epel-release yum-plugin-priorities' + cmd = shlex.split(command) + res = subprocess.call(cmd) - if res == 1: - count = count + 1 - InstallCyberPanel.stdOut("Trying to install PowerDNS Repositories, trying again, try number: " + str(count)) - if count == 3: - logging.InstallLog.writeToFile("Failed to install PowerDNS Repositories, exiting installer! [installPowerDNS]") - InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("PowerDNS Repositories successfully installed!") - InstallCyberPanel.stdOut("PowerDNS Repositories successfully installed!") - break + if res == 1: + count = count + 1 + InstallCyberPanel.stdOut("Trying to install PowerDNS Repositories, trying again, try number: " + str(count)) + if count == 3: + logging.InstallLog.writeToFile("Failed to install PowerDNS Repositories, exiting installer! [installPowerDNS]") + InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) + else: + logging.InstallLog.writeToFile("PowerDNS Repositories successfully installed!") + InstallCyberPanel.stdOut("PowerDNS Repositories successfully installed!") + break - count = 0 + count = 0 - while(1): + while(1): - command = 'curl -o /etc/yum.repos.d/powerdns-auth-master.repo https://repo.powerdns.com/repo-files/centos-auth-master.repo' - cmd = shlex.split(command) - res = subprocess.call(cmd) + command = 'curl -o /etc/yum.repos.d/powerdns-auth-master.repo ' \ + 'https://repo.powerdns.com/repo-files/centos-auth-master.repo' + cmd = shlex.split(command) + res = subprocess.call(cmd) - if res == 1: - count = count + 1 - InstallCyberPanel.stdOut( - "Trying to install PowerDNS Repositories, trying again, try number: " + str(count)) - if count == 3: - logging.InstallLog.writeToFile( - "Failed to install PowerDNS Repositories, exiting installer! [installPowerDNS]") - InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("PowerDNS Repositories successfully installed!") - InstallCyberPanel.stdOut("PowerDNS Repositories successfully installed!") - break + if res == 1: + count = count + 1 + InstallCyberPanel.stdOut( + "Trying to install PowerDNS Repositories, trying again, try number: " + str(count)) + if count == 3: + logging.InstallLog.writeToFile( + "Failed to install PowerDNS Repositories, exiting installer! [installPowerDNS]") + InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) + else: + logging.InstallLog.writeToFile("PowerDNS Repositories successfully installed!") + InstallCyberPanel.stdOut("PowerDNS Repositories successfully installed!") + break count = 1 while(1): - command = 'yum -y install pdns pdns-backend-mysql' + if self.distro == ubuntu: + command = "apt-get -y install pdns-backend-mysql" + else: + command = 'yum -y install pdns pdns-backend-mysql' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -956,7 +989,9 @@ class InstallCyberPanel: count = count + 1 InstallCyberPanel.stdOut("Trying to enable PowerDNS to start and system restart, trying again, try number: " + str(count)) if count == 3: - logging.InstallLog.writeToFile("Failed to enable PowerDNS to run at system restart, you can manually do this later using systemctl enable pdns! [startPowerDNS]") + logging.InstallLog.writeToFile("Failed to enable PowerDNS to run at system restart, you can " + "manually do this later using systemctl enable pdns! " + "[startPowerDNS]") InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") break else: @@ -1004,7 +1039,10 @@ class InstallCyberPanel: count = 0 while(1): - command = 'yum -y install gcc gcc-c++ make autoconf glibc rcs' + if self.distro == ubuntu: + command = "apt-get -y install gcc g++ make autoconf rcs" + else: + command = 'yum -y install gcc gcc-c++ make autoconf glibc rcs' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -1023,7 +1061,12 @@ class InstallCyberPanel: count = 0 while(1): - command = 'yum -y install pcre-devel openssl-devel expat-devel geoip-devel zlib-devel udns-devel which curl' + if self.distro == ubuntu: + command = "apt-get -y install libpcre3 libpcre3-dev openssl libexpat1 libexpat1-dev libgeoip-dev" \ + " zlib1g zlib1g-dev libudns-dev whichman curl" + else: + command = 'yum -y install pcre-devel openssl-devel expat-devel geoip-devel zlib-devel udns-devel' \ + ' which curl' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -1062,7 +1105,9 @@ class InstallCyberPanel: count = 0 while(1): - command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /usr/local/lscp/key.pem -out /usr/local/lscp/cert.pem' + command = 'openssl req -newkey rsa:1024 -new -nodes -x509 -days 3650 -subj ' \ + '"/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /usr/local/lscp/key.pem ' \ + '-out /usr/local/lscp/cert.pem' cmd = shlex.split(command) res = subprocess.call(cmd) @@ -1115,7 +1160,7 @@ class InstallCyberPanel: -def Main(cwd, mysql): +def Main(cwd, mysql, distro): InstallCyberPanel.mysqlPassword = randomPassword.generate_pass() InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass() @@ -1125,7 +1170,7 @@ def Main(cwd, mysql): password.writelines(InstallCyberPanel.mysql_Root_password) password.close() - installer = InstallCyberPanel("/usr/local/lsws/",cwd) + installer = InstallCyberPanel("/usr/local/lsws/",cwd,distro) installer.installLiteSpeed() installer.changePortTo80() @@ -1133,7 +1178,6 @@ def Main(cwd, mysql): installer.installAllPHPVersions() installer.fix_ols_configs() - installer.setup_mariadb_repo() installer.installMySQL(mysql) installer.changeMYSQLRootPassword() @@ -1142,7 +1186,6 @@ def Main(cwd, mysql): mysqlUtilities.createDatabaseCyberPanel("cyberpanel","cyberpanel",InstallCyberPanel.mysqlPassword, mysql) - installer.installPureFTPD() installer.installPureFTPDConfigurations(mysql) installer.startPureFTPD() diff --git a/install/unInstall.py b/install/unInstall.py index 5d14440c1..4be97de7c 100644 --- a/install/unInstall.py +++ b/install/unInstall.py @@ -6,6 +6,7 @@ import argparse import os import shlex import socket +from install import preFlightsChecks From cb379b928152bfbd3c3975b4b481c994af5bf42b Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 26 Oct 2018 16:25:13 -0400 Subject: [PATCH 15/58] Actually some real stuff --- install/install.py | 6 +-- install/installCyberPanel.py | 18 +++++---- install/unInstall.py | 72 +++++++++++++++++++++++------------- 3 files changed, 61 insertions(+), 35 deletions(-) diff --git a/install/install.py b/install/install.py index 2724ebb0e..34d1301bd 100755 --- a/install/install.py +++ b/install/install.py @@ -25,7 +25,7 @@ ubuntu=1 class preFlightsChecks: 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.path = path self.cwd = cwd @@ -3148,7 +3148,7 @@ def main(): os.mkdir("/etc/cyberpanel") except OSError as e: 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: pass @@ -3159,7 +3159,7 @@ def main(): cwd = os.getcwd() 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: os.chdir("/etc/cyberpanel") diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 546e1bd39..479a790e0 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -3,7 +3,7 @@ import subprocess import os import pexpect from mysqlUtilities import mysqlUtilities -from install import preflightsChecks +import install import installLog as logging import shlex import randomPassword @@ -467,12 +467,16 @@ class InstallCyberPanel: 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)) if res == 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: logging.InstallLog.writeToFile("Failed to enable MariaDB instance to run at system restart, " "you can do this later using systemctl enable mysql! [installMySQL]") @@ -895,7 +899,7 @@ class InstallCyberPanel: while(1): if self.distro == ubuntu: - command = "apt-get -y install pdns-backend-mysql" + command = "apt-get -y install pdns-server pdns-backend-mysql" else: command = 'yum -y install pdns pdns-backend-mysql' cmd = shlex.split(command) @@ -1166,11 +1170,11 @@ def Main(cwd, mysql, distro): 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.close() - installer = InstallCyberPanel("/usr/local/lsws/",cwd,distro) + installer = InstallCyberPanel("/usr/local/lsws/", cwd, distro) installer.installLiteSpeed() installer.changePortTo80() @@ -1184,7 +1188,7 @@ def Main(cwd, mysql, distro): installer.changeMYSQLRootPasswordCyberPanel(mysql) installer.startMariaDB() - mysqlUtilities.createDatabaseCyberPanel("cyberpanel","cyberpanel",InstallCyberPanel.mysqlPassword, mysql) + mysqlUtilities.createDatabaseCyberPanel("cyberpanel", "cyberpanel", InstallCyberPanel.mysqlPassword, mysql) installer.installPureFTPD() installer.installPureFTPDConfigurations(mysql) diff --git a/install/unInstall.py b/install/unInstall.py index 4be97de7c..a4d332b11 100644 --- a/install/unInstall.py +++ b/install/unInstall.py @@ -6,20 +6,25 @@ import argparse import os import shlex import socket -from install import preFlightsChecks +import install +#distros +centos=0 +ubuntu=1 +distro = install.get_distro() class unInstallCyberPanel: def unInstallCyberPanelRepo(self): - try: - copyPath = "/etc/yum.repos.d/cyberpanel.repo" - os.remove(copyPath) + if distro == centos: + try: + copyPath = "/etc/yum.repos.d/cyberpanel.repo" + os.remove(copyPath) - except OSError,msg: - logging.InstallLog.writeToFile(str(msg)+ " [unInstallCyberPanelRepo]") + except OSError,msg: + logging.InstallLog.writeToFile(str(msg)+ " [unInstallCyberPanelRepo]") def removeGunicorn(self): try: @@ -41,7 +46,10 @@ class unInstallCyberPanel: def removePostfixDovecot(self): 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) @@ -63,7 +71,10 @@ class unInstallCyberPanel: def removeMysql(self): 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) @@ -85,13 +96,16 @@ class unInstallCyberPanel: def removeLiteSpeed(self): 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: logging.InstallLog.writeToFile(str(msg) + " [removeLiteSpeed]") @@ -119,13 +133,16 @@ class unInstallCyberPanel: def removePureFTPD(self): 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: logging.InstallLog.writeToFile(str(msg) + " [removePureFTPD]") @@ -137,14 +154,16 @@ class unInstallCyberPanel: def removePowerDNS(self): 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: logging.InstallLog.writeToFile(str(msg) + " [removePowerDNS]") @@ -157,13 +176,16 @@ class unInstallCyberPanel: def removePHP(self): 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: logging.InstallLog.writeToFile(str(msg) + " [removePHP]") From 37661a61d257cfd4805391fc58b22fc36512dfed Mon Sep 17 00:00:00 2001 From: rperper Date: Mon, 29 Oct 2018 09:04:11 -0400 Subject: [PATCH 16/58] Stop and disable systemd-resolved service to be able to install powerdns. --- install/installCyberPanel.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 479a790e0..f1d94b2ac 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -26,13 +26,8 @@ class InstallCyberPanel: self.distro=distro @staticmethod - def stdOut(message): - print("\n\n") - print ("[" + time.strftime( - "%I-%M-%S-%a-%b-%Y") + "] #########################################################################\n") - print("[" + time.strftime("%I-%M-%S-%a-%b-%Y") + "] " + message + "\n") - print ("[" + time.strftime( - "%I-%M-%S-%a-%b-%Y") + "] #########################################################################\n") + def stdOut(message, log = 0, exit = 0, code = os.EX_OK): + install.preFlightsChecks.stdOut(message, log, exit, code) def installLiteSpeed(self): @@ -854,6 +849,18 @@ class InstallCyberPanel: count = 0 + if self.distro == ubuntu: + command = 'systemctl stop systemd-resolved' + res = subprocess.call(shlex.split(command)) + if res != 0: + InstallCyberPanel.stdOut('Unable to stop systemd.resolved, prohits install of PowerDNS, error #' + + str(res), 1, 1, os.EX_OSERR) + command = 'systemctl disable systemd-resolved.service' + res = subprocess.call(shlex.split(command)) + if res != 0: + InstallCyberPanel.stdOut('Unable to disable systemd.resolved, prohits install of PowerDNS, error #' + + str(res), 1, 1, os.EX_OSERR) + if self.distro == centos: while (1): command = 'yum -y install epel-release yum-plugin-priorities' From ed8c276b06675a4bb867d353a61e43fbb1b56951 Mon Sep 17 00:00:00 2001 From: rperper Date: Mon, 29 Oct 2018 10:17:57 -0400 Subject: [PATCH 17/58] More on getting the nameserver to work after the default name server is removed. --- install/installCyberPanel.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index f1d94b2ac..b569c6f21 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -7,6 +7,7 @@ import install import installLog as logging import shlex import randomPassword +import errno import time import sys @@ -860,6 +861,23 @@ class InstallCyberPanel: if res != 0: InstallCyberPanel.stdOut('Unable to disable systemd.resolved, prohits install of PowerDNS, error #' + str(res), 1, 1, os.EX_OSERR) + try: + os.rename('/etc/resolv.conf', 'etc/resolved.conf') + except OSError as e: + if e.errno != errno.EEXIST: + InstallCyberPanel.stdOut("Unable to rename /etc/resolv.conf to install PowerDNS: " + + str(e), 1, 1, os.EX_OSERR) + try: + os.remove('/etc/resolv.conf') + except OSError as e1: + InstallCyberPanel.stdOut("Unable to remove existing /etc/resolv.conf to install PowerDNS: " + + str(e1), 1, 1, os.EX_OSERR) + command = 'echo "nameserver 8.8.8.8" > /etc/resolv.conf' + res = subprocess.call(shlex.split(command)) + if (res != 0): + InstallCyberPanel.stdOut("Unable to create new /etc/resolv.conf to point to 'nameserver 8.8.8.8'" + " You may need to do this manually to continue", 1, 1, os.EX_OSERR) + if self.distro == centos: while (1): From 52e6856fc405881f64504633e39d9a5494e40516 Mon Sep 17 00:00:00 2001 From: rperper Date: Mon, 29 Oct 2018 10:45:46 -0400 Subject: [PATCH 18/58] A bug in the renaming of the /etc/resolv.conf file if it doesn't work. --- install/installCyberPanel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index b569c6f21..a8f1fa65d 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -864,7 +864,7 @@ class InstallCyberPanel: try: os.rename('/etc/resolv.conf', 'etc/resolved.conf') except OSError as e: - if e.errno != errno.EEXIST: + if e.errno != errno.EEXIST and e.errno != errno.ENOENT: InstallCyberPanel.stdOut("Unable to rename /etc/resolv.conf to install PowerDNS: " + str(e), 1, 1, os.EX_OSERR) try: From 64ec237e89337b18a00638c4b43cd608bd2a16d3 Mon Sep 17 00:00:00 2001 From: rperper Date: Mon, 29 Oct 2018 10:52:34 -0400 Subject: [PATCH 19/58] Didn't install openlitespeed correctly. --- install/installCyberPanel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index a8f1fa65d..eb9ae3dca 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -37,7 +37,7 @@ class InstallCyberPanel: while (1): if self.distro == ubuntu: - command = "apt-get -y openlitespeed" + command = "apt-get -y install openlitespeed" else: command = 'yum install -y openlitespeed' cmd = shlex.split(command) From 9aabeb1f5a1f8df506a89e22fb37f547c2e4b186 Mon Sep 17 00:00:00 2001 From: rperper Date: Mon, 29 Oct 2018 11:27:50 -0400 Subject: [PATCH 20/58] Fixing again the code to deal with /etc/resolv.conf --- install/installCyberPanel.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index eb9ae3dca..6e7451544 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -872,11 +872,14 @@ class InstallCyberPanel: except OSError as e1: InstallCyberPanel.stdOut("Unable to remove existing /etc/resolv.conf to install PowerDNS: " + str(e1), 1, 1, os.EX_OSERR) - command = 'echo "nameserver 8.8.8.8" > /etc/resolv.conf' - res = subprocess.call(shlex.split(command)) - if (res != 0): - InstallCyberPanel.stdOut("Unable to create new /etc/resolv.conf to point to 'nameserver 8.8.8.8'" - " You may need to do this manually to continue", 1, 1, os.EX_OSERR) + try: + f = open('/etc/resolv.conf', 'w') + f.write('nameserver 8.8.8.8') + f.close() + except IOError as e: + InstallCyberPanel.stdOut("Unable to create /etc/resolv.conf: " + str(e) + + ". This may need to be fixed manually as 'echo \"nameserver 8.8.8.8\"> " + "/etc/resolv.conf'", 1, 1, os.EX_OSERR) if self.distro == centos: From 0f3152ae6371947cef758c8700176697e4cfb90c Mon Sep 17 00:00:00 2001 From: rperper Date: Mon, 29 Oct 2018 11:30:44 -0400 Subject: [PATCH 21/58] Fixing again the code to deal with /etc/resolv.conf --- install/unInstall.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/install/unInstall.py b/install/unInstall.py index a4d332b11..f9971e48b 100644 --- a/install/unInstall.py +++ b/install/unInstall.py @@ -16,6 +16,22 @@ distro = install.get_distro() class unInstallCyberPanel: + def fixResolvConf(self): + if distro == centos: + return + + if os.access('/etc/resolv.conf', os.F_OK): + return + + try: + f = open('/etc/resolv.conf', 'w') + f.write('nameserver 8.8.8.8') + f.close() + except IOError as e: + print "Unable to create /etc/resolv.conf: " + str(e) + \ + ". This may need to be fixed manually as 'echo \"nameserver 8.8.8.8\"> " \ + "/etc/resolv.conf'" + def unInstallCyberPanelRepo(self): if distro == centos: @@ -201,6 +217,7 @@ def Main(): remove = unInstallCyberPanel() + remove.fix remove.removeLiteSpeed() remove.removeMysql() remove.removePostfixDovecot() From 639aded6da9025e7da3639c996595a730a864d9f Mon Sep 17 00:00:00 2001 From: rperper Date: Mon, 29 Oct 2018 16:26:07 -0400 Subject: [PATCH 22/58] Fixed various issues --- install/install.py | 5 ++++- install/installCyberPanel.py | 14 ++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/install/install.py b/install/install.py index 34d1301bd..de6ceefcb 100755 --- a/install/install.py +++ b/install/install.py @@ -82,7 +82,7 @@ class preFlightsChecks: if self.distro == ubuntu: self.stdOut("Add Cyberpanel user") - command = "useradd cyberpanel -g sudo" + command = "useradd cyberpanel -U -G sudo" cmd = shlex.split(command) res = subprocess.call(cmd) if res != 0 and res != 9: @@ -703,6 +703,9 @@ class preFlightsChecks: break def fix_selinux_issue(self): + if (self.distro == ubuntu): + return + try: cmd = [] diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 6e7451544..3b330d3fa 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -1160,13 +1160,19 @@ class InstallCyberPanel: except: pass - command = 'adduser lscpd -M -d /usr/local/lscp' + if self.distro == centos: + command = 'adduser lscpd -M -d /usr/local/lscp' + else: + command = 'useradd lscpd -M -d /usr/local/lscp' + cmd = shlex.split(command) res = subprocess.call(cmd) - command = 'groupadd lscpd' - cmd = shlex.split(command) - res = subprocess.call(cmd) + if self.distro == centos: + command = 'groupadd lscpd' + cmd = shlex.split(command) + res = subprocess.call(cmd) + # Added group in useradd for Ubuntu command = 'usermod -a -G lscpd lscpd' cmd = shlex.split(command) From 2dac61842b43cc3e59284d0e5b5bf5dc79b45d5c Mon Sep 17 00:00:00 2001 From: rperper Date: Mon, 29 Oct 2018 16:29:10 -0400 Subject: [PATCH 23/58] Fixed uninstall bug --- install/unInstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/unInstall.py b/install/unInstall.py index f9971e48b..49849b167 100644 --- a/install/unInstall.py +++ b/install/unInstall.py @@ -217,7 +217,7 @@ def Main(): remove = unInstallCyberPanel() - remove.fix + remove.fixResolvConf() remove.removeLiteSpeed() remove.removeMysql() remove.removePostfixDovecot() From fce581be742964f21c6e0553b098aa50427fc8c2 Mon Sep 17 00:00:00 2001 From: rperper Date: Mon, 29 Oct 2018 16:53:06 -0400 Subject: [PATCH 24/58] Yet more uninstall stuff --- install/unInstall.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/unInstall.py b/install/unInstall.py index 49849b167..89294bad6 100644 --- a/install/unInstall.py +++ b/install/unInstall.py @@ -115,7 +115,7 @@ class unInstallCyberPanel: if distro == centos: command = 'yum -y remove openlitespeed' else: - command = 'apt-get -y remove openlitespeed' + command = 'apt-get --purge -y remove openlitespeed' cmd = shlex.split(command) From 2c037fcf45248a956c660c2928b00a4a95fa2ba5 Mon Sep 17 00:00:00 2001 From: rperper Date: Tue, 30 Oct 2018 09:51:30 -0400 Subject: [PATCH 25/58] Some fixes (I hope) --- install/install.py | 11 +++++++---- install/installCyberPanel.py | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/install/install.py b/install/install.py index de6ceefcb..c23d70de4 100755 --- a/install/install.py +++ b/install/install.py @@ -1164,7 +1164,7 @@ class preFlightsChecks: def install_postfix_davecot(self): - self.stdOut("Install dovecot") + self.stdOut("Install dovecot - first remove postfix") try: if self.distro == centos: command = 'yum remove postfix -y' @@ -1173,14 +1173,17 @@ class preFlightsChecks: subprocess.call(shlex.split(command)) + self.stdOut("Install dovecot - do the install") count = 0 while(1): if self.distro == centos: command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-3.2.4-1.gf.el7.x86_64.rpm' else: - command = 'debconf-set-selections <<< "postfix postfix/mailname string ' + str(socket.getfqdn()) + '";' \ - ' debconf-set-selections <<< "postfix postfix/main_mailer_type string \'Internet Site\'";' \ - ' apt-get install -y postfix' + command = 'debconf-set-selections <<< "postfix postfix/mailname string ' + str(socket.getfqdn()) + '"' + subprocess.call(shlex.split(command)) + command = 'debconf-set-selections <<< "postfix postfix/main_mailer_type string \'Internet Site\'"' + subprocess.call(shlex.split(command)) + command = 'apt-get -y install postfix' cmd = shlex.split(command) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 3b330d3fa..432cd29c6 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -927,7 +927,7 @@ class InstallCyberPanel: while(1): if self.distro == ubuntu: - command = "apt-get -y install pdns-server pdns-backend-mysql" + command = "DEBIAN_FRONTEND=noninteractive apt-get -y install pdns-server pdns-backend-mysql" else: command = 'yum -y install pdns pdns-backend-mysql' cmd = shlex.split(command) @@ -1124,13 +1124,13 @@ class InstallCyberPanel: if res == 1: count = count + 1 - InstallCyberPanel.stdOut("Trying to configure LSCPD, trying again, try number: " + str(count)) + InstallCyberPanel.stdOut("Trying to extract LSCPD, trying again, try number: " + str(count)) if count == 3: - logging.InstallLog.writeToFile("Failed to configure LSCPD, exiting installer! [installLSCPD]") + logging.InstallLog.writeToFile("Failed to extract LSCPD, exiting installer! [installLSCPD]") InstallCyberPanel.stdOut("Installation failed, consult: /var/log/installLogs.txt") os._exit(0) else: - logging.InstallLog.writeToFile("LSCPD successfully configured!") + logging.InstallLog.writeToFile("LSCPD successfully extracted!") InstallCyberPanel.stdOut("LSCPD successfully extracted!") break From 36cc391547fa00e93af0fa464b7c92bb975da8de Mon Sep 17 00:00:00 2001 From: rperper Date: Tue, 30 Oct 2018 11:44:41 -0400 Subject: [PATCH 26/58] Updated manage and some other stuff --- install/install.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/install/install.py b/install/install.py index c23d70de4..bd9e7e34b 100755 --- a/install/install.py +++ b/install/install.py @@ -1180,9 +1180,9 @@ class preFlightsChecks: command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-3.2.4-1.gf.el7.x86_64.rpm' else: command = 'debconf-set-selections <<< "postfix postfix/mailname string ' + str(socket.getfqdn()) + '"' - subprocess.call(shlex.split(command)) + subprocess.call(shlex.split(command), shell=True) command = 'debconf-set-selections <<< "postfix postfix/main_mailer_type string \'Internet Site\'"' - subprocess.call(shlex.split(command)) + subprocess.call(shlex.split(command), shell=True) command = 'apt-get -y install postfix' cmd = shlex.split(command) @@ -2343,6 +2343,16 @@ class preFlightsChecks: count = 0 + # In Ubuntu, the library that lscpd looks for is libpcre.so.1, but the one it installs is libpcre.so.3... + if self.distro == ubuntu: + command = 'ln -s /lib/x86_64-linux-gnu/libpcre.so.3 /lib/x86_64-linux-gnu/libpcre.so.1' + res = subprocess.call(shlex.split(command)) + if res == 0: + self.stdOut("Created ubuntu symbolic link to pcre") + else + self.stdOut("Error creating symbolic link to pcre: " + str(res)) + + while(1): command = 'systemctl start lscpd' @@ -2929,7 +2939,10 @@ milter_default_action = accept count = 0 while (1): - command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel" + if self.distro == centos: + command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel" + else: + command = 'apt-get -y install libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-openssl-dev' res = subprocess.call(shlex.split(command)) if res == 1: From ff1d715f6755880a90ba66355da79ca016ce8396 Mon Sep 17 00:00:00 2001 From: rperper Date: Tue, 30 Oct 2018 11:47:31 -0400 Subject: [PATCH 27/58] Syntax again... --- install/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index bd9e7e34b..0baef533a 100755 --- a/install/install.py +++ b/install/install.py @@ -2349,7 +2349,7 @@ class preFlightsChecks: res = subprocess.call(shlex.split(command)) if res == 0: self.stdOut("Created ubuntu symbolic link to pcre") - else + else: self.stdOut("Error creating symbolic link to pcre: " + str(res)) From dc5a7844edf5a9f19c521cf0f46ff3c7ecfecfd6 Mon Sep 17 00:00:00 2001 From: rperper Date: Tue, 30 Oct 2018 12:14:56 -0400 Subject: [PATCH 28/58] Fix bugs in pure-ftpd config --- install/installCyberPanel.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 432cd29c6..789a5c3f6 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -738,9 +738,18 @@ class InstallCyberPanel: ############## Start pureftpd ###################### try: - + self.stdOut("Correct configuration with pure-ftpd") count = 0 + try: + ok.mkdir("/etc/pure-ftpd/conf") + os.mkdir("/etc/pure-ftpd/auth") + except OSError as e: + pass + command = 'cp /etc/pure-ftpd/pure-ftpd.conf /etc/pure-ftpd/conf/pure-ftpd.conf' + res = subprocess.call(shlex.split(command)) + + self.stdOut("Start the pure-ftp service") while(1): cmd = [] From 38cee60439b1ae2474624d9b54b772c73adeab40 Mon Sep 17 00:00:00 2001 From: rperper Date: Tue, 30 Oct 2018 12:36:05 -0400 Subject: [PATCH 29/58] Dumb typo! --- install/installCyberPanel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 789a5c3f6..eeba79d5a 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -741,7 +741,7 @@ class InstallCyberPanel: self.stdOut("Correct configuration with pure-ftpd") count = 0 try: - ok.mkdir("/etc/pure-ftpd/conf") + os.mkdir("/etc/pure-ftpd/conf") os.mkdir("/etc/pure-ftpd/auth") except OSError as e: pass From 796339e6fd9dedf9e0b609d67d7c192c005c6ff9 Mon Sep 17 00:00:00 2001 From: rperper Date: Tue, 30 Oct 2018 14:34:51 -0400 Subject: [PATCH 30/58] Needed to turn on the shell for PowerDNS install. --- install/installCyberPanel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index eeba79d5a..ace2f73fe 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -940,7 +940,7 @@ class InstallCyberPanel: else: command = 'yum -y install pdns pdns-backend-mysql' cmd = shlex.split(command) - res = subprocess.call(cmd) + res = subprocess.call(cmd, shell=True) if res == 1: count = count + 1 From 8d1878b8a75999b8f220185f9ca6fb0f300e924d Mon Sep 17 00:00:00 2001 From: rperper Date: Tue, 30 Oct 2018 15:51:22 -0400 Subject: [PATCH 31/58] Simplify install --- install/installCyberPanel.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index ace2f73fe..3b28eebf5 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -1209,14 +1209,22 @@ class InstallCyberPanel: def Main(cwd, mysql, distro): - InstallCyberPanel.mysqlPassword = randomPassword.generate_pass() InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass() - - password = open("/etc/cyberpanel/mysqlPassword", "w") - password.writelines(InstallCyberPanel.mysql_Root_password) + file_name = '/etc/cyberpanel/mysqlPassword' + if access(file_name, os.F_OK): + password = open(file_name, 'r') + InstallCyberPanel.mysql_Root_password = password.readline() + else: + password = open(file_name, "w") + password.writelines(InstallCyberPanel.mysql_Root_password) password.close() + if distro == centos: + InstallCyberPanel.mysqlPassword = randomPassword.generate_pass() + else: + InstallCyberPanel.mysqlPassword = InstallCyberPanel.mysql_Root_password + installer = InstallCyberPanel("/usr/local/lsws/", cwd, distro) installer.installLiteSpeed() @@ -1227,8 +1235,10 @@ def Main(cwd, mysql, distro): installer.setup_mariadb_repo() installer.installMySQL(mysql) - installer.changeMYSQLRootPassword() - installer.changeMYSQLRootPasswordCyberPanel(mysql) + if distro == centos: + installer.changeMYSQLRootPassword() + if distro == centos and mysql == 'Two': + installer.changeMYSQLRootPasswordCyberPanel(mysql) installer.startMariaDB() mysqlUtilities.createDatabaseCyberPanel("cyberpanel", "cyberpanel", InstallCyberPanel.mysqlPassword, mysql) From 66ab8b413caa71fd75f4cf935d4ccc9d27ccf6d1 Mon Sep 17 00:00:00 2001 From: rperper Date: Tue, 30 Oct 2018 15:58:45 -0400 Subject: [PATCH 32/58] Syntax --- install/installCyberPanel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 3b28eebf5..105d27bf2 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -1212,7 +1212,7 @@ def Main(cwd, mysql, distro): InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass() file_name = '/etc/cyberpanel/mysqlPassword' - if access(file_name, os.F_OK): + if os.access(file_name, os.F_OK): password = open(file_name, 'r') InstallCyberPanel.mysql_Root_password = password.readline() else: From 3cb1049840e8278f98afb29ca7018145fb66edf7 Mon Sep 17 00:00:00 2001 From: rperper Date: Tue, 30 Oct 2018 17:33:43 -0400 Subject: [PATCH 33/58] Use a different method for unattended installs --- install/install.py | 14 ++++++++++---- install/installCyberPanel.py | 5 ++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/install/install.py b/install/install.py index 0baef533a..98f1950c0 100755 --- a/install/install.py +++ b/install/install.py @@ -1179,11 +1179,17 @@ class preFlightsChecks: if self.distro == centos: command = 'yum install -y http://mirror.ghettoforge.org/distributions/gf/el/7/plus/x86_64//postfix3-3.2.4-1.gf.el7.x86_64.rpm' else: - command = 'debconf-set-selections <<< "postfix postfix/mailname string ' + str(socket.getfqdn()) + '"' - subprocess.call(shlex.split(command), shell=True) - command = 'debconf-set-selections <<< "postfix postfix/main_mailer_type string \'Internet Site\'"' - subprocess.call(shlex.split(command), shell=True) + command = 'apt-get -y debconf-utils' + subprocess.call(shlex.split(command)) + file_name = self.cwd + '/pf.unattend.text' + pf = open(file_name, 'w') + pf.write('postfix postfix/mailname string ' + str(socket.getfqdn() + '\n')) + pf.write('postfix postfix/main_mailer_type string "Internet Site"\n') + pf.close() + command = 'debconf-set-selections ' + file_name + subprocess.call(shlex.split(command)) command = 'apt-get -y install postfix' + # os.remove(file_name) cmd = shlex.split(command) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 105d27bf2..f44c8ac63 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -970,7 +970,10 @@ class InstallCyberPanel: InstallCyberPanel.stdOut("Configuring PowerDNS..") os.chdir(self.cwd) - dnsPath = "/etc/pdns/pdns.conf" + if self.distro == centos: + dnsPath = "/etc/pdns/pdns.conf" + else: + dnsPath = "/etc/powerdns/pdns.conf" if os.path.exists(dnsPath): os.remove(dnsPath) From f8c8e71adcba8af623a8df4ff5d3e134996835ca Mon Sep 17 00:00:00 2001 From: rperper Date: Wed, 31 Oct 2018 11:06:24 -0400 Subject: [PATCH 34/58] Fix MariaDB issues --- install/installCyberPanel.py | 38 ++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index f44c8ac63..26c0ba438 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -8,6 +8,8 @@ import installLog as logging import shlex import randomPassword import errno +import MySQLdb as mariadb +import re import time import sys @@ -616,6 +618,35 @@ class InstallCyberPanel: return 1 + def fixMariaDB(self): + self.stdOut("Setup MariaDB so it can support Cyberpanel's needs") + try: + conn = mariadb.connect(user='root', passwd=mysql_Root_password) + cursor = conn.cursor() + cursor.execute('set global innodb_file_per_table = on;') + cursor.exeucte('set global innodb_file_format = Barracuda;') + cursor.execute('set global innodb_large_prefix = on;') + cursor.close() + conn.close() + except: + self.stdOut("Error in setting MariaDB global options", 1, 1, os.EX_OSERR) + + try: + fileName = '/etc/mysql/mariadb.conf.d/50-server.cnf' + data = open(fileName, 'r').readlines() + + writeDataToFile = open(fileName, 'w') + for line in data: + writeDataToFile.write(line.replace('utf8mb4','utf8')) + writeDataToFile.close() + except IOError as err: + self.stdOut("Error in setting: " + fileName + ": " + str(err), 1, 1, os.EX_OSERR) + + os.system('systemctl restart mysql') + + self.stdOut("MariaDB is now setup so it can support Cyberpanel's needs") + + def installPureFTPD(self): try: @@ -937,10 +968,11 @@ class InstallCyberPanel: while(1): if self.distro == ubuntu: command = "DEBIAN_FRONTEND=noninteractive apt-get -y install pdns-server pdns-backend-mysql" + res = os.system(command) else: command = 'yum -y install pdns pdns-backend-mysql' - cmd = shlex.split(command) - res = subprocess.call(cmd, shell=True) + cmd = shlex.split(command) + res = subprocess.call(cmd, shell=True) if res == 1: count = count + 1 @@ -1243,6 +1275,8 @@ def Main(cwd, mysql, distro): if distro == centos and mysql == 'Two': installer.changeMYSQLRootPasswordCyberPanel(mysql) installer.startMariaDB() + if distro == ubuntu: + installer.fixMariaDB() mysqlUtilities.createDatabaseCyberPanel("cyberpanel", "cyberpanel", InstallCyberPanel.mysqlPassword, mysql) From 94a0a91206149b960e8001be4fb93b0970ca32f7 Mon Sep 17 00:00:00 2001 From: rperper Date: Wed, 31 Oct 2018 11:24:31 -0400 Subject: [PATCH 35/58] Dumb syntax again --- install/installCyberPanel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 26c0ba438..c11c2978d 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -621,7 +621,7 @@ class InstallCyberPanel: def fixMariaDB(self): self.stdOut("Setup MariaDB so it can support Cyberpanel's needs") try: - conn = mariadb.connect(user='root', passwd=mysql_Root_password) + conn = mariadb.connect(user='root', passwd=self.mysql_Root_password) cursor = conn.cursor() cursor.execute('set global innodb_file_per_table = on;') cursor.exeucte('set global innodb_file_format = Barracuda;') From 2da9857ef83fcccdc6f471fac463ff14466c8ef3 Mon Sep 17 00:00:00 2001 From: rperper Date: Wed, 31 Oct 2018 11:37:42 -0400 Subject: [PATCH 36/58] Something else is wrong... --- install/installCyberPanel.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index c11c2978d..a81e4ff08 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -620,16 +620,14 @@ class InstallCyberPanel: def fixMariaDB(self): self.stdOut("Setup MariaDB so it can support Cyberpanel's needs") - try: - conn = mariadb.connect(user='root', passwd=self.mysql_Root_password) - cursor = conn.cursor() - cursor.execute('set global innodb_file_per_table = on;') - cursor.exeucte('set global innodb_file_format = Barracuda;') - cursor.execute('set global innodb_large_prefix = on;') - cursor.close() - conn.close() - except: - self.stdOut("Error in setting MariaDB global options", 1, 1, os.EX_OSERR) + + conn = mariadb.connect(user='root', passwd=self.mysql_Root_password) + cursor = conn.cursor() + cursor.execute('set global innodb_file_per_table = on;') + cursor.exeucte('set global innodb_file_format = Barracuda;') + cursor.execute('set global innodb_large_prefix = on;') + cursor.close() + conn.close() try: fileName = '/etc/mysql/mariadb.conf.d/50-server.cnf' From b15cd8fa967799fcaeaf2433516658ab24f68511 Mon Sep 17 00:00:00 2001 From: rperper Date: Wed, 31 Oct 2018 11:42:51 -0400 Subject: [PATCH 37/58] Spelling counts --- install/installCyberPanel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index a81e4ff08..e92e0197c 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -624,7 +624,7 @@ class InstallCyberPanel: conn = mariadb.connect(user='root', passwd=self.mysql_Root_password) cursor = conn.cursor() cursor.execute('set global innodb_file_per_table = on;') - cursor.exeucte('set global innodb_file_format = Barracuda;') + cursor.execute('set global innodb_file_format = Barracuda;') cursor.execute('set global innodb_large_prefix = on;') cursor.close() conn.close() From f79c9f5ea1a0cdb8857a226cc05bde065fec23d8 Mon Sep 17 00:00:00 2001 From: rperper Date: Wed, 31 Oct 2018 11:53:03 -0400 Subject: [PATCH 38/58] distro for static method and password --- install/install.py | 6 +++--- install/installCyberPanel.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/install/install.py b/install/install.py index 98f1950c0..317d09055 100755 --- a/install/install.py +++ b/install/install.py @@ -2938,14 +2938,14 @@ milter_default_action = accept return 0 @staticmethod - def setupVirtualEnv(): + def setupVirtualEnv(distro): try: ## count = 0 while (1): - if self.distro == centos: + if distro == centos: command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel" else: command = 'apt-get -y install libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-openssl-dev' @@ -3256,7 +3256,7 @@ def main(): checks.configureOpenDKIM() checks.modSecPreReqs() - checks.setupVirtualEnv() + checks.setupVirtualEnv(distro) checks.setupPHPAndComposer() if args.postfix != None: diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index e92e0197c..2ab2e1d7b 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -1268,10 +1268,10 @@ def Main(cwd, mysql, distro): installer.setup_mariadb_repo() installer.installMySQL(mysql) - if distro == centos: - installer.changeMYSQLRootPassword() - if distro == centos and mysql == 'Two': - installer.changeMYSQLRootPasswordCyberPanel(mysql) + #if distro == centos: + installer.changeMYSQLRootPassword() + #if distro == centos and mysql == 'Two': + installer.changeMYSQLRootPasswordCyberPanel(mysql) installer.startMariaDB() if distro == ubuntu: installer.fixMariaDB() From 91b46371536a137a5a3036b9e9df9472929f0adb Mon Sep 17 00:00:00 2001 From: rperper Date: Wed, 31 Oct 2018 12:16:08 -0400 Subject: [PATCH 39/58] Need OpenSSL development environment (oops) --- install/install.py | 7 ++++--- install/installCyberPanel.py | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/install/install.py b/install/install.py index 317d09055..97b564450 100755 --- a/install/install.py +++ b/install/install.py @@ -2948,7 +2948,8 @@ milter_default_action = accept if distro == centos: command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel" else: - command = 'apt-get -y install libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-openssl-dev' + command = 'apt-get -y install libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev ' \ + 'libcurl4-openssl-dev libssl-dev' res = subprocess.call(shlex.split(command)) if res == 1: @@ -3004,8 +3005,8 @@ milter_default_action = accept preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") os._exit(0) else: - logging.InstallLog.writeToFile("virtualenv setuped successfully!") - preFlightsChecks.stdOut("virtualenv setuped successfully!") + logging.InstallLog.writeToFile("virtualenv setup successfully!") + preFlightsChecks.stdOut("virtualenv setup successfully!") break ## diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 2ab2e1d7b..4c422ff8c 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -1268,9 +1268,7 @@ def Main(cwd, mysql, distro): installer.setup_mariadb_repo() installer.installMySQL(mysql) - #if distro == centos: installer.changeMYSQLRootPassword() - #if distro == centos and mysql == 'Two': installer.changeMYSQLRootPasswordCyberPanel(mysql) installer.startMariaDB() if distro == ubuntu: From f53d8f9d51e95a0febecc42f58664462b9cd05fa Mon Sep 17 00:00:00 2001 From: rperper Date: Wed, 31 Oct 2018 12:47:15 -0400 Subject: [PATCH 40/58] Added more libraries --- install/install.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index 97b564450..ee3756add 100755 --- a/install/install.py +++ b/install/install.py @@ -2949,7 +2949,8 @@ milter_default_action = accept command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel" else: command = 'apt-get -y install libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev ' \ - 'libcurl4-openssl-dev libssl-dev' + 'libcurl4-openssl-dev libssl-dev nghttp2 libnghttp2-dev idn2 libidn2-dev librtmp-dev ' \ + 'libpsl-dev nettle-dev libgnutls28-dev libldap2-dev' res = subprocess.call(shlex.split(command)) if res == 1: From 09028f1183b3e5258c21ac9511b380b8f5df9220 Mon Sep 17 00:00:00 2001 From: rperper Date: Wed, 31 Oct 2018 14:42:42 -0400 Subject: [PATCH 41/58] Composer no test --- install/composer-no-test.sh | 6 ++++++ install/install.py | 31 +++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 install/composer-no-test.sh diff --git a/install/composer-no-test.sh b/install/composer-no-test.sh new file mode 100644 index 000000000..4225b03c6 --- /dev/null +++ b/install/composer-no-test.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +#php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" +php composer-setup.php +php -r "unlink('composer-setup.php');" +cp composer.phar /usr/bin/composer diff --git a/install/install.py b/install/install.py index ee3756add..aef9a49e9 100755 --- a/install/install.py +++ b/install/install.py @@ -2922,19 +2922,38 @@ milter_default_action = accept def setupPHPAndComposer(self): try: + if self.distro == ubuntu: + if not os.access('/usr/local/lsws/lsphp70/bin/php'): + if os.access('/usr/local/lsws/lsphp70/bin/php7.0'): + os.symlink('/usr/local/lsws/lsphp70/bin/php7.0', '/usr/local/lsws/lsphp70/bin/php') + if not os.access('/usr/local/lsws/lsphp71/bin/php'): + if os.access('/usr/local/lsws/lsphp71/bin/php7.1'): + os.symlink('/usr/local/lsws/lsphp71/bin/php7.1', '/usr/local/lsws/lsphp71/bin/php') + if not os.access('/usr/local/lsws/lsphp72/bin/php'): + if os.access('/usr/local/lsws/lsphp72/bin/php7.2'): + os.symlink('/usr/local/lsws/lsphp72/bin/php7.2', '/usr/local/lsws/lsphp72/bin/php') + command = "cp /usr/local/lsws/lsphp71/bin/php /usr/bin/" res = subprocess.call(shlex.split(command)) os.chdir(self.cwd) - command = "chmod +x composer.sh" + if self.distro == centos: + command = "chmod +x composer.sh" + else: + command = "chmod +x composer-no-test.sh" + res = subprocess.call(shlex.split(command)) - command = "./composer.sh" + if self.distro == centos: + command = "./composer.sh" + else: + command = "./composer-no-test.sh" + res = subprocess.call(shlex.split(command)) except OSError, msg: - logging.InstallLog.writeToFile(str(msg) + " [setupPHPAndComposer]") + self.stdOut('Setup PHP error: ' + str(msg) + " [setupPHPAndComposer]", 1, 1, os.EX_OSERR) return 0 @staticmethod @@ -3072,7 +3091,7 @@ milter_default_action = accept writeToFile.close() except OSError, msg: - logging.InstallLog.writeToFile(str(msg) + " [enableDisableDNS]") + preFlightsChecks.stdOut('Error disabling DNS: ' + str(msg) + " [enableDisableDNS]", 1, 0) return 0 @staticmethod @@ -3098,7 +3117,7 @@ milter_default_action = accept writeToFile.close() except OSError, msg: - logging.InstallLog.writeToFile(str(msg) + " [enableDisableEmail]") + preFlightsChecks.stdOut('Error disabling Email: ' + str(msg) + " [enableDisableEmail]", 1, 0) return 0 @staticmethod @@ -3124,7 +3143,7 @@ milter_default_action = accept writeToFile.close() except OSError, msg: - logging.InstallLog.writeToFile(str(msg) + " [enableDisableEmail]") + preFlightsChecks.stdOut('Error disabling FTP: ' + str(msg) + " [enableDisableFTP]", 1, 0) return 0 From 26e98923121c8286bbc387f2e02b2c307c303dff Mon Sep 17 00:00:00 2001 From: rperper Date: Wed, 31 Oct 2018 14:57:51 -0400 Subject: [PATCH 42/58] Syntax bug --- install/install.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/install/install.py b/install/install.py index aef9a49e9..e893087b1 100755 --- a/install/install.py +++ b/install/install.py @@ -2923,14 +2923,14 @@ milter_default_action = accept def setupPHPAndComposer(self): try: if self.distro == ubuntu: - if not os.access('/usr/local/lsws/lsphp70/bin/php'): - if os.access('/usr/local/lsws/lsphp70/bin/php7.0'): + if not os.access('/usr/local/lsws/lsphp70/bin/php', os.R_OK): + if os.access('/usr/local/lsws/lsphp70/bin/php7.0', os.R_OK): os.symlink('/usr/local/lsws/lsphp70/bin/php7.0', '/usr/local/lsws/lsphp70/bin/php') - if not os.access('/usr/local/lsws/lsphp71/bin/php'): - if os.access('/usr/local/lsws/lsphp71/bin/php7.1'): + if not os.access('/usr/local/lsws/lsphp71/bin/php', os.R_OK): + if os.access('/usr/local/lsws/lsphp71/bin/php7.1', os.R_OK): os.symlink('/usr/local/lsws/lsphp71/bin/php7.1', '/usr/local/lsws/lsphp71/bin/php') - if not os.access('/usr/local/lsws/lsphp72/bin/php'): - if os.access('/usr/local/lsws/lsphp72/bin/php7.2'): + if not os.access('/usr/local/lsws/lsphp72/bin/php', os.R_OK): + if os.access('/usr/local/lsws/lsphp72/bin/php7.2', os.R_OK): os.symlink('/usr/local/lsws/lsphp72/bin/php7.2', '/usr/local/lsws/lsphp72/bin/php') command = "cp /usr/local/lsws/lsphp71/bin/php /usr/bin/" From a00657c8a1164220824ab94d1acd02d105714622 Mon Sep 17 00:00:00 2001 From: rperper Date: Wed, 31 Oct 2018 15:22:02 -0400 Subject: [PATCH 43/58] Almost there! --- install/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index e893087b1..da8a08934 100755 --- a/install/install.py +++ b/install/install.py @@ -82,7 +82,7 @@ class preFlightsChecks: if self.distro == ubuntu: self.stdOut("Add Cyberpanel user") - command = "useradd cyberpanel -U -G sudo" + command = "useradd cyberpanel -m -U -G sudo" cmd = shlex.split(command) res = subprocess.call(cmd) if res != 0 and res != 9: From 1d92b184eadf76d9f21f2e8243a5531e6a5e00a5 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 09:43:04 -0400 Subject: [PATCH 44/58] Fix sudoers file and print success message. --- install/install.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/install/install.py b/install/install.py index da8a08934..f2c94e10d 100755 --- a/install/install.py +++ b/install/install.py @@ -81,6 +81,21 @@ class preFlightsChecks: count = 0 if self.distro == ubuntu: + self.stdOut("Fix sudoers") + try: + fileName = '/etc/sudoers' + data = open(fileName, 'r').readlines() + + writeDataToFile = open(fileName, 'w') + for line in data: + if line[:5] == '%sudo': + writeDataToFile.write('%sudo ALL=ALL NOPASSWD:ALL\n') + else: + writeDataToFile.write(line) + writeDataToFile.close() + except IOError as err: + self.stdOut("Error in fixing sudoers file: " + str(err), 1, 1, os.EX_OSERR) + self.stdOut("Add Cyberpanel user") command = "useradd cyberpanel -m -U -G sudo" cmd = shlex.split(command) @@ -370,7 +385,7 @@ class preFlightsChecks: break def install_python_setup_tools(self): - self.stdOut("Install python setup tools"); + self.stdOut("Install python setup tools") count = 0 while (1): command = "yum -y install python-setuptools" @@ -2661,7 +2676,8 @@ class preFlightsChecks: print(" Visit: https://" + self.ipAddr + ":8090 ") print(" Username: admin ") print(" Password: 1234567 ") - + print(" Database password in /etc/mysqlPassword ") + print(" ") print("###################################################################") def installCertBot(self): @@ -3299,7 +3315,7 @@ def main(): checks.enableDisableFTP('On') logging.InstallLog.writeToFile("CyberPanel installation successfully completed!") - + checks.installation_successfull() if __name__ == "__main__": main() From cc3acdc39cbe8ea9919bc16b6679199e4e32078a Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 10:08:40 -0400 Subject: [PATCH 45/58] Bug in sudoers file (sigh) --- install/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index f2c94e10d..777018c97 100755 --- a/install/install.py +++ b/install/install.py @@ -89,7 +89,7 @@ class preFlightsChecks: writeDataToFile = open(fileName, 'w') for line in data: if line[:5] == '%sudo': - writeDataToFile.write('%sudo ALL=ALL NOPASSWD:ALL\n') + writeDataToFile.write('%sudo ALL=(ALL:ALL) NOPASSWD: ALL\n') else: writeDataToFile.write(line) writeDataToFile.close() From b9ce492ef221b00a92523d2adf56ac6dc02b4777 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 10:10:43 -0400 Subject: [PATCH 46/58] ...and wrong location for the database password file... --- install/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index 777018c97..b48790d0f 100755 --- a/install/install.py +++ b/install/install.py @@ -2676,7 +2676,7 @@ class preFlightsChecks: print(" Visit: https://" + self.ipAddr + ":8090 ") print(" Username: admin ") print(" Password: 1234567 ") - print(" Database password in /etc/mysqlPassword ") + print(" Database password in /etc/cyberpanel/mysqlPassword ") print(" ") print("###################################################################") From 4a4e48201791c352812813074c1fda4d6094c9be Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 13:32:39 -0400 Subject: [PATCH 47/58] Small fixes for Ubuntu 16 --- install/install.py | 10 ++++------ install/installCyberPanel.py | 8 +++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/install/install.py b/install/install.py index b48790d0f..ec80b55b7 100755 --- a/install/install.py +++ b/install/install.py @@ -320,7 +320,7 @@ class preFlightsChecks: count = 0 while (1): if self.distro == ubuntu: - command = "apt-get -y install python-pip" + command = "apt-get -y install python-pip libcurl4-openssl-dev" else: command = "yum -y install python-pip" res = subprocess.call(shlex.split(command)) @@ -2983,9 +2983,9 @@ milter_default_action = accept if distro == centos: command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel" else: - command = 'apt-get -y install libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev ' \ - 'libcurl4-openssl-dev libssl-dev nghttp2 libnghttp2-dev idn2 libidn2-dev librtmp-dev ' \ - 'libpsl-dev nettle-dev libgnutls28-dev libldap2-dev' + command = 'apt-get -y install libattr1 libattr1-dev liblzma-dev libgpgme-dev ' \ + 'libmariadbclient-dev libcurl4-openssl-dev libssl-dev nghttp2 libnghttp2-dev idn2 ' \ + 'libidn2-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev libldap2-dev' res = subprocess.call(shlex.split(command)) if res == 1: @@ -3262,14 +3262,12 @@ def main(): checks.setup_email_Passwords(installCyberPanel.InstallCyberPanel.mysqlPassword, mysql) checks.setup_postfix_davecot_config(mysql) - checks.install_unzip() checks.install_zip() checks.install_rsync() checks.downoad_and_install_raindloop() - checks.download_install_phpmyadmin() checks.installFirewalld() diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 4c422ff8c..6cdfc3cf5 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -232,11 +232,13 @@ class InstallCyberPanel: while (1): if self.distro == ubuntu: - command = 'apt-get -y install lsphp*' + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp*' + res = os.system(command) + else: command = 'yum -y groupinstall lsphp-all' - cmd = shlex.split(command) - res = subprocess.call(cmd) + cmd = shlex.split(command) + res = subprocess.call(cmd) if res == 1: count = count + 1 From 4a25f6bda4ff1a75f6b32ca43b80f87317b111d7 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 14:10:09 -0400 Subject: [PATCH 48/58] More libraries --- install/install.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index ec80b55b7..c090cbba3 100755 --- a/install/install.py +++ b/install/install.py @@ -2985,7 +2985,8 @@ milter_default_action = accept else: command = 'apt-get -y install libattr1 libattr1-dev liblzma-dev libgpgme-dev ' \ 'libmariadbclient-dev libcurl4-openssl-dev libssl-dev nghttp2 libnghttp2-dev idn2 ' \ - 'libidn2-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev libldap2-dev' + 'libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev ' \ + 'libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev' res = subprocess.call(shlex.split(command)) if res == 1: From f891a76f4f5edb6ee0a1b0b5ae0b7c0bfb0a64f8 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 16:10:29 -0400 Subject: [PATCH 49/58] Trying to deal with Ubuntu 16.04 bug --- install/install.py | 56 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/install/install.py b/install/install.py index c090cbba3..6191e8ffc 100755 --- a/install/install.py +++ b/install/install.py @@ -34,7 +34,7 @@ class preFlightsChecks: self.distro = distro @staticmethod - def stdOut(message, log = 0, exit = 0, code = os.EX_OK): + def stdOut(message, log = 0, do_exit = 0, code = os.EX_OK): print("\n\n") print ("[" + time.strftime( "%I-%M-%S-%a-%b-%Y") + "] #########################################################################\n") @@ -43,7 +43,7 @@ class preFlightsChecks: "%I-%M-%S-%a-%b-%Y") + "] #########################################################################\n") if log: logging.InstallLog.writeToFile(message) - if exit: + if do_exit: sys.exit(code) def checkPythonVersion(self): @@ -1054,9 +1054,9 @@ class preFlightsChecks: def download_install_phpmyadmin(self): self.stdOut("Install PHP MyAdmin") try: - dir = "/usr/local/lscp/cyberpanel/" + directory = "/usr/local/lscp/cyberpanel/" try: - os.chdir(dir) + os.chdir(directory) except OSError as e: msg = "Error changing to " + "/usr/local/lscp/cyberpanel/ :" + str(e) + " [download_install_phpmyadmin]" self.stdOut(msg, 1, 1, os.EX_USAGE) @@ -2410,7 +2410,7 @@ class preFlightsChecks: try: ## first install crontab - file = open("installLogs.txt", 'a') + fd = open("installLogs.txt", 'a') count = 0 while(1): @@ -2421,7 +2421,7 @@ class preFlightsChecks: cmd = shlex.split(command) - res = subprocess.call(cmd, stdout=file) + res = subprocess.call(cmd, stdout=fd) if res == 1: count = count + 1 @@ -2527,8 +2527,7 @@ class preFlightsChecks: preFlightsChecks.stdOut("Crond successfully restarted!") break - file.close() - + fd.close() except OSError, msg: logging.InstallLog.writeToFile(str(msg) + " [setup_cron]") @@ -2986,7 +2985,8 @@ milter_default_action = accept command = 'apt-get -y install libattr1 libattr1-dev liblzma-dev libgpgme-dev ' \ 'libmariadbclient-dev libcurl4-openssl-dev libssl-dev nghttp2 libnghttp2-dev idn2 ' \ 'libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev ' \ - 'libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev' + 'libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev ' \ + 'python-gpg python-gpgme' res = subprocess.call(shlex.split(command)) if res == 1: @@ -3055,22 +3055,30 @@ milter_default_action = accept ## + install_file = '/usr/local/CyberCP/requirments.txt' + if distro == ubuntu and get_Ubuntu_release() < 18.04: + install_file_new = '/usr/local/CyberCP/requirements.txt' + preFlightsChecks.stdOut("Install updated " + install_file_new, 1) + command = "sed 's/==[0-9.]*//g' " + install_file + " | sed 's/Django/Django<2/g' > " + install_file_new + os.system(command) + install_file = install_file_new + count = 0 while (1): - command = "pip install --ignore-installed -r /usr/local/CyberCP/requirments.txt" + command = "pip install --ignore-installed -r " + install_file res = subprocess.call(shlex.split(command)) if res == 1: count = count + 1 preFlightsChecks.stdOut( - "Trying to install project dependant modules, trying again, try number: " + str(count)) + "Trying to install Python project dependant modules, trying again, try number: " + str(count)) if count == 3: logging.InstallLog.writeToFile( - "Failed to install project dependant modules! [setupVirtualEnv]") + "Failed to install Python project dependant modules! [setupVirtualEnv]") break else: - logging.InstallLog.writeToFile("Project dependant modules installed successfully!") - preFlightsChecks.stdOut("Project dependant modules installed successfully!!") + logging.InstallLog.writeToFile("Python project dependant modules installed successfully!") + preFlightsChecks.stdOut("Python project dependant modules installed successfully!!") break command = "systemctl restart gunicorn.socket" @@ -3191,6 +3199,26 @@ def get_distro(): return distro +def get_Ubuntu_release(): + release = -1 + if exists("/etc/lsb-release"): + distro_file = "/etc/lsb-release" + with open(distro_file) as f: + for line in f: + if line[:16] == "DISTRIB_RELEASE=": + release = float(line[16:]) + + if release == -1: + preFlightsChecks.stdOut("Can't find distro release name in " + distro_file + " - fatal error", 1, 1, + os.EX_UNAVAILABLE) + + else: + logging.InstallLog.writeToFile("Can't find linux release file - fatal error") + preFlightsChecks.stdOut("Can't find linux release file - fatal error") + os._exit(os.EX_UNAVAILABLE) + + return release + def main(): From 2ba38ba5d41f4750af10eb3422f8da973b82f5f9 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 16:16:01 -0400 Subject: [PATCH 50/58] Take out some of the newer code to step-by-step debug it --- install/install.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/install/install.py b/install/install.py index 6191e8ffc..b2054d753 100755 --- a/install/install.py +++ b/install/install.py @@ -2986,7 +2986,7 @@ milter_default_action = accept 'libmariadbclient-dev libcurl4-openssl-dev libssl-dev nghttp2 libnghttp2-dev idn2 ' \ 'libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev ' \ 'libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev ' \ - 'python-gpg python-gpgme' + 'python-gpg python-gpgme libcurl3' res = subprocess.call(shlex.split(command)) if res == 1: @@ -3056,12 +3056,12 @@ milter_default_action = accept ## install_file = '/usr/local/CyberCP/requirments.txt' - if distro == ubuntu and get_Ubuntu_release() < 18.04: - install_file_new = '/usr/local/CyberCP/requirements.txt' - preFlightsChecks.stdOut("Install updated " + install_file_new, 1) - command = "sed 's/==[0-9.]*//g' " + install_file + " | sed 's/Django/Django<2/g' > " + install_file_new - os.system(command) - install_file = install_file_new + #if distro == ubuntu and get_Ubuntu_release() < 18.04: + # install_file_new = '/usr/local/CyberCP/requirements.txt' + # preFlightsChecks.stdOut("Install updated " + install_file_new, 1) + # command = "sed 's/==[0-9.]*//g' " + install_file + " | sed 's/Django/Django<2/g' > " + install_file_new + # os.system(command) + # install_file = install_file_new count = 0 while (1): From 43da49a94508b1d2584969366fe5fe917216f0c6 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 16:17:51 -0400 Subject: [PATCH 51/58] Some of George's suggestions --- install/install.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install/install.py b/install/install.py index b2054d753..c5b26f8f1 100755 --- a/install/install.py +++ b/install/install.py @@ -320,7 +320,7 @@ class preFlightsChecks: count = 0 while (1): if self.distro == ubuntu: - command = "apt-get -y install python-pip libcurl4-openssl-dev" + command = "apt-get -y install python-pip" else: command = "yum -y install python-pip" res = subprocess.call(shlex.split(command)) @@ -2983,10 +2983,10 @@ milter_default_action = accept command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel" else: command = 'apt-get -y install libattr1 libattr1-dev liblzma-dev libgpgme-dev ' \ - 'libmariadbclient-dev libcurl4-openssl-dev libssl-dev nghttp2 libnghttp2-dev idn2 ' \ + 'libmariadbclient-dev libcurl4-gnutls-dev libssl-dev nghttp2 libnghttp2-dev idn2 ' \ 'libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev ' \ 'libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev ' \ - 'python-gpg python-gpgme libcurl3' + 'python-gpg python-gpgme' res = subprocess.call(shlex.split(command)) if res == 1: From 1dff0bc2ea6bde45c543b1cf926b9620a9a61024 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 16:35:07 -0400 Subject: [PATCH 52/58] Dumb bug --- install/install.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install/install.py b/install/install.py index c5b26f8f1..ee969d7f1 100755 --- a/install/install.py +++ b/install/install.py @@ -2443,7 +2443,7 @@ class preFlightsChecks: else: command = 'systemctl enable cron' cmd = shlex.split(command) - res = subprocess.call(cmd, stdout=file) + res = subprocess.call(cmd, stdout=fd) if res == 1: count = count + 1 @@ -2465,7 +2465,7 @@ class preFlightsChecks: command = 'systemctl start cron' cmd = shlex.split(command) - res = subprocess.call(cmd, stdout=file) + res = subprocess.call(cmd, stdout=fd) if res == 1: count = count + 1 @@ -2488,7 +2488,7 @@ class preFlightsChecks: command = 'chmod +x /usr/local/CyberCP/plogical/findBWUsage.py' cmd = shlex.split(command) - res = subprocess.call(cmd, stdout=file) + res = subprocess.call(cmd, stdout=fd) if res == 1: logging.InstallLog.writeToFile("1427 [setup_cron]") @@ -2498,7 +2498,7 @@ class preFlightsChecks: command = 'chmod +x /usr/local/CyberCP/postfixSenderPolicy/client.py' cmd = shlex.split(command) - res = subprocess.call(cmd, stdout=file) + res = subprocess.call(cmd, stdout=fd) if res == 1: logging.InstallLog.writeToFile("1428 [setup_cron]") @@ -2514,7 +2514,7 @@ class preFlightsChecks: command = 'systemctl restart cron.service' cmd = shlex.split(command) - res = subprocess.call(cmd, stdout=file) + res = subprocess.call(cmd, stdout=fd) if res == 1: count = count + 1 From 467d13c1582bbca6e80d21280248d4aa12116dfd Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 16:55:01 -0400 Subject: [PATCH 53/58] Adding gnutls earlier as well --- install/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index ee969d7f1..226d0e77f 100755 --- a/install/install.py +++ b/install/install.py @@ -320,7 +320,7 @@ class preFlightsChecks: count = 0 while (1): if self.distro == ubuntu: - command = "apt-get -y install python-pip" + command = "apt-get -y install python-pip libcurl4-gnutls-dev" else: command = "yum -y install python-pip" res = subprocess.call(shlex.split(command)) From 66625e91e265f04709273f7db19461254014c42d Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 20:27:26 -0400 Subject: [PATCH 54/58] George's suggested additions --- install/install.py | 2 +- install/installCyberPanel.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install/install.py b/install/install.py index 226d0e77f..23a64582a 100755 --- a/install/install.py +++ b/install/install.py @@ -320,7 +320,7 @@ class preFlightsChecks: count = 0 while (1): if self.distro == ubuntu: - command = "apt-get -y install python-pip libcurl4-gnutls-dev" + command = "apt-get -y install python-pip libcurl4-gnutls-dev libgnutls-dev libgcrypt20-dev" else: command = "yum -y install python-pip" res = subprocess.call(shlex.split(command)) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 6cdfc3cf5..31ad4e17f 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -232,7 +232,7 @@ class InstallCyberPanel: while (1): if self.distro == ubuntu: - command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp*' + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp7*' res = os.system(command) else: From 9b634f51e5b0617d0205bde2b91bc0806cceff85 Mon Sep 17 00:00:00 2001 From: rperper Date: Thu, 1 Nov 2018 20:40:32 -0400 Subject: [PATCH 55/58] Fixed the bug Rukai found that I introduced (thanks) --- install/installCyberPanel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index 31ad4e17f..17e3e8902 100644 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -972,7 +972,7 @@ class InstallCyberPanel: else: command = 'yum -y install pdns pdns-backend-mysql' cmd = shlex.split(command) - res = subprocess.call(cmd, shell=True) + res = subprocess.call(cmd) if res == 1: count = count + 1 From a431937d6adb9eb632be308cfb84d3a37fb8e4f9 Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 2 Nov 2018 09:17:16 -0400 Subject: [PATCH 56/58] Install packages independently so they actually install --- install/install.py | 79 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/install/install.py b/install/install.py index 23a64582a..87d1ac6ed 100755 --- a/install/install.py +++ b/install/install.py @@ -320,7 +320,7 @@ class preFlightsChecks: count = 0 while (1): if self.distro == ubuntu: - command = "apt-get -y install python-pip libcurl4-gnutls-dev libgnutls-dev libgcrypt20-dev" + command = "apt-get -y install python-pip" else: command = "yum -y install python-pip" res = subprocess.call(shlex.split(command)) @@ -2971,6 +2971,15 @@ milter_default_action = accept self.stdOut('Setup PHP error: ' + str(msg) + " [setupPHPAndComposer]", 1, 1, os.EX_OSERR) return 0 + @staticmethod + def installOne(package): + res = subprocess.call(shlex.split('apt-get -y install ' + package)) + if res != 0: + preFlightsChecks.stdOut("Error #" + str(res) + ' installing:' + package + '. This may not be an issue ' \ + 'but may affect installation of something later', 1) + return res #Though probably not used + + @staticmethod def setupVirtualEnv(distro): try: @@ -2978,30 +2987,54 @@ milter_default_action = accept ## count = 0 - while (1): - if distro == centos: + if distro == ubuntu: + # You can't install all at once! So install one at a time. + preFlightsChecks.stdOut("Installing python prerequisites", 1) + preFlightsChecks.installOne('libcurl4-gnutls-dev') + preFlightsChecks.installOne('libgnutls-dev') + preFlightsChecks.installOne('libgcrypt20-dev') + preFlightsChecks.installOne('libattr1') + preFlightsChecks.installOne('libattr1-dev') + preFlightsChecks.installOne('liblzma-dev') + preFlightsChecks.installOne('libgpgme-dev') + preFlightsChecks.installOne('libmariadbclient-dev') + preFlightsChecks.installOne('libcurl4-gnutls-dev') + preFlightsChecks.installOne('libssl-dev') + preFlightsChecks.installOne('nghttp2') + preFlightsChecks.installOne('libnghttp2-dev') + preFlightsChecks.installOne('idn2') + preFlightsChecks.installOne('libidn2-dev') + preFlightsChecks.installOne('libidn2-0-dev') + preFlightsChecks.installOne('librtmp-dev') + preFlightsChecks.installOne('libpsl-dev') + preFlightsChecks.installOne('nettle-dev') + preFlightsChecks.installOne('libgnutls28-dev') + preFlightsChecks.installOne('libldap2-dev') + preFlightsChecks.installOne('libgssapi-krb5-2') + preFlightsChecks.installOne('libk5crypto3') + preFlightsChecks.installOne('libkrb5-dev') + preFlightsChecks.installOne('libcomerr2') + preFlightsChecks.installOne('libldap2-dev') + preFlightsChecks.installOne('python-gpg') + preFlightsChecks.installOne('python-gpgme') + else: + while (1): command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel" - else: - command = 'apt-get -y install libattr1 libattr1-dev liblzma-dev libgpgme-dev ' \ - 'libmariadbclient-dev libcurl4-gnutls-dev libssl-dev nghttp2 libnghttp2-dev idn2 ' \ - 'libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev ' \ - 'libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev ' \ - 'python-gpg python-gpgme' - res = subprocess.call(shlex.split(command)) + res = subprocess.call(shlex.split(command)) - if res == 1: - count = count + 1 - preFlightsChecks.stdOut( - "Trying to install project dependant modules, trying again, try number: " + str(count)) - if count == 3: - logging.InstallLog.writeToFile( - "Failed to install project dependant modules! [setupVirtualEnv]") - preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") - os._exit(0) - else: - logging.InstallLog.writeToFile("Project dependant modules installed successfully!") - preFlightsChecks.stdOut("Project dependant modules installed successfully!!") - break + if res == 1: + count = count + 1 + preFlightsChecks.stdOut( + "Trying to install project dependant modules, trying again, try number: " + str(count)) + if count == 3: + logging.InstallLog.writeToFile( + "Failed to install project dependant modules! [setupVirtualEnv]") + preFlightsChecks.stdOut("Installation failed, consult: /var/log/installLogs.txt") + os._exit(0) + else: + logging.InstallLog.writeToFile("Project dependant modules installed successfully!") + preFlightsChecks.stdOut("Project dependant modules installed successfully!!") + break ## From c931ed675251374a35b7be42a553bc360a7a4f63 Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 2 Nov 2018 11:53:08 -0400 Subject: [PATCH 57/58] Remove pycharm from the requirements --- install/install.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/install/install.py b/install/install.py index 87d1ac6ed..ff33284bd 100755 --- a/install/install.py +++ b/install/install.py @@ -3089,12 +3089,18 @@ milter_default_action = accept ## install_file = '/usr/local/CyberCP/requirments.txt' - #if distro == ubuntu and get_Ubuntu_release() < 18.04: - # install_file_new = '/usr/local/CyberCP/requirements.txt' - # preFlightsChecks.stdOut("Install updated " + install_file_new, 1) - # command = "sed 's/==[0-9.]*//g' " + install_file + " | sed 's/Django/Django<2/g' > " + install_file_new - # os.system(command) - # install_file = install_file_new + if distro == ubuntu and get_Ubuntu_release() < 18.04: + install_file_new = '/usr/local/CyberCP/requirements.txt' + fd = open(install_file,'r') + fd_new = open(install_file_new,'w') + lines = fd.readlines() + for line in lines: + if line[:6] != 'pycurl': + fd_new.write(line) + fd.close() + fd_new.close() + preFlightsChecks.stdOut("Install updated " + install_file_new, 1) + install_file = install_file_new count = 0 while (1): From 9abd011adcefd96c56dad4403f21a7f4e4987a13 Mon Sep 17 00:00:00 2001 From: rperper Date: Fri, 2 Nov 2018 12:09:30 -0400 Subject: [PATCH 58/58] Remove pygpgme from the requirements for 16.04 --- install/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index ff33284bd..ccc31b1e6 100755 --- a/install/install.py +++ b/install/install.py @@ -3095,7 +3095,7 @@ milter_default_action = accept fd_new = open(install_file_new,'w') lines = fd.readlines() for line in lines: - if line[:6] != 'pycurl': + if line[:6] != 'pycurl' and line[:7] != 'pygpgme': fd_new.write(line) fd.close() fd_new.close()