Merge branch 'v2.1.1' into v2.1.1-usman

This commit is contained in:
Usman Nasir
2021-08-29 19:48:28 +05:00
10 changed files with 87 additions and 43 deletions

View File

@@ -72,7 +72,7 @@ class secMiddleware:
final_json = json.dumps(final_dic) final_json = json.dumps(final_dic)
return HttpResponse(final_json) return HttpResponse(final_json)
if request.build_absolute_uri().find('api/verifyConn') > -1 or request.build_absolute_uri().find('webhook') > -1 or request.build_absolute_uri().find('saveSpamAssassinConfigurations') > -1 or request.build_absolute_uri().find('docker') > -1 or request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('filemanager') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1: if request.build_absolute_uri().find('api/verifyConn') > -1 or request.build_absolute_uri().find('webhook') > -1 or request.build_absolute_uri().find('saveSpamAssassinConfigurations') > -1 or request.build_absolute_uri().find('docker') > -1 or request.build_absolute_uri().find('cloudAPI') > -1 or request.build_absolute_uri().find('verifyLogin') > -1 or request.build_absolute_uri().find('submitUserCreation') > -1:
continue continue
if key == 'recordContentAAAA' or key == 'backupDestinations' or key == 'ports' \ if key == 'recordContentAAAA' or key == 'backupDestinations' or key == 'ports' \
or key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' \ or key == 'imageByPass' or key == 'passwordByPass' or key == 'cronCommand' \

View File

@@ -10,10 +10,11 @@ import install
from os.path import exists from os.path import exists
import time import time
#distros # distros
centos=0 centos = 0
ubuntu=1 ubuntu = 1
cent8=2 cent8 = 2
def get_Ubuntu_release(): def get_Ubuntu_release():
release = -1 release = -1
@@ -34,12 +35,13 @@ def get_Ubuntu_release():
return release return release
class InstallCyberPanel:
class InstallCyberPanel:
mysql_Root_password = "" mysql_Root_password = ""
mysqlPassword = "" mysqlPassword = ""
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): 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):
self.server_root_path = rootPath self.server_root_path = rootPath
self.cwd = cwd self.cwd = cwd
self.distro = distro self.distro = distro
@@ -133,7 +135,7 @@ class InstallCyberPanel:
return 1 return 1
def reStartLiteSpeed(self): def reStartLiteSpeed(self):
command = self.server_root_path+"bin/lswsctrl restart" command = self.server_root_path + "bin/lswsctrl restart"
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
def fix_ols_configs(self): def fix_ols_configs(self):
@@ -143,7 +145,7 @@ class InstallCyberPanel:
## remove example virtual host ## remove example virtual host
data = open(self.server_root_path+"conf/httpd_config.conf",'r').readlines() data = open(self.server_root_path + "conf/httpd_config.conf", 'r').readlines()
writeDataToFile = open(self.server_root_path + "conf/httpd_config.conf", 'w') writeDataToFile = open(self.server_root_path + "conf/httpd_config.conf", 'w')
@@ -166,13 +168,13 @@ class InstallCyberPanel:
try: try:
InstallCyberPanel.stdOut("Changing default port to 80..", 1) InstallCyberPanel.stdOut("Changing default port to 80..", 1)
data = open(self.server_root_path+"conf/httpd_config.conf").readlines() data = open(self.server_root_path + "conf/httpd_config.conf").readlines()
writeDataToFile = open(self.server_root_path+"conf/httpd_config.conf", 'w') writeDataToFile = open(self.server_root_path + "conf/httpd_config.conf", 'w')
for items in data: for items in data:
if (items.find("*:8088") > -1): if (items.find("*:8088") > -1):
writeDataToFile.writelines(items.replace("*:8088","*:80")) writeDataToFile.writelines(items.replace("*:8088", "*:80"))
else: else:
writeDataToFile.writelines(items) writeDataToFile.writelines(items)
@@ -208,7 +210,6 @@ class InstallCyberPanel:
## only php 71 ## only php 71
if self.distro == centos: if self.distro == centos:
command = 'yum install lsphp71 lsphp71-json lsphp71-xmlrpc lsphp71-xml lsphp71-soap lsphp71-snmp ' \ command = 'yum install lsphp71 lsphp71-json lsphp71-xmlrpc lsphp71-xml lsphp71-soap lsphp71-snmp ' \
'lsphp71-recode lsphp71-pspell lsphp71-process lsphp71-pgsql lsphp71-pear lsphp71-pdo lsphp71-opcache ' \ '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-odbc lsphp71-mysqlnd lsphp71-mcrypt lsphp71-mbstring lsphp71-ldap lsphp71-intl lsphp71-imap ' \
@@ -223,7 +224,6 @@ class InstallCyberPanel:
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
## only php 73 ## only php 73
command = 'yum install -y lsphp73 lsphp73-json lsphp73-xmlrpc lsphp73-xml lsphp73-tidy lsphp73-soap lsphp73-snmp ' \ command = 'yum install -y lsphp73 lsphp73-json lsphp73-xmlrpc lsphp73-xml lsphp73-tidy lsphp73-soap lsphp73-snmp ' \
'lsphp73-recode lsphp73-pspell lsphp73-process lsphp73-pgsql lsphp73-pear lsphp73-pdo lsphp73-opcache ' \ 'lsphp73-recode lsphp73-pspell lsphp73-process lsphp73-pgsql lsphp73-pear lsphp73-pdo lsphp73-opcache ' \
@@ -277,13 +277,14 @@ class InstallCyberPanel:
self.startMariaDB() self.startMariaDB()
def changeMYSQLRootPassword(self): def changeMYSQLRootPassword(self):
if self.remotemysql == 'OFF': if self.remotemysql == 'OFF':
if self.distro == ubuntu: if self.distro == ubuntu:
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) 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)
else: else:
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) 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)
command = 'mysql -u root -e "' + passwordCMD + '"' command = 'mysql -u root -e "' + passwordCMD + '"'
@@ -367,7 +368,6 @@ class InstallCyberPanel:
command = 'dnf install pure-ftpd -y' command = 'dnf install pure-ftpd -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)
####### Install pureftpd to system startup ####### Install pureftpd to system startup
command = "systemctl enable " + install.preFlightsChecks.pureFTPDServiceName(self.distro) command = "systemctl enable " + install.preFlightsChecks.pureFTPDServiceName(self.distro)
@@ -400,7 +400,8 @@ class InstallCyberPanel:
except: except:
logging.InstallLog.writeToFile("[ERROR] Could not create directory for FTP SSL") logging.InstallLog.writeToFile("[ERROR] Could not create directory for FTP SSL")
if (self.distro == centos or self.distro == cent8) or (self.distro == ubuntu and get_Ubuntu_release() == 18.14): if (self.distro == centos or self.distro == cent8) or (
self.distro == ubuntu and get_Ubuntu_release() == 18.14):
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'
else: else:
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' 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'
@@ -418,7 +419,7 @@ class InstallCyberPanel:
shutil.copytree("pure-ftpd-one", ftpdPath) shutil.copytree("pure-ftpd-one", ftpdPath)
else: else:
if mysql == 'Two': if mysql == 'Two':
shutil.copytree("pure-ftpd",ftpdPath) shutil.copytree("pure-ftpd", ftpdPath)
else: else:
shutil.copytree("pure-ftpd-one", ftpdPath) shutil.copytree("pure-ftpd-one", ftpdPath)
@@ -430,18 +431,17 @@ class InstallCyberPanel:
except OSError as err: except OSError as err:
self.stdOut("[ERROR] Error creating extra pure-ftpd directories: " + str(err), ". Should be ok", 1) self.stdOut("[ERROR] Error creating extra pure-ftpd directories: " + str(err), ". Should be ok", 1)
data = open(ftpdPath+"/pureftpd-mysql.conf","r").readlines() data = open(ftpdPath + "/pureftpd-mysql.conf", "r").readlines()
writeDataToFile = open(ftpdPath+"/pureftpd-mysql.conf","w") writeDataToFile = open(ftpdPath + "/pureftpd-mysql.conf", "w")
dataWritten = "MYSQLPassword "+InstallCyberPanel.mysqlPassword+'\n' dataWritten = "MYSQLPassword " + InstallCyberPanel.mysqlPassword + '\n'
for items in data: for items in data:
if items.find("MYSQLPassword")>-1: if items.find("MYSQLPassword") > -1:
writeDataToFile.writelines(dataWritten) writeDataToFile.writelines(dataWritten)
else: else:
writeDataToFile.writelines(items) writeDataToFile.writelines(items)
writeDataToFile.close() writeDataToFile.close()
ftpConfPath = '/etc/pure-ftpd/pureftpd-mysql.conf' ftpConfPath = '/etc/pure-ftpd/pureftpd-mysql.conf'
@@ -460,7 +460,7 @@ class InstallCyberPanel:
if os.path.exists('/etc/pure-ftpd/db/mysql.conf'): if os.path.exists('/etc/pure-ftpd/db/mysql.conf'):
os.remove('/etc/pure-ftpd/db/mysql.conf') os.remove('/etc/pure-ftpd/db/mysql.conf')
shutil.copy(ftpdPath+"/pureftpd-mysql.conf", '/etc/pure-ftpd/db/mysql.conf') shutil.copy(ftpdPath + "/pureftpd-mysql.conf", '/etc/pure-ftpd/db/mysql.conf')
else: else:
shutil.copy(ftpdPath + "/pureftpd-mysql.conf", '/etc/pure-ftpd/db/mysql.conf') shutil.copy(ftpdPath + "/pureftpd-mysql.conf", '/etc/pure-ftpd/db/mysql.conf')
@@ -479,7 +479,6 @@ class InstallCyberPanel:
command = 'echo "/etc/pure-ftpd/db/mysql.conf" > /etc/pure-ftpd/conf/MySQLConfigFile' command = 'echo "/etc/pure-ftpd/db/mysql.conf" > /etc/pure-ftpd/conf/MySQLConfigFile'
subprocess.call(command, shell=True) subprocess.call(command, shell=True)
command = 'ln -s /etc/pure-ftpd/conf/MySQLConfigFile /etc/pure-ftpd/auth/30mysql' command = 'ln -s /etc/pure-ftpd/conf/MySQLConfigFile /etc/pure-ftpd/auth/30mysql'
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)
@@ -504,7 +503,6 @@ class InstallCyberPanel:
command = 'systemctl disable systemd-resolved.service' command = 'systemctl disable systemd-resolved.service'
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
try: try:
os.rename('/etc/resolv.conf', 'etc/resolved.conf') os.rename('/etc/resolv.conf', 'etc/resolved.conf')
except OSError as e: except OSError as e:
@@ -514,11 +512,10 @@ class InstallCyberPanel:
try: try:
os.remove('/etc/resolv.conf') os.remove('/etc/resolv.conf')
except OSError as e1: except OSError as e1:
InstallCyberPanel.stdOut("[ERROR] Unable to remove existing /etc/resolv.conf to install PowerDNS: " + InstallCyberPanel.stdOut(
"[ERROR] Unable to remove existing /etc/resolv.conf to install PowerDNS: " +
str(e1), 1, 1, os.EX_OSERR) str(e1), 1, 1, os.EX_OSERR)
# try: # try:
# f = open('/etc/resolv.conf', 'a') # f = open('/etc/resolv.conf', 'a')
# f.write('nameserver 8.8.8.8') # f.write('nameserver 8.8.8.8')
@@ -582,12 +579,11 @@ class InstallCyberPanel:
else: else:
writeDataToFile.writelines(items) writeDataToFile.writelines(items)
#if self.distro == ubuntu: # if self.distro == ubuntu:
# os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR) # os.fchmod(writeDataToFile.fileno(), stat.S_IRUSR | stat.S_IWUSR)
writeDataToFile.close() writeDataToFile.close()
if self.remotemysql == 'ON': if self.remotemysql == 'ON':
command = "sed -i 's|gmysql-host=localhost|gmysql-host=%s|g' %s" % (self.mysqlhost, dnsPath) command = "sed -i 's|gmysql-host=localhost|gmysql-host=%s|g' %s" % (self.mysqlhost, dnsPath)
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)
@@ -613,8 +609,8 @@ class InstallCyberPanel:
install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) install.preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR)
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): 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):
InstallCyberPanel.mysqlPassword = randomPassword.generate_pass() InstallCyberPanel.mysqlPassword = randomPassword.generate_pass()
InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass() InstallCyberPanel.mysql_Root_password = randomPassword.generate_pass()
@@ -630,7 +626,8 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
password.writelines(InstallCyberPanel.mysql_Root_password) password.writelines(InstallCyberPanel.mysql_Root_password)
password.close() password.close()
else: else:
mysqlData = {'remotemysql': remotemysql, 'mysqlhost': mysqlhost, 'mysqldb':mysqldb, 'mysqluser': mysqluser, 'mysqlpassword': mysqlpassword, 'mysqlport': mysqlport} mysqlData = {'remotemysql': remotemysql, 'mysqlhost': mysqlhost, 'mysqldb': mysqldb, 'mysqluser': mysqluser,
'mysqlpassword': mysqlpassword, 'mysqlport': mysqlport}
from json import dumps from json import dumps
writeToFile = open(file_name, 'w') writeToFile = open(file_name, 'w')
writeToFile.write(dumps(mysqlData)) writeToFile.write(dumps(mysqlData))
@@ -640,8 +637,6 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
print(open(file_name, 'r').read()) print(open(file_name, 'r').read())
time.sleep(10) time.sleep(10)
try: try:
command = 'chmod 640 %s' % (file_name) command = 'chmod 640 %s' % (file_name)
install.preFlightsChecks.call(command, distro, '[chmod]', install.preFlightsChecks.call(command, distro, '[chmod]',
@@ -659,7 +654,8 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
else: else:
InstallCyberPanel.mysqlPassword = InstallCyberPanel.mysql_Root_password InstallCyberPanel.mysqlPassword = InstallCyberPanel.mysql_Root_password
installer = InstallCyberPanel("/usr/local/lsws/",cwd, distro, ent, serial, port, ftp, dns, publicip, remotemysql, mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport) installer = InstallCyberPanel("/usr/local/lsws/", cwd, distro, ent, serial, port, ftp, dns, publicip, remotemysql,
mysqlhost, mysqldb, mysqluser, mysqlpassword, mysqlport)
logging.InstallLog.writeToFile('Installing LiteSpeed Web server,40') logging.InstallLog.writeToFile('Installing LiteSpeed Web server,40')
installer.installLiteSpeed() installer.installLiteSpeed()
@@ -680,7 +676,7 @@ def Main(cwd, mysql, distro, ent, serial = None, port = "8090", ftp = None, dns
if distro == ubuntu: if distro == ubuntu:
installer.fixMariaDB() installer.fixMariaDB()
mysqlUtilities.createDatabase("cyberpanel","cyberpanel", InstallCyberPanel.mysqlPassword, publicip) mysqlUtilities.createDatabase("cyberpanel", "cyberpanel", InstallCyberPanel.mysqlPassword, publicip)
if ftp == None: if ftp == None:
installer.installPureFTPD() installer.installPureFTPD()

View File

@@ -272,4 +272,10 @@
<status>0</status> <status>0</status>
</extension> </extension>
<extension>
<extensionName>lsphp72-sodium</extensionName>
<extensionDescription>The php-sodium extension provides strong encryption capabilities in an easy and consistent way.</extensionDescription>
<status>0</status>
</extension>
</php> </php>

View File

@@ -272,4 +272,10 @@
<status>0</status> <status>0</status>
</extension> </extension>
<extension>
<extensionName>lsphp73-sodium</extensionName>
<extensionDescription>The php-sodium extension provides strong encryption capabilities in an easy and consistent way.</extensionDescription>
<status>0</status>
</extension>
</php> </php>

View File

@@ -272,4 +272,10 @@
<status>0</status> <status>0</status>
</extension> </extension>
<extension>
<extensionName>lsphp74-sodium</extensionName>
<extensionDescription>The php-sodium extension provides strong encryption capabilities in an easy and consistent way.</extensionDescription>
<status>0</status>
</extension>
</php> </php>

View File

@@ -272,4 +272,10 @@
<status>0</status> <status>0</status>
</extension> </extension>
<extension>
<extensionName>lsphp80-sodium</extensionName>
<extensionDescription>The php-sodium extension provides strong encryption capabilities in an easy and consistent way.</extensionDescription>
<status>0</status>
</extension>
</php> </php>

View File

@@ -122,4 +122,10 @@
<status>0</status> <status>0</status>
</extension> </extension>
<extension>
<extensionName>lsphp72-sodium</extensionName>
<extensionDescription>The php-sodium extension provides strong encryption capabilities in an easy and consistent way.</extensionDescription>
<status>0</status>
</extension>
</php> </php>

View File

@@ -122,4 +122,10 @@
<status>0</status> <status>0</status>
</extension> </extension>
<extension>
<extensionName>lsphp73-sodium</extensionName>
<extensionDescription>The php-sodium extension provides strong encryption capabilities in an easy and consistent way.</extensionDescription>
<status>0</status>
</extension>
</php> </php>

View File

@@ -122,4 +122,10 @@
<status>0</status> <status>0</status>
</extension> </extension>
<extension>
<extensionName>lsphp74-sodium</extensionName>
<extensionDescription>The php-sodium extension provides strong encryption capabilities in an easy and consistent way.</extensionDescription>
<status>0</status>
</extension>
</php> </php>

View File

@@ -122,4 +122,10 @@
<status>0</status> <status>0</status>
</extension> </extension>
<extension>
<extensionName>lsphp80-sodium</extensionName>
<extensionDescription>The php-sodium extension provides strong encryption capabilities in an easy and consistent way.</extensionDescription>
<status>0</status>
</extension>
</php> </php>