Skip to content

Commit 5da94b0

Browse files
committed
bug fix: install
1 parent 777e699 commit 5da94b0

File tree

1 file changed

+42
-47
lines changed

1 file changed

+42
-47
lines changed

install/installCyberPanel.py

Lines changed: 42 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
from os.path import exists
1111
import time
1212

13-
#distros
14-
centos=0
15-
ubuntu=1
16-
cent8=2
13+
# distros
14+
centos = 0
15+
ubuntu = 1
16+
cent8 = 2
17+
1718

1819
def get_Ubuntu_release():
1920
release = -1
@@ -34,12 +35,13 @@ def get_Ubuntu_release():
3435

3536
return release
3637

37-
class InstallCyberPanel:
3838

39+
class InstallCyberPanel:
3940
mysql_Root_password = ""
4041
mysqlPassword = ""
4142

42-
def __init__(self, rootPath, cwd, distro, ent, serial = None, port = None, ftp = None, dns = None, publicip = None, remotemysql = None , mysqlhost = None, mysqldb = None, mysqluser = None, mysqlpassword = None, mysqlport = None):
43+
def __init__(self, rootPath, cwd, distro, ent, serial=None, port=None, ftp=None, dns=None, publicip=None,
44+
remotemysql=None, mysqlhost=None, mysqldb=None, mysqluser=None, mysqlpassword=None, mysqlport=None):
4345
self.server_root_path = rootPath
4446
self.cwd = cwd
4547
self.distro = distro
@@ -101,7 +103,6 @@ def installLiteSpeed(self):
101103
writeSerial.writelines(self.serial)
102104
writeSerial.close()
103105

104-
105106
shutil.copy('litespeed/install.sh', 'lsws-6.0/')
106107
shutil.copy('litespeed/functions.sh', 'lsws-6.0/')
107108

@@ -132,7 +133,7 @@ def installLiteSpeed(self):
132133
return 1
133134

134135
def reStartLiteSpeed(self):
135-
command = self.server_root_path+"bin/lswsctrl restart"
136+
command = self.server_root_path + "bin/lswsctrl restart"
136137
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
137138

138139
def fix_ols_configs(self):
@@ -142,7 +143,7 @@ def fix_ols_configs(self):
142143

143144
## remove example virtual host
144145

145-
data = open(self.server_root_path+"conf/httpd_config.conf",'r').readlines()
146+
data = open(self.server_root_path + "conf/httpd_config.conf", 'r').readlines()
146147

147148
writeDataToFile = open(self.server_root_path + "conf/httpd_config.conf", 'w')
148149

@@ -165,13 +166,13 @@ def changePortTo80(self):
165166
try:
166167
InstallCyberPanel.stdOut("Changing default port to 80..", 1)
167168

168-
data = open(self.server_root_path+"conf/httpd_config.conf").readlines()
169+
data = open(self.server_root_path + "conf/httpd_config.conf").readlines()
169170

170-
writeDataToFile = open(self.server_root_path+"conf/httpd_config.conf", 'w')
171+
writeDataToFile = open(self.server_root_path + "conf/httpd_config.conf", 'w')
171172

172173
for items in data:
173174
if (items.find("*:8088") > -1):
174-
writeDataToFile.writelines(items.replace("*:8088","*:80"))
175+
writeDataToFile.writelines(items.replace("*:8088", "*:80"))
175176
else:
176177
writeDataToFile.writelines(items)
177178

@@ -191,7 +192,7 @@ def installAllPHPVersions(self):
191192
command = 'DEBIAN_FRONTEND=noninteractive apt-get -y install ' \
192193
'lsphp7? lsphp7?-common lsphp7?-curl lsphp7?-dev lsphp7?-imap lsphp7?-intl lsphp7?-json ' \
193194
'lsphp7?-ldap lsphp7?-mysql lsphp7?-opcache lsphp7?-pspell lsphp7?-recode ' \
194-
'lsphp7?-sqlite3 lsphp7?-tidy lsphp7?-sodium'
195+
'lsphp7?-sqlite3 lsphp7?-tidy'
195196

196197
os.system(command)
197198

@@ -207,7 +208,6 @@ def installAllPHPVersions(self):
207208

208209
## only php 71
209210
if self.distro == centos:
210-
211211
command = 'yum install lsphp71 lsphp71-json lsphp71-xmlrpc lsphp71-xml lsphp71-soap lsphp71-snmp ' \
212212
'lsphp71-recode lsphp71-pspell lsphp71-process lsphp71-pgsql lsphp71-pear lsphp71-pdo lsphp71-opcache ' \
213213
'lsphp71-odbc lsphp71-mysqlnd lsphp71-mcrypt lsphp71-mbstring lsphp71-ldap lsphp71-intl lsphp71-imap ' \
@@ -218,24 +218,23 @@ def installAllPHPVersions(self):
218218
command = 'yum install -y lsphp72 lsphp72-json lsphp72-xmlrpc lsphp72-xml lsphp72-soap lsphp72-snmp ' \
219219
'lsphp72-recode lsphp72-pspell lsphp72-process lsphp72-pgsql lsphp72-pear lsphp72-pdo lsphp72-opcache ' \
220220
'lsphp72-odbc lsphp72-mysqlnd lsphp72-mcrypt lsphp72-mbstring lsphp72-ldap lsphp72-intl lsphp72-imap ' \
221-
'lsphp72-gmp lsphp72-gd lsphp72-enchant lsphp72-dba lsphp72-common lsphp72-bcmath lsphp72-sodium'
221+
'lsphp72-gmp lsphp72-gd lsphp72-enchant lsphp72-dba lsphp72-common lsphp72-bcmath'
222222

223223
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
224224

225-
226225
## only php 73
227226
command = 'yum install -y lsphp73 lsphp73-json lsphp73-xmlrpc lsphp73-xml lsphp73-tidy lsphp73-soap lsphp73-snmp ' \
228227
'lsphp73-recode lsphp73-pspell lsphp73-process lsphp73-pgsql lsphp73-pear lsphp73-pdo lsphp73-opcache ' \
229228
'lsphp73-odbc lsphp73-mysqlnd lsphp73-mcrypt lsphp73-mbstring lsphp73-ldap lsphp73-intl lsphp73-imap ' \
230-
'lsphp73-gmp lsphp73-gd lsphp73-enchant lsphp73-dba lsphp73-common lsphp73-bcmath lsphp73-sodium'
229+
'lsphp73-gmp lsphp73-gd lsphp73-enchant lsphp73-dba lsphp73-common lsphp73-bcmath'
231230

232231
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
233232

234233
## only php 74
235234
command = 'yum install -y lsphp74 lsphp74-json lsphp74-xmlrpc lsphp74-xml lsphp74-tidy lsphp74-soap lsphp74-snmp ' \
236235
'lsphp74-recode lsphp74-pspell lsphp74-process lsphp74-pgsql lsphp74-pear lsphp74-pdo lsphp74-opcache ' \
237236
'lsphp74-odbc lsphp74-mysqlnd lsphp74-mcrypt lsphp74-mbstring lsphp74-ldap lsphp74-intl lsphp74-imap ' \
238-
'lsphp74-gmp lsphp74-gd lsphp74-enchant lsphp74-dba lsphp74-common lsphp74-bcmath lsphp74-sodium'
237+
'lsphp74-gmp lsphp74-gd lsphp74-enchant lsphp74-dba lsphp74-common lsphp74-bcmath'
239238

240239
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
241240

@@ -276,13 +275,14 @@ def installMySQL(self, mysql):
276275

277276
self.startMariaDB()
278277

279-
280278
def changeMYSQLRootPassword(self):
281279
if self.remotemysql == 'OFF':
282280
if self.distro == ubuntu:
283-
passwordCMD = "use mysql;DROP DATABASE IF EXISTS test;DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%%';GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '%s';UPDATE user SET plugin='' WHERE User='root';flush privileges;" % (InstallCyberPanel.mysql_Root_password)
281+
passwordCMD = "use mysql;DROP DATABASE IF EXISTS test;DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%%';GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '%s';UPDATE user SET plugin='' WHERE User='root';flush privileges;" % (
282+
InstallCyberPanel.mysql_Root_password)
284283
else:
285-
passwordCMD = "use mysql;DROP DATABASE IF EXISTS test;DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%%';GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '%s';flush privileges;" % (InstallCyberPanel.mysql_Root_password)
284+
passwordCMD = "use mysql;DROP DATABASE IF EXISTS test;DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%%';GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '%s';flush privileges;" % (
285+
InstallCyberPanel.mysql_Root_password)
286286

287287
command = 'mysql -u root -e "' + passwordCMD + '"'
288288

@@ -366,7 +366,6 @@ def installPureFTPD(self):
366366
command = 'dnf install pure-ftpd -y'
367367
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
368368

369-
370369
####### Install pureftpd to system startup
371370

372371
command = "systemctl enable " + install.preFlightsChecks.pureFTPDServiceName(self.distro)
@@ -379,7 +378,7 @@ def installPureFTPD(self):
379378

380379
command = 'useradd -u 2001 -s /bin/false -d /bin/null -c "pureftpd user" -g ftpgroup ftpuser'
381380
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
382-
381+
383382
def startPureFTPD(self):
384383
############## Start pureftpd ######################
385384
if self.distro == ubuntu:
@@ -399,7 +398,8 @@ def installPureFTPDConfigurations(self, mysql):
399398
except:
400399
logging.InstallLog.writeToFile("[ERROR] Could not create directory for FTP SSL")
401400

402-
if (self.distro == centos or self.distro == cent8) or (self.distro == ubuntu and get_Ubuntu_release() == 18.14):
401+
if (self.distro == centos or self.distro == cent8) or (
402+
self.distro == ubuntu and get_Ubuntu_release() == 18.14):
403403
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'
404404
else:
405405
command = 'openssl req -x509 -nodes -days 7300 -newkey rsa:2048 -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'
@@ -417,7 +417,7 @@ def installPureFTPDConfigurations(self, mysql):
417417
shutil.copytree("pure-ftpd-one", ftpdPath)
418418
else:
419419
if mysql == 'Two':
420-
shutil.copytree("pure-ftpd",ftpdPath)
420+
shutil.copytree("pure-ftpd", ftpdPath)
421421
else:
422422
shutil.copytree("pure-ftpd-one", ftpdPath)
423423

@@ -429,18 +429,17 @@ def installPureFTPDConfigurations(self, mysql):
429429
except OSError as err:
430430
self.stdOut("[ERROR] Error creating extra pure-ftpd directories: " + str(err), ". Should be ok", 1)
431431

432-
data = open(ftpdPath+"/pureftpd-mysql.conf","r").readlines()
432+
data = open(ftpdPath + "/pureftpd-mysql.conf", "r").readlines()
433433

434-
writeDataToFile = open(ftpdPath+"/pureftpd-mysql.conf","w")
434+
writeDataToFile = open(ftpdPath + "/pureftpd-mysql.conf", "w")
435435

436-
dataWritten = "MYSQLPassword "+InstallCyberPanel.mysqlPassword+'\n'
436+
dataWritten = "MYSQLPassword " + InstallCyberPanel.mysqlPassword + '\n'
437437
for items in data:
438-
if items.find("MYSQLPassword")>-1:
438+
if items.find("MYSQLPassword") > -1:
439439
writeDataToFile.writelines(dataWritten)
440440
else:
441441
writeDataToFile.writelines(items)
442442

443-
444443
writeDataToFile.close()
445444

446445
ftpConfPath = '/etc/pure-ftpd/pureftpd-mysql.conf'
@@ -459,7 +458,7 @@ def installPureFTPDConfigurations(self, mysql):
459458

460459
if os.path.exists('/etc/pure-ftpd/db/mysql.conf'):
461460
os.remove('/etc/pure-ftpd/db/mysql.conf')
462-
shutil.copy(ftpdPath+"/pureftpd-mysql.conf", '/etc/pure-ftpd/db/mysql.conf')
461+
shutil.copy(ftpdPath + "/pureftpd-mysql.conf", '/etc/pure-ftpd/db/mysql.conf')
463462
else:
464463
shutil.copy(ftpdPath + "/pureftpd-mysql.conf", '/etc/pure-ftpd/db/mysql.conf')
465464

@@ -478,7 +477,6 @@ def installPureFTPDConfigurations(self, mysql):
478477
command = 'echo "/etc/pure-ftpd/db/mysql.conf" > /etc/pure-ftpd/conf/MySQLConfigFile'
479478
subprocess.call(command, shell=True)
480479

481-
482480
command = 'ln -s /etc/pure-ftpd/conf/MySQLConfigFile /etc/pure-ftpd/auth/30mysql'
483481
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
484482

@@ -503,7 +501,6 @@ def installPowerDNS(self):
503501
command = 'systemctl disable systemd-resolved.service'
504502
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
505503

506-
507504
try:
508505
os.rename('/etc/resolv.conf', 'etc/resolved.conf')
509506
except OSError as e:
@@ -513,10 +510,9 @@ def installPowerDNS(self):
513510
try:
514511
os.remove('/etc/resolv.conf')
515512
except OSError as e1:
516-
InstallCyberPanel.stdOut("[ERROR] Unable to remove existing /etc/resolv.conf to install PowerDNS: " +
517-
str(e1), 1, 1, os.EX_OSERR)
518-
519-
513+
InstallCyberPanel.stdOut(
514+
"[ERROR] Unable to remove existing /etc/resolv.conf to install PowerDNS: " +
515+
str(e1), 1, 1, os.EX_OSERR)
520516

521517
# try:
522518
# f = open('/etc/resolv.conf', 'a')
@@ -581,12 +577,11 @@ def installPowerDNSConfigurations(self, mysqlPassword, mysql):
581577
else:
582578
writeDataToFile.writelines(items)
583579

584-
#if self.distro == ubuntu:
580+
# if self.distro == ubuntu:
585581
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
586582

587583
writeDataToFile.close()
588584

589-
590585
if self.remotemysql == 'ON':
591586
command = "sed -i 's|gmysql-host=localhost|gmysql-host=%s|g' %s" % (self.mysqlhost, dnsPath)
592587
install.preFlightsChecks.call(command, self.distro, command, command, 1, 1, os.EX_OSERR)
@@ -612,8 +607,8 @@ def startPowerDNS(self):
612607
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
613608

614609

615-
def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns = None, publicip = None, remotemysql = None , mysqlhost = None, mysqldb = None, mysqluser = None, mysqlpassword = None, mysqlport = None):
616-
610+
def Main(cwd, mysql, distro, ent, serial=None, port="8090", ftp=None, dns=None, publicip=None, remotemysql=None,
611+
mysqlhost=None, mysqldb=None, mysqluser=None, mysqlpassword=None, mysqlport=None):
617612
InstallCyberPanel.mysqlPassword = randomPassword.generate_pass()
618613
InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass()
619614

@@ -629,7 +624,8 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
629624
password.writelines(InstallCyberPanel.mysql_Root_password)
630625
password.close()
631626
else:
632-
mysqlData = {'remotemysql': remotemysql, 'mysqlhost': mysqlhost, 'mysqldb':mysqldb, 'mysqluser': mysqluser, 'mysqlpassword': mysqlpassword, 'mysqlport': mysqlport}
627+
mysqlData = {'remotemysql': remotemysql, 'mysqlhost': mysqlhost, 'mysqldb': mysqldb, 'mysqluser': mysqluser,
628+
'mysqlpassword': mysqlpassword, 'mysqlport': mysqlport}
633629
from json import dumps
634630
writeToFile = open(file_name, 'w')
635631
writeToFile.write(dumps(mysqlData))
@@ -639,8 +635,6 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
639635
print(open(file_name, 'r').read())
640636
time.sleep(10)
641637

642-
643-
644638
try:
645639
command = 'chmod 640 %s' % (file_name)
646640
install.preFlightsChecks.call(command, distro, '[chmod]',
@@ -658,7 +652,8 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
658652
else:
659653
InstallCyberPanel.mysqlPassword = InstallCyberPanel.mysql_Root_password
660654

661-
installer = InstallCyberPanel("/usr/local/lsws/",cwd, distro, ent, serial, port, ftp, dns, publicip, remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport)
655+
installer = InstallCyberPanel("/usr/local/lsws/", cwd, distro, ent, serial, port, ftp, dns, publicip, remotemysql,
656+
mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport)
662657

663658
logging.InstallLog.writeToFile('Installing LiteSpeed Web server,40')
664659
installer.installLiteSpeed()
@@ -679,7 +674,7 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
679674
if distro == ubuntu:
680675
installer.fixMariaDB()
681676

682-
mysqlUtilities.createDatabase("cyberpanel","cyberpanel", InstallCyberPanel.mysqlPassword, publicip)
677+
mysqlUtilities.createDatabase("cyberpanel", "cyberpanel", InstallCyberPanel.mysqlPassword, publicip)
683678

684679
if ftp == None:
685680
installer.installPureFTPD()
@@ -699,4 +694,4 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
699694
if dns == 'ON':
700695
installer.installPowerDNS()
701696
installer.installPowerDNSConfigurations(InstallCyberPanel.mysqlPassword, mysql)
702-
installer.startPowerDNS()
697+
installer.startPowerDNS()

0 commit comments

Comments
 (0)