From d4ce8fcb3d29b821609688dce5a6f806169c3475 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Sat, 12 Nov 2022 16:00:41 +0500 Subject: [PATCH] bug fix: ubuntu 22 --- install/install.py | 73 +++++++++++++++++++----------------- install/installCyberPanel.py | 12 +++--- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/install/install.py b/install/install.py index 058177119..b2c43ab5b 100755 --- a/install/install.py +++ b/install/install.py @@ -218,12 +218,15 @@ class preFlightsChecks: return False @staticmethod - def call(command, distro, bracket, message, log=0, do_exit=0, code=os.EX_OK): + def call(command, distro, bracket, message, log=0, do_exit=0, code=os.EX_OK, shell=False): finalMessage = 'Running: %s' % (message) preFlightsChecks.stdOut(finalMessage, log) count = 0 while True: - res = subprocess.call(shlex.split(command)) + if shell == False: + res = subprocess.call(shlex.split(command)) + else: + res = subprocess.call(command, shell=True) if preFlightsChecks.resFailed(distro, res): count = count + 1 @@ -368,9 +371,9 @@ class preFlightsChecks: if self.distro == centos or self.distro == cent8 or self.distro == openeuler: command = "yum -y install psmisc" else: - command = "apt-get -y install psmisc" + command = "DEBIAN_FRONTEND=noninteractive apt-get -y install psmisc" - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) def download_install_CyberPanel(self, mysqlPassword, mysql): ## @@ -706,9 +709,9 @@ password="%s" if self.distro == centos or self.distro == cent8 or self.distro == openeuler: command = 'yum -y install unzip' else: - command = 'apt-get -y install unzip' + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install unzip' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_unzip]") @@ -718,9 +721,9 @@ password="%s" if self.distro == centos or self.distro == cent8 or self.distro == openeuler: command = 'yum -y install zip' else: - command = 'apt-get -y install zip' + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install zip' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_zip]") @@ -816,8 +819,8 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; command = 'yum remove postfix -y' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) elif self.distro == ubuntu: - command = 'apt-get -y remove postfix' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y remove postfix' + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) self.stdOut("Install dovecot - do the install") @@ -835,8 +838,8 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) else: - command = 'apt-get -y install debconf-utils' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install debconf-utils' + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) file_name = self.cwd + '/pf.unattend.text' pf = open(file_name, 'w') pf.write('postfix postfix/mailname string ' + str(socket.getfqdn() + '\n')) @@ -845,10 +848,10 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; command = 'debconf-set-selections ' + file_name preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) - command = 'apt-get -y install postfix postfix-mysql' + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install postfix postfix-mysql' # os.remove(file_name) - preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR, True) ## @@ -859,9 +862,9 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; elif self.distro == openeuler: command = 'dnf install dovecot -y' else: - command = 'apt-get -y install dovecot-mysql dovecot-imapd dovecot-pop3d' + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install dovecot-mysql dovecot-imapd dovecot-pop3d' - preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR, True) except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_postfix_dovecot]") @@ -1359,8 +1362,8 @@ autocreate_system_folders = On preFlightsChecks.stdOut("[ERROR] Expected access to ufw not available, do not need to remove it", 1) return True try: - preFlightsChecks.call('apt-get -y remove ufw', self.distro, '[remove_ufw]', 'Remove ufw firewall ' + - '(using firewalld)', 1, 0, os.EX_OSERR) + preFlightsChecks.call('DEBIAN_FRONTEND=noninteractive apt-get -y remove ufw', self.distro, '[remove_ufw]', 'Remove ufw firewall ' + + '(using firewalld)', 1, 0, os.EX_OSERR, True) except: pass return True @@ -1374,11 +1377,11 @@ autocreate_system_folders = On preFlightsChecks.stdOut("Enabling Firewall!") if self.distro == ubuntu: - command = 'apt-get -y install firewalld' + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install firewalld' else: command = 'yum -y install firewalld' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) ###### if self.distro == centos: @@ -1436,19 +1439,19 @@ autocreate_system_folders = On os.chdir(self.cwd) if self.distro == ubuntu: - command = "apt-get -y install gcc g++ make autoconf rcs" + command = "DEBIAN_FRONTEND=noninteractive apt-get -y install gcc g++ make autoconf rcs" else: command = 'yum -y install gcc gcc-c++ make autoconf glibc' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) if self.distro == ubuntu: - command = "apt-get -y install libpcre3 libpcre3-dev openssl libexpat1 libexpat1-dev libgeoip-dev" \ + command = "DEBIAN_FRONTEND=noninteractive 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' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) command = 'tar zxf lscp.tar.gz -C /usr/local/' preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) @@ -1718,9 +1721,9 @@ autocreate_system_folders = On if self.distro == centos or self.distro == cent8 or self.distro == openeuler: command = 'yum install cronie -y' else: - command = 'apt-get -y install cron' + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install cron' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) if self.distro == centos or self.distro == cent8 or self.distro == openeuler: command = 'systemctl enable crond' @@ -1822,9 +1825,9 @@ autocreate_system_folders = On if self.distro == centos or self.distro == cent8 or self.distro == openeuler: command = 'yum -y install rsync' else: - command = 'apt-get -y install rsync' + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install rsync' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) except BaseException as msg: logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_rsync]") @@ -1880,9 +1883,9 @@ autocreate_system_folders = On elif self.distro == cent8 or self.distro == openeuler: command = 'dnf install opendkim -y' else: - command = 'apt-get -y install opendkim' + command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install opendkim' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) if self.distro == cent8 or self.distro == openeuler: command = 'dnf install opendkim-tools -y' @@ -2002,7 +2005,7 @@ milter_default_action = accept @staticmethod def installOne(package): - res = subprocess.call(shlex.split('apt-get -y install ' + package)) + res = subprocess.call(shlex.split('DEBIAN_FRONTEND=noninteractive 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', @@ -2135,11 +2138,11 @@ milter_default_action = accept preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) else: - command = 'apt-get update -y' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + command = 'DEBIAN_FRONTEND=noninteractive apt-get update -y' + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) - command = 'apt-get install restic -y' - preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) + command = 'DEBIAN_FRONTEND=noninteractive apt-get install restic -y' + preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR, True) command = 'restic self-update' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) diff --git a/install/installCyberPanel.py b/install/installCyberPanel.py index f73bf8ef8..c197a3898 100755 --- a/install/installCyberPanel.py +++ b/install/installCyberPanel.py @@ -66,8 +66,8 @@ class InstallCyberPanel: def installLiteSpeed(self): if self.ent == 0: if self.distro == ubuntu: - command = "apt-get -y install openlitespeed" - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + command = "DEBIAN_FRONTEND=noninteractive apt-get -y install openlitespeed" + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR, True) elif self.distro == centos: command = 'yum install -y openlitespeed' install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) @@ -268,8 +268,8 @@ class InstallCyberPanel: if self.distro == ubuntu: if get_Ubuntu_release() == 18.10: - command = 'apt-get install software-properties-common -y' - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + command = 'DEBIAN_FRONTEND=noninteractive apt-get install software-properties-common -y' + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR, True) command = "apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'" install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) @@ -277,7 +277,7 @@ class InstallCyberPanel: command = "add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirror.yongbok.net/mariadb/repo/10.4/ubuntu bionic main'" install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) - command = "apt-get -y install mariadb-server" + command = "DEBIAN_FRONTEND=noninteractive apt-get -y install mariadb-server" elif self.distro == centos: command = 'yum --enablerepo=mariadb -y install MariaDB-server MariaDB-client' elif self.distro == cent8 or self.distro == openeuler: @@ -297,7 +297,7 @@ class InstallCyberPanel: command = 'dnf -y install mariadb-server' - install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) + install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR, True) ############## Start mariadb ######################