bug fix: ubuntu 22

This commit is contained in:
Usman Nasir
2022-11-12 16:00:41 +05:00
parent 1aeb604aa6
commit d4ce8fcb3d
2 changed files with 44 additions and 41 deletions

View File

@@ -218,12 +218,15 @@ class preFlightsChecks:
return False return False
@staticmethod @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) finalMessage = 'Running: %s' % (message)
preFlightsChecks.stdOut(finalMessage, log) preFlightsChecks.stdOut(finalMessage, log)
count = 0 count = 0
while True: 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): if preFlightsChecks.resFailed(distro, res):
count = count + 1 count = count + 1
@@ -368,9 +371,9 @@ class preFlightsChecks:
if self.distro == centos or self.distro == cent8 or self.distro == openeuler: if self.distro == centos or self.distro == cent8 or self.distro == openeuler:
command = "yum -y install psmisc" command = "yum -y install psmisc"
else: 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): 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: if self.distro == centos or self.distro == cent8 or self.distro == openeuler:
command = 'yum -y install unzip' command = 'yum -y install unzip'
else: 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: except BaseException as msg:
logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_unzip]") 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: if self.distro == centos or self.distro == cent8 or self.distro == openeuler:
command = 'yum -y install zip' command = 'yum -y install zip'
else: 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: except BaseException as msg:
logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_zip]") logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_zip]")
@@ -816,8 +819,8 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout';
command = 'yum remove postfix -y' command = 'yum remove postfix -y'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
elif self.distro == ubuntu: elif self.distro == ubuntu:
command = 'apt-get -y remove postfix' command = 'DEBIAN_FRONTEND=noninteractive apt-get -y remove postfix'
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)
self.stdOut("Install dovecot - do the install") 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) preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
else: else:
command = 'apt-get -y install debconf-utils' command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install debconf-utils'
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)
file_name = self.cwd + '/pf.unattend.text' file_name = self.cwd + '/pf.unattend.text'
pf = open(file_name, 'w') pf = open(file_name, 'w')
pf.write('postfix postfix/mailname string ' + str(socket.getfqdn() + '\n')) 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 command = 'debconf-set-selections ' + file_name
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) 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) # 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: elif self.distro == openeuler:
command = 'dnf install dovecot -y' command = 'dnf install dovecot -y'
else: 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: except BaseException as msg:
logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_postfix_dovecot]") 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) preFlightsChecks.stdOut("[ERROR] Expected access to ufw not available, do not need to remove it", 1)
return True return True
try: try:
preFlightsChecks.call('apt-get -y remove ufw', self.distro, '[remove_ufw]', 'Remove ufw firewall ' + preFlightsChecks.call('DEBIAN_FRONTEND=noninteractive apt-get -y remove ufw', self.distro, '[remove_ufw]', 'Remove ufw firewall ' +
'(using firewalld)', 1, 0, os.EX_OSERR) '(using firewalld)', 1, 0, os.EX_OSERR, True)
except: except:
pass pass
return True return True
@@ -1374,11 +1377,11 @@ autocreate_system_folders = On
preFlightsChecks.stdOut("Enabling Firewall!") preFlightsChecks.stdOut("Enabling Firewall!")
if self.distro == ubuntu: if self.distro == ubuntu:
command = 'apt-get -y install firewalld' command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install firewalld'
else: else:
command = 'yum -y install firewalld' 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: if self.distro == centos:
@@ -1436,19 +1439,19 @@ autocreate_system_folders = On
os.chdir(self.cwd) os.chdir(self.cwd)
if self.distro == ubuntu: 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: else:
command = 'yum -y install gcc gcc-c++ make autoconf glibc' 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: 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" " zlib1g zlib1g-dev libudns-dev whichman curl"
else: else:
command = 'yum -y install pcre-devel openssl-devel expat-devel geoip-devel zlib-devel udns-devel' 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/' command = 'tar zxf lscp.tar.gz -C /usr/local/'
preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR) 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: if self.distro == centos or self.distro == cent8 or self.distro == openeuler:
command = 'yum install cronie -y' command = 'yum install cronie -y'
else: 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: if self.distro == centos or self.distro == cent8 or self.distro == openeuler:
command = 'systemctl enable crond' command = 'systemctl enable crond'
@@ -1822,9 +1825,9 @@ autocreate_system_folders = On
if self.distro == centos or self.distro == cent8 or self.distro == openeuler: if self.distro == centos or self.distro == cent8 or self.distro == openeuler:
command = 'yum -y install rsync' command = 'yum -y install rsync'
else: 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: except BaseException as msg:
logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_rsync]") logging.InstallLog.writeToFile('[ERROR] ' + str(msg) + " [install_rsync]")
@@ -1880,9 +1883,9 @@ autocreate_system_folders = On
elif self.distro == cent8 or self.distro == openeuler: elif self.distro == cent8 or self.distro == openeuler:
command = 'dnf install opendkim -y' command = 'dnf install opendkim -y'
else: 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: if self.distro == cent8 or self.distro == openeuler:
command = 'dnf install opendkim-tools -y' command = 'dnf install opendkim-tools -y'
@@ -2002,7 +2005,7 @@ milter_default_action = accept
@staticmethod @staticmethod
def installOne(package): 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: if res != 0:
preFlightsChecks.stdOut("Error #" + str(res) + ' installing:' + package + '. This may not be an issue ' \ preFlightsChecks.stdOut("Error #" + str(res) + ' installing:' + package + '. This may not be an issue ' \
'but may affect installation of something later', '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) preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
else: else:
command = 'apt-get update -y' command = 'DEBIAN_FRONTEND=noninteractive apt-get update -y'
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 = 'apt-get install restic -y' command = 'DEBIAN_FRONTEND=noninteractive apt-get install restic -y'
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 = 'restic self-update' command = 'restic self-update'
preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)

View File

@@ -66,8 +66,8 @@ class InstallCyberPanel:
def installLiteSpeed(self): def installLiteSpeed(self):
if self.ent == 0: if self.ent == 0:
if self.distro == ubuntu: if self.distro == ubuntu:
command = "apt-get -y install openlitespeed" command = "DEBIAN_FRONTEND=noninteractive apt-get -y install openlitespeed"
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)
elif self.distro == centos: elif self.distro == centos:
command = 'yum install -y openlitespeed' command = 'yum install -y openlitespeed'
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)
@@ -268,8 +268,8 @@ class InstallCyberPanel:
if self.distro == ubuntu: if self.distro == ubuntu:
if get_Ubuntu_release() == 18.10: if get_Ubuntu_release() == 18.10:
command = 'apt-get install software-properties-common -y' command = 'DEBIAN_FRONTEND=noninteractive apt-get install software-properties-common -y'
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)
command = "apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'" 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) 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'" 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) 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: elif self.distro == centos:
command = 'yum --enablerepo=mariadb -y install MariaDB-server MariaDB-client' command = 'yum --enablerepo=mariadb -y install MariaDB-server MariaDB-client'
elif self.distro == cent8 or self.distro == openeuler: elif self.distro == cent8 or self.distro == openeuler:
@@ -297,7 +297,7 @@ class InstallCyberPanel:
command = 'dnf -y install mariadb-server' 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 ###################### ############## Start mariadb ######################