2017-10-24 19:16:36 +05:00
import os
2018-07-19 22:38:37 +05:00
import os . path
import sys
2020-01-02 14:32:02 +05:00
import argparse
2021-10-17 22:06:33 +06:00
import pwd
import grp
2021-02-21 13:09:50 +05:00
2018-07-19 22:38:37 +05:00
sys . path . append ( ' /usr/local/CyberCP ' )
os . environ . setdefault ( " DJANGO_SETTINGS_MODULE " , " CyberCP.settings " )
2017-10-24 19:16:36 +05:00
import shlex
import subprocess
2018-04-23 19:23:03 +05:00
import shutil
2018-05-14 22:26:25 +05:00
import time
2018-12-14 05:01:10 +05:00
import MySQLdb as mysql
2018-12-20 16:18:16 +05:00
from CyberCP import settings
2019-04-15 15:54:23 +05:00
import random
import string
2017-10-24 19:16:36 +05:00
2022-04-24 22:41:34 +05:00
VERSION = ' 2.3 '
2023-01-23 11:36:41 +05:00
BUILD = 3
2019-06-08 21:41:43 +00:00
2020-06-10 22:35:52 +05:00
CENTOS7 = 0
CENTOS8 = 1
2021-02-21 16:10:33 +05:00
Ubuntu18 = 2
Ubuntu20 = 3
CloudLinux7 = 4
CloudLinux8 = 5
2022-06-25 02:14:01 +08:00
openEuler20 = 6
openEuler22 = 7
2022-09-25 12:39:47 +05:00
Ubuntu22 = 8
2020-06-10 22:35:52 +05:00
2021-02-21 13:09:50 +05:00
2017-10-24 19:16:36 +05:00
class Upgrade :
logPath = " /usr/local/lscp/logs/upgradeLog "
2019-12-27 20:07:27 +05:00
cdn = ' cdn.cyberpanel.sh '
2020-04-11 11:31:13 +05:00
installedOutput = ' '
CentOSPath = ' /etc/redhat-release '
2021-02-21 16:10:33 +05:00
UbuntuPath = ' /etc/lsb-release '
2022-06-25 02:14:01 +08:00
openEulerPath = ' /etc/openEuler-release '
2021-03-22 22:01:26 +05:00
FromCloud = 0
2023-02-03 20:26:24 +05:00
SnappyVersion = ' 2.25.3 '
2017-10-24 19:16:36 +05:00
2021-02-21 13:09:50 +05:00
AdminACL = ' { " adminStatus " :1, " versionManagement " : 1, " createNewUser " : 1, " listUsers " : 1, " deleteUser " :1 , " resellerCenter " : 1, ' \
' " changeUserACL " : 1, " createWebsite " : 1, " modifyWebsite " : 1, " suspendWebsite " : 1, " deleteWebsite " : 1, ' \
' " createPackage " : 1, " listPackages " : 1, " deletePackage " : 1, " modifyPackage " : 1, " createDatabase " : 1, " deleteDatabase " : 1, ' \
' " listDatabases " : 1, " createNameServer " : 1, " createDNSZone " : 1, " deleteZone " : 1, " addDeleteRecords " : 1, ' \
' " createEmail " : 1, " listEmails " : 1, " deleteEmail " : 1, " emailForwarding " : 1, " changeEmailPassword " : 1, ' \
' " dkimManager " : 1, " createFTPAccount " : 1, " deleteFTPAccount " : 1, " listFTPAccounts " : 1, " createBackup " : 1, ' \
2021-04-15 19:47:12 -04:00
' " restoreBackup " : 1, " addDeleteDestinations " : 1, " scheduleBackups " : 1, " remoteBackups " : 1, " googleDriveBackups " : 1, " manageSSL " : 1, ' \
2021-02-21 13:09:50 +05:00
' " hostnameSSL " : 1, " mailServerSSL " : 1 } '
ResellerACL = ' { " adminStatus " :0, " versionManagement " : 1, " createNewUser " : 1, " listUsers " : 1, " deleteUser " : 1 , " resellerCenter " : 1, ' \
' " changeUserACL " : 0, " createWebsite " : 1, " modifyWebsite " : 1, " suspendWebsite " : 1, " deleteWebsite " : 1, ' \
' " createPackage " : 1, " listPackages " : 1, " deletePackage " : 1, " modifyPackage " : 1, " createDatabase " : 1, " deleteDatabase " : 1, ' \
' " listDatabases " : 1, " createNameServer " : 1, " createDNSZone " : 1, " deleteZone " : 1, " addDeleteRecords " : 1, ' \
' " createEmail " : 1, " listEmails " : 1, " deleteEmail " : 1, " emailForwarding " : 1, " changeEmailPassword " : 1, ' \
' " dkimManager " : 1, " createFTPAccount " : 1, " deleteFTPAccount " : 1, " listFTPAccounts " : 1, " createBackup " : 1, ' \
2021-04-15 19:47:12 -04:00
' " restoreBackup " : 1, " addDeleteDestinations " : 0, " scheduleBackups " : 0, " remoteBackups " : 0, " googleDriveBackups " : 1, " manageSSL " : 1, ' \
2021-02-21 13:09:50 +05:00
' " hostnameSSL " : 0, " mailServerSSL " : 0 } '
UserACL = ' { " adminStatus " :0, " versionManagement " : 1, " createNewUser " : 0, " listUsers " : 0, " deleteUser " : 0 , " resellerCenter " : 0, ' \
' " changeUserACL " : 0, " createWebsite " : 0, " modifyWebsite " : 0, " suspendWebsite " : 0, " deleteWebsite " : 0, ' \
' " createPackage " : 0, " listPackages " : 0, " deletePackage " : 0, " modifyPackage " : 0, " createDatabase " : 1, " deleteDatabase " : 1, ' \
' " listDatabases " : 1, " createNameServer " : 0, " createDNSZone " : 1, " deleteZone " : 1, " addDeleteRecords " : 1, ' \
' " createEmail " : 1, " listEmails " : 1, " deleteEmail " : 1, " emailForwarding " : 1, " changeEmailPassword " : 1, ' \
' " dkimManager " : 1, " createFTPAccount " : 1, " deleteFTPAccount " : 1, " listFTPAccounts " : 1, " createBackup " : 1, ' \
2021-04-15 19:47:12 -04:00
' " restoreBackup " : 0, " addDeleteDestinations " : 0, " scheduleBackups " : 0, " remoteBackups " : 0, " googleDriveBackups " : 1, " manageSSL " : 1, ' \
2021-02-21 13:09:50 +05:00
' " hostnameSSL " : 0, " mailServerSSL " : 0 } '
2020-06-10 22:35:52 +05:00
@staticmethod
def decideCentosVersion ( ) :
if open ( Upgrade . CentOSPath , ' r ' ) . read ( ) . find ( ' CentOS Linux release 8 ' ) > - 1 :
return CENTOS8
else :
return CENTOS7
2021-02-21 16:10:33 +05:00
@staticmethod
def FindOperatingSytem ( ) :
if os . path . exists ( Upgrade . CentOSPath ) :
result = open ( Upgrade . CentOSPath , ' r ' ) . read ( )
if result . find ( ' CentOS Linux release 8 ' ) > - 1 or result . find ( ' CloudLinux release 8 ' ) > - 1 :
return CENTOS8
else :
return CENTOS7
2022-06-25 02:14:01 +08:00
elif os . path . exists ( Upgrade . openEulerPath ) :
result = open ( Upgrade . openEulerPath , ' r ' ) . read ( )
if result . find ( ' 20.03 ' ) > - 1 :
return openEuler20
elif result . find ( ' 22.03 ' ) > - 1 :
return openEuler22
2021-02-21 16:10:33 +05:00
else :
result = open ( Upgrade . UbuntuPath , ' r ' ) . read ( )
if result . find ( ' 20.04 ' ) > - 1 :
return Ubuntu20
2022-09-25 12:39:47 +05:00
elif result . find ( ' 22.04 ' ) > - 1 :
return Ubuntu22
2021-02-21 16:10:33 +05:00
else :
return Ubuntu18
2018-07-19 22:38:37 +05:00
@staticmethod
2019-06-08 21:41:43 +00:00
def stdOut ( message , do_exit = 0 ) :
2018-07-19 22:38:37 +05:00
print ( " \n \n " )
2019-12-10 15:09:10 +05:00
print ( ( " [ " + time . strftime (
" % m. %d . % Y_ % H- % M- % S " ) + " ] ######################################################################### \n " ) )
print ( ( " [ " + time . strftime ( " % m. %d . % Y_ % H- % M- % S " ) + " ] " + message + " \n " ) )
print ( ( " [ " + time . strftime (
" % m. %d . % Y_ % H- % M- % S " ) + " ] ######################################################################### \n " ) )
2018-07-19 22:38:37 +05:00
2018-12-14 05:01:10 +05:00
if do_exit :
2021-03-22 22:01:26 +05:00
if Upgrade . FromCloud == 0 :
os . _exit ( 0 )
2018-12-14 05:01:10 +05:00
2018-11-14 13:36:34 +05:00
@staticmethod
2022-09-10 23:32:28 +05:00
def executioner ( command , component , do_exit = 0 , shell = False ) :
2018-11-14 13:36:34 +05:00
try :
2021-03-18 15:18:56 +05:00
FNULL = open ( os . devnull , ' w ' )
2018-12-14 05:01:10 +05:00
count = 0
while True :
2022-09-10 23:32:28 +05:00
if shell == False :
res = subprocess . call ( shlex . split ( command ) , stderr = subprocess . STDOUT )
else :
res = subprocess . call ( command , stderr = subprocess . STDOUT , shell = True )
2018-12-14 05:01:10 +05:00
if res != 0 :
count = count + 1
Upgrade . stdOut ( component + ' failed, trying again, try number: ' + str ( count ) , 0 )
if count == 3 :
Upgrade . stdOut ( component + ' failed. ' , do_exit )
return False
else :
Upgrade . stdOut ( component + ' successful. ' , 0 )
break
return True
2018-11-14 13:36:34 +05:00
except :
2021-03-24 12:31:56 +05:00
return False
2018-11-14 13:36:34 +05:00
2019-11-25 18:00:31 +05:00
@staticmethod
def updateRepoURL ( ) :
command = " sed -i ' s|sgp.cyberpanel.sh|cdn.cyberpanel.sh|g ' /etc/yum.repos.d/MariaDB.repo "
Upgrade . executioner ( command , command , 0 )
command = " sed -i ' s|lax.cyberpanel.sh|cdn.cyberpanel.sh|g ' /etc/yum.repos.d/MariaDB.repo "
Upgrade . executioner ( command , command , 0 )
command = " sed -i ' s|fra.cyberpanel.sh|cdn.cyberpanel.sh|g ' /etc/yum.repos.d/MariaDB.repo "
Upgrade . executioner ( command , command , 0 )
command = " sed -i ' s|mirror.cyberpanel.net|cdn.cyberpanel.sh|g ' /etc/yum.repos.d/MariaDB.repo "
Upgrade . executioner ( command , command , 0 )
command = " sed -i ' s|sgp.cyberpanel.sh|cdn.cyberpanel.sh|g ' /etc/yum.repos.d/litespeed.repo "
Upgrade . executioner ( command , command , 0 )
command = " sed -i ' s|lax.cyberpanel.sh|cdn.cyberpanel.sh|g ' /etc/yum.repos.d/litespeed.repo "
Upgrade . executioner ( command , command , 0 )
command = " sed -i ' s|fra.cyberpanel.sh|cdn.cyberpanel.sh|g ' /etc/yum.repos.d/litespeed.repo "
Upgrade . executioner ( command , command , 0 )
command = " sed -i ' s|mirror.cyberpanel.net|cdn.cyberpanel.sh|g ' /etc/yum.repos.d/litespeed.repo "
Upgrade . executioner ( command , command , 0 )
2019-04-15 15:54:23 +05:00
@staticmethod
def mountTemp ( ) :
try :
if os . path . exists ( " /usr/.tempdisk " ) :
return 0
command = " dd if=/dev/zero of=/usr/.tempdisk bs=100M count=15 "
Upgrade . executioner ( command , ' mountTemp ' , 0 )
command = " mkfs.ext4 -F /usr/.tempdisk "
Upgrade . executioner ( command , ' mountTemp ' , 0 )
command = " mkdir -p /usr/.tmpbak/ "
Upgrade . executioner ( command , ' mountTemp ' , 0 )
command = " cp -pr /tmp/* /usr/.tmpbak/ "
subprocess . call ( command , shell = True )
command = " mount -o loop,rw,nodev,nosuid,noexec,nofail /usr/.tempdisk /tmp "
Upgrade . executioner ( command , ' mountTemp ' , 0 )
command = " chmod 1777 /tmp "
Upgrade . executioner ( command , ' mountTemp ' , 0 )
command = " cp -pr /usr/.tmpbak/* /tmp/ "
subprocess . call ( command , shell = True )
command = " rm -rf /usr/.tmpbak "
Upgrade . executioner ( command , ' mountTemp ' , 0 )
command = " mount --bind /tmp /var/tmp "
Upgrade . executioner ( command , ' mountTemp ' , 0 )
tmp = " /usr/.tempdisk /tmp ext4 loop,rw,noexec,nosuid,nodev,nofail 0 0 \n "
varTmp = " /tmp /var/tmp none bind 0 0 \n "
fstab = " /etc/fstab "
writeToFile = open ( fstab , " a " )
writeToFile . writelines ( tmp )
writeToFile . writelines ( varTmp )
writeToFile . close ( )
2019-12-10 15:09:10 +05:00
except BaseException as msg :
2019-04-15 15:54:23 +05:00
Upgrade . stdOut ( str ( msg ) + " [mountTemp] " , 0 )
@staticmethod
def dockerUsers ( ) :
### Docker User/group
2021-10-17 22:06:33 +06:00
try :
pwd . getpwnam ( ' docker ' )
except KeyError :
command = " adduser docker "
Upgrade . executioner ( command , ' adduser docker ' , 0 )
2019-04-15 15:54:23 +05:00
2021-10-17 22:06:33 +06:00
try :
grp . getgrnam ( ' docker ' )
except KeyError :
command = ' groupadd docker '
Upgrade . executioner ( command , ' adduser docker ' , 0 )
2019-04-15 15:54:23 +05:00
command = ' usermod -aG docker docker '
Upgrade . executioner ( command , ' adduser docker ' , 0 )
command = ' usermod -aG docker cyberpanel '
Upgrade . executioner ( command , ' adduser docker ' , 0 )
###
@staticmethod
def fixSudoers ( ) :
try :
distroPath = ' /etc/lsb-release '
if os . path . exists ( distroPath ) :
fileName = ' /etc/sudoers '
data = open ( fileName , ' r ' ) . readlines ( )
writeDataToFile = open ( fileName , ' w ' )
for line in data :
if line . find ( " %s udo ALL=(ALL:ALL) " ) > - 1 :
continue
else :
writeDataToFile . write ( line )
writeDataToFile . close ( )
else :
try :
path = " /etc/sudoers "
data = open ( path , ' r ' ) . readlines ( )
writeToFile = open ( path , ' w ' )
for items in data :
if items . find ( " wheel " ) > - 1 and items . find ( " ALL=(ALL) " ) :
continue
2022-06-10 12:37:21 +05:00
elif items . find ( " root " ) > - 1 and items . find ( " ALL=(ALL) " ) > - 1 and items [ 0 ] != ' # ' :
writeToFile . writelines ( ' root ALL=(ALL:ALL) ALL \n ' )
2019-04-15 15:54:23 +05:00
else :
writeToFile . writelines ( items )
writeToFile . close ( )
except :
pass
command = " chsh -s /bin/false cyberpanel "
Upgrade . executioner ( command , 0 )
except IOError as err :
pass
@staticmethod
def download_install_phpmyadmin ( ) :
try :
cwd = os . getcwd ( )
if not os . path . exists ( " /usr/local/CyberCP/public " ) :
os . mkdir ( " /usr/local/CyberCP/public " )
try :
shutil . rmtree ( " /usr/local/CyberCP/public/phpmyadmin " )
except :
pass
2021-11-02 14:20:27 +05:00
command = ' wget -O /usr/local/CyberCP/public/phpmyadmin.zip https://github.com/usmannasir/cyberpanel/raw/stable/phpmyadmin.zip '
2019-12-27 20:07:27 +05:00
Upgrade . executioner ( command , 0 )
2022-06-23 22:54:58 +05:00
command = ' unzip /usr/local/CyberCP/public/phpmyadmin.zip -d /usr/local/CyberCP/public/phpmyadmin '
2019-12-27 20:07:27 +05:00
Upgrade . executioner ( command , 0 )
2020-03-26 13:36:24 +01:00
command = ' mv /usr/local/CyberCP/public/phpMyAdmin-*-all-languages /usr/local/CyberCP/public/phpmyadmin '
2020-03-27 11:26:37 +05:00
subprocess . call ( command , shell = True )
2019-04-15 15:54:23 +05:00
2019-12-27 20:07:27 +05:00
command = ' rm -f /usr/local/CyberCP/public/phpmyadmin.zip '
2019-04-15 15:54:23 +05:00
Upgrade . executioner ( command , 0 )
## Write secret phrase
2019-12-10 15:09:10 +05:00
rString = ' ' . join ( [ random . choice ( string . ascii_letters + string . digits ) for n in range ( 32 ) ] )
2019-04-15 15:54:23 +05:00
2019-12-27 21:41:07 +05:00
data = open ( ' /usr/local/CyberCP/public/phpmyadmin/config.sample.inc.php ' , ' r ' ) . readlines ( )
2019-04-15 15:54:23 +05:00
2019-12-27 21:41:07 +05:00
writeToFile = open ( ' /usr/local/CyberCP/public/phpmyadmin/config.inc.php ' , ' w ' )
2019-04-15 15:54:23 +05:00
2020-08-10 11:40:00 +05:00
writeE = 1
phpMyAdminContent = """
$ cfg [ ' Servers ' ] [ $ i ] [ ' AllowNoPassword ' ] = false ;
$ cfg [ ' Servers ' ] [ $ i ] [ ' auth_type ' ] = ' signon ' ;
$ cfg [ ' Servers ' ] [ $ i ] [ ' SignonSession ' ] = ' SignonSession ' ;
$ cfg [ ' Servers ' ] [ $ i ] [ ' SignonURL ' ] = ' phpmyadminsignin.php ' ;
2020-08-13 11:09:43 +05:00
$ cfg [ ' Servers ' ] [ $ i ] [ ' LogoutURL ' ] = ' phpmyadminsignin.php?logout ' ;
2020-08-10 11:40:00 +05:00
"""
2019-04-15 15:54:23 +05:00
for items in data :
if items . find ( ' blowfish_secret ' ) > - 1 :
writeToFile . writelines (
" $cfg[ ' blowfish_secret ' ] = ' " + rString + " ' ; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ \n " )
2020-08-13 11:25:19 +05:00
elif items . find ( ' /* Authentication type */ ' ) > - 1 :
2019-04-15 15:54:23 +05:00
writeToFile . writelines ( items )
2020-08-10 11:40:00 +05:00
writeToFile . write ( phpMyAdminContent )
writeE = 0
2020-08-13 11:25:19 +05:00
elif items . find ( " $cfg[ ' Servers ' ][$i][ ' AllowNoPassword ' ] " ) > - 1 :
2020-08-10 11:40:00 +05:00
writeE = 1
else :
if writeE :
writeToFile . writelines ( items )
2019-04-15 15:54:23 +05:00
writeToFile . writelines ( " $cfg[ ' TempDir ' ] = ' /usr/local/CyberCP/public/phpmyadmin/tmp ' ; \n " )
writeToFile . close ( )
os . mkdir ( ' /usr/local/CyberCP/public/phpmyadmin/tmp ' )
2020-08-09 12:45:18 +05:00
command = ' cp /usr/local/CyberCP/plogical/phpmyadminsignin.php /usr/local/CyberCP/public/phpmyadmin/phpmyadminsignin.php '
Upgrade . executioner ( command , 0 )
2020-10-09 19:42:36 +05:00
passFile = " /etc/cyberpanel/mysqlPassword "
try :
import json
jsonData = json . loads ( open ( passFile , ' r ' ) . read ( ) )
mysqluser = jsonData [ ' mysqluser ' ]
mysqlpassword = jsonData [ ' mysqlpassword ' ]
mysqlport = jsonData [ ' mysqlport ' ]
mysqlhost = jsonData [ ' mysqlhost ' ]
command = " sed -i ' s|localhost| %s |g ' /usr/local/CyberCP/public/phpmyadmin/phpmyadminsignin.php " % (
mysqlhost )
Upgrade . executioner ( command , 0 )
except :
pass
2019-04-15 15:54:23 +05:00
os . chdir ( cwd )
2019-12-10 15:09:10 +05:00
except BaseException as msg :
2019-04-15 15:54:23 +05:00
Upgrade . stdOut ( str ( msg ) + " [download_install_phpmyadmin] " , 0 )
@staticmethod
def setupComposer ( ) :
2020-01-02 15:01:20 +05:00
if os . path . exists ( ' composer.sh ' ) :
os . remove ( ' composer.sh ' )
2019-04-15 15:54:23 +05:00
command = " wget https://cyberpanel.sh/composer.sh "
Upgrade . executioner ( command , 0 )
command = " chmod +x composer.sh "
Upgrade . executioner ( command , 0 )
command = " ./composer.sh "
Upgrade . executioner ( command , 0 )
@staticmethod
def downoad_and_install_raindloop ( ) :
try :
#######
2022-05-21 11:16:58 +05:00
# if os.path.exists("/usr/local/CyberCP/public/rainloop"):
#
# if os.path.exists("/usr/local/lscp/cyberpanel/rainloop/data"):
# pass
# else:
# command = "mv /usr/local/CyberCP/public/rainloop/data /usr/local/lscp/cyberpanel/rainloop/data"
# Upgrade.executioner(command, 0)
#
# command = "chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop/data"
# Upgrade.executioner(command, 0)
#
# iPath = os.listdir('/usr/local/CyberCP/public/rainloop/rainloop/v/')
#
# path = "/usr/local/CyberCP/public/snappymail/snappymail/v/%s/include.php" % (iPath[0])
#
# data = open(path, 'r').readlines()
# writeToFile = open(path, 'w')
#
# for items in data:
# if items.find("$sCustomDataPath = '';") > -1:
# writeToFile.writelines(
# " $sCustomDataPath = '/usr/local/lscp/cyberpanel/rainloop/data';\n")
# else:
# writeToFile.writelines(items)
#
# writeToFile.close()
# return 0
2019-04-15 15:54:23 +05:00
cwd = os . getcwd ( )
if not os . path . exists ( " /usr/local/CyberCP/public " ) :
os . mkdir ( " /usr/local/CyberCP/public " )
os . chdir ( " /usr/local/CyberCP/public " )
count = 1
while ( 1 ) :
2022-05-17 13:38:25 +05:00
command = ' wget https://github.com/the-djmaze/snappymail/releases/download/v %s /snappymail- %s .zip ' % ( Upgrade . SnappyVersion , Upgrade . SnappyVersion )
2019-04-15 15:54:23 +05:00
cmd = shlex . split ( command )
res = subprocess . call ( cmd )
if res != 0 :
count = count + 1
if count == 3 :
break
else :
break
#############
count = 0
2022-05-17 12:47:27 +05:00
if os . path . exists ( ' /usr/local/CyberCP/public/snappymail ' ) :
shutil . rmtree ( ' /usr/local/CyberCP/public/snappymail ' )
2019-04-15 15:54:23 +05:00
while ( 1 ) :
2022-05-17 13:38:25 +05:00
command = ' unzip snappymail- %s .zip -d /usr/local/CyberCP/public/snappymail ' % ( Upgrade . SnappyVersion )
2019-04-15 15:54:23 +05:00
cmd = shlex . split ( command )
res = subprocess . call ( cmd )
if res != 0 :
count = count + 1
if count == 3 :
break
else :
break
2022-05-17 11:36:48 +05:00
try :
2022-05-17 13:38:25 +05:00
os . remove ( " snappymail- %s .zip " % ( Upgrade . SnappyVersion ) )
2022-05-17 11:36:48 +05:00
except :
pass
2019-04-15 15:54:23 +05:00
#######
2022-04-29 00:27:41 +02:00
os . chdir ( " /usr/local/CyberCP/public/snappymail " )
2019-04-15 15:54:23 +05:00
count = 0
while ( 1 ) :
command = ' find . -type d -exec chmod 755 {} \ ; '
cmd = shlex . split ( command )
res = subprocess . call ( cmd )
if res != 0 :
count = count + 1
if count == 3 :
break
else :
break
#############
count = 0
while ( 1 ) :
command = ' find . -type f -exec chmod 644 {} \ ; '
cmd = shlex . split ( command )
res = subprocess . call ( cmd )
if res != 0 :
count = count + 1
if count == 3 :
break
2021-05-26 15:42:26 +05:00
else :
break
2019-04-15 15:54:23 +05:00
######
2022-04-29 00:27:41 +02:00
iPath = os . listdir ( ' /usr/local/CyberCP/public/snappymail/snappymail/v/ ' )
2019-08-27 14:40:02 +05:00
2022-04-29 00:27:41 +02:00
path = " /usr/local/CyberCP/public/snappymail/snappymail/v/ %s /include.php " % ( iPath [ 0 ] )
2019-04-15 15:54:23 +05:00
data = open ( path , ' r ' ) . readlines ( )
writeToFile = open ( path , ' w ' )
for items in data :
if items . find ( " $sCustomDataPath = ' ' ; " ) > - 1 :
writeToFile . writelines (
2022-05-17 16:50:28 +05:00
" $sCustomDataPath = ' /usr/local/lscp/cyberpanel/rainloop/data ' ; \n " )
2019-04-15 15:54:23 +05:00
else :
writeToFile . writelines ( items )
2019-08-27 14:40:02 +05:00
writeToFile . close ( )
2022-05-17 16:50:28 +05:00
command = " mkdir -p /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/configs/ "
2022-04-29 00:27:41 +02:00
Upgrade . executioner ( command , ' mkdir snappymail configs ' , 0 )
2019-09-02 15:09:17 +05:00
2022-05-17 16:50:28 +05:00
labsPath = ' /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/configs/application.ini '
2019-09-02 15:09:17 +05:00
2023-02-03 19:55:23 +05:00
# labsData = """[labs]
# imap_folder_list_limit = 0
# autocreate_system_folders = On
# """
#
# writeToFile = open(labsPath, 'a')
# writeToFile.write(labsData)
# writeToFile.close()
2019-09-02 15:09:17 +05:00
2022-05-20 15:54:07 +05:00
includeFileOldPath = ' /usr/local/CyberCP/public/snappymail/_include.php '
includeFileNewPath = ' /usr/local/CyberCP/public/snappymail/include.php '
if os . path . exists ( includeFileOldPath ) :
writeToFile = open ( includeFileOldPath , ' a ' )
writeToFile . write ( " \n define( ' APP_DATA_FOLDER_PATH ' , ' /usr/local/lscp/cyberpanel/rainloop/data/ ' ); \n " )
writeToFile . close ( )
command = ' mv %s %s ' % ( includeFileOldPath , includeFileNewPath )
Upgrade . executioner ( command , ' mkdir snappymail configs ' , 0 )
2023-02-03 19:55:23 +05:00
## take care of auto create folders
2023-02-04 10:44:54 +05:00
# labsData = open(labsPath, 'r').read()
# labsDataLines = open(labsPath, 'r').readlines()
#
# if labsData.find('autocreate_system_folders') > -1:
# command = "sed -i 's|autocreate_system_folders = Off|autocreate_system_folders = On|g' %s" % (labsPath)
# Upgrade.executioner(command, 'mkdir snappymail configs', 0)
# else:
# WriteToFile = open(labsPath, 'w')
# for lines in labsDataLines:
# if lines.find('[labs]') > -1:
# WriteToFile.write(lines)
# WriteToFile.write(f'autocreate_system_folders = On\n')
# else:
# WriteToFile.write(lines)
# WriteToFile.close()
2023-02-03 19:55:23 +05:00
##take care of imap_folder_list_limit
2023-02-04 10:44:54 +05:00
# labsDataLines = open(labsPath, 'r').readlines()
#
# if labsData.find('imap_folder_list_limit') == -1:
# WriteToFile = open(labsPath, 'w')
# for lines in labsDataLines:
# if lines.find('[labs]') > -1:
# WriteToFile.write(lines)
# WriteToFile.write(f'imap_folder_list_limit = 0\n')
# else:
# WriteToFile.write(lines)
# WriteToFile.close()
2023-02-03 19:55:23 +05:00
2022-05-20 15:54:07 +05:00
2019-04-15 15:54:23 +05:00
os . chdir ( cwd )
2019-12-10 15:09:10 +05:00
except BaseException as msg :
2019-04-15 15:54:23 +05:00
Upgrade . stdOut ( str ( msg ) + " [downoad_and_install_raindloop] " , 0 )
return 1
2017-10-24 19:16:36 +05:00
@staticmethod
2018-04-23 19:23:03 +05:00
def downloadLink ( ) :
2018-07-19 22:38:37 +05:00
try :
2020-03-29 21:18:55 +05:00
version_number = VERSION
version_build = str ( BUILD )
2019-04-15 15:54:23 +05:00
try :
path = " /usr/local/CyberCP/version.txt "
writeToFile = open ( path , ' w ' )
writeToFile . writelines ( version_number + ' \n ' )
writeToFile . writelines ( version_build )
writeToFile . close ( )
except :
pass
2018-07-19 22:38:37 +05:00
return ( version_number + " . " + version_build + " .tar.gz " )
2019-12-10 15:09:10 +05:00
except BaseException as msg :
2018-07-19 22:38:37 +05:00
Upgrade . stdOut ( str ( msg ) + ' [downloadLink] ' )
os . _exit ( 0 )
2018-07-23 02:09:33 +05:00
@staticmethod
def setupCLI ( ) :
try :
2018-08-28 01:19:34 +05:00
2018-11-14 13:36:34 +05:00
command = " ln -s /usr/local/CyberCP/cli/cyberPanel.py /usr/bin/cyberpanel "
2018-12-14 05:01:10 +05:00
Upgrade . executioner ( command , ' CLI Symlink ' , 0 )
2018-11-14 13:36:34 +05:00
command = " chmod +x /usr/local/CyberCP/cli/cyberPanel.py "
2018-12-14 05:01:10 +05:00
Upgrade . executioner ( command , ' CLI Permissions ' , 0 )
2018-08-28 01:19:34 +05:00
2019-12-10 15:09:10 +05:00
except OSError as msg :
2018-07-23 02:09:33 +05:00
Upgrade . stdOut ( str ( msg ) + " [setupCLI] " )
return 0
2018-07-19 22:38:37 +05:00
@staticmethod
def staticContent ( ) :
2018-12-14 05:01:10 +05:00
2019-04-15 15:54:23 +05:00
command = " rm -rf /usr/local/CyberCP/public/static "
2018-12-14 05:01:10 +05:00
Upgrade . executioner ( command , ' Remove old static content ' , 0 )
##
2019-04-15 15:54:23 +05:00
if not os . path . exists ( " /usr/local/CyberCP/public " ) :
os . mkdir ( " /usr/local/CyberCP/public " )
2022-06-06 13:55:09 +05:00
cwd = os . getcwd ( )
os . chdir ( ' /usr/local/CyberCP ' )
command = ' /usr/local/CyberPanel/bin/python manage.py collectstatic --noinput --clear '
Upgrade . executioner ( command , ' Remove old static content ' , 0 )
os . chdir ( cwd )
2019-04-15 15:54:23 +05:00
shutil . move ( " /usr/local/CyberCP/static " , " /usr/local/CyberCP/public/ " )
2018-07-19 22:38:37 +05:00
@staticmethod
def upgradeVersion ( ) :
2018-12-14 05:01:10 +05:00
try :
2020-01-02 14:45:11 +05:00
import django
os . environ . setdefault ( " DJANGO_SETTINGS_MODULE " , " CyberCP.settings " )
django . setup ( )
from baseTemplate . models import version
2018-12-14 05:01:10 +05:00
vers = version . objects . get ( pk = 1 )
2020-03-29 21:18:55 +05:00
vers . currentVersion = VERSION
vers . build = str ( BUILD )
2018-12-14 05:01:10 +05:00
vers . save ( )
except :
pass
@staticmethod
2019-06-08 21:41:43 +00:00
def setupConnection ( db = None ) :
2018-12-14 05:01:10 +05:00
try :
passFile = " /etc/cyberpanel/mysqlPassword "
f = open ( passFile )
data = f . read ( )
password = data . split ( ' \n ' , 1 ) [ 0 ]
if db == None :
conn = mysql . connect ( user = ' root ' , passwd = password )
else :
2018-12-17 18:46:34 +05:00
try :
conn = mysql . connect ( db = db , user = ' root ' , passwd = password )
except :
2018-12-20 16:18:16 +05:00
try :
2019-06-08 21:41:43 +00:00
conn = mysql . connect ( host = ' 127.0.0.1 ' , port = 3307 , db = db , user = ' root ' , passwd = password )
2018-12-20 16:18:16 +05:00
except :
dbUser = settings . DATABASES [ ' default ' ] [ ' USER ' ]
password = settings . DATABASES [ ' default ' ] [ ' PASSWORD ' ]
host = settings . DATABASES [ ' default ' ] [ ' HOST ' ]
port = settings . DATABASES [ ' default ' ] [ ' PORT ' ]
2019-02-03 13:37:14 +05:00
if port == ' ' :
conn = mysql . connect ( host = host , port = 3306 , db = db , user = dbUser , passwd = password )
else :
conn = mysql . connect ( host = host , port = int ( port ) , db = db , user = dbUser , passwd = password )
2018-12-14 05:01:10 +05:00
cursor = conn . cursor ( )
return conn , cursor
2019-12-10 15:09:10 +05:00
except BaseException as msg :
2018-12-14 05:01:10 +05:00
Upgrade . stdOut ( str ( msg ) )
return 0 , 0
2017-10-24 19:16:36 +05:00
2018-08-19 00:28:31 +05:00
@staticmethod
def applyLoginSystemMigrations ( ) :
try :
2018-12-14 05:01:10 +05:00
connection , cursor = Upgrade . setupConnection ( ' cyberpanel ' )
2018-08-19 00:28:31 +05:00
2021-07-16 14:37:15 +05:00
try :
cursor . execute ( ' CREATE TABLE `baseTemplate_cyberpanelcosmetic` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `MainDashboardCSS` longtext NOT NULL) ' )
except :
pass
2018-08-28 01:19:34 +05:00
try :
2019-06-08 21:41:43 +00:00
cursor . execute (
2021-04-15 19:47:12 -04:00
' CREATE TABLE `loginSystem_acl` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `name` varchar(50) NOT NULL UNIQUE, `adminStatus` integer NOT NULL DEFAULT 0, `versionManagement` integer NOT NULL DEFAULT 0, `createNewUser` integer NOT NULL DEFAULT 0, `deleteUser` integer NOT NULL DEFAULT 0, `resellerCenter` integer NOT NULL DEFAULT 0, `changeUserACL` integer NOT NULL DEFAULT 0, `createWebsite` integer NOT NULL DEFAULT 0, `modifyWebsite` integer NOT NULL DEFAULT 0, `suspendWebsite` integer NOT NULL DEFAULT 0, `deleteWebsite` integer NOT NULL DEFAULT 0, `createPackage` integer NOT NULL DEFAULT 0, `deletePackage` integer NOT NULL DEFAULT 0, `modifyPackage` integer NOT NULL DEFAULT 0, `createDatabase` integer NOT NULL DEFAULT 0, `deleteDatabase` integer NOT NULL DEFAULT 0, `listDatabases` integer NOT NULL DEFAULT 0, `createNameServer` integer NOT NULL DEFAULT 0, `createDNSZone` integer NOT NULL DEFAULT 0, `deleteZone` integer NOT NULL DEFAULT 0, `addDeleteRecords` integer NOT NULL DEFAULT 0, `createEmail` integer NOT NULL DEFAULT 0, `deleteEmail` integer NOT NULL DEFAULT 0, `emailForwarding` integer NOT NULL DEFAULT 0, `changeEmailPassword` integer NOT NULL DEFAULT 0, `dkimManager` integer NOT NULL DEFAULT 0, `createFTPAccount` integer NOT NULL DEFAULT 0, `deleteFTPAccount` integer NOT NULL DEFAULT 0, `listFTPAccounts` integer NOT NULL DEFAULT 0, `createBackup` integer NOT NULL DEFAULT 0, `restoreBackup` integer NOT NULL DEFAULT 0, `addDeleteDestinations` integer NOT NULL DEFAULT 0, `scheduleBackups` integer NOT NULL DEFAULT 0, `remoteBackups` integer NOT NULL DEFAULT 0, `manageSSL` integer NOT NULL DEFAULT 0, `hostnameSSL` integer NOT NULL DEFAULT 0, `mailServerSSL` integer NOT NULL DEFAULT 0) ' )
2018-08-28 01:19:34 +05:00
except :
pass
2022-05-22 12:43:39 +05:00
2018-11-26 02:32:30 +05:00
try :
2018-12-14 05:01:10 +05:00
cursor . execute ( ' ALTER TABLE loginSystem_administrator ADD token varchar(500) ' )
2018-11-26 02:32:30 +05:00
except :
2019-11-12 14:01:29 +05:00
pass
2020-08-10 21:06:51 +05:00
try :
2020-08-10 23:55:46 +05:00
cursor . execute ( " ALTER TABLE loginSystem_administrator ADD secretKey varchar(50) DEFAULT ' None ' " )
2020-08-10 21:06:51 +05:00
except :
pass
2020-01-23 16:07:07 +05:00
try :
cursor . execute ( ' alter table databases_databases drop index dbUser; ' )
except :
pass
2020-01-22 14:18:13 +05:00
try :
2020-01-22 21:15:38 +05:00
cursor . execute ( " ALTER TABLE loginSystem_administrator ADD state varchar(15) DEFAULT ' ACTIVE ' " )
2020-01-22 14:18:13 +05:00
except :
pass
2019-11-12 14:01:29 +05:00
try :
2019-11-12 14:03:35 +05:00
cursor . execute ( ' ALTER TABLE loginSystem_administrator ADD securityLevel integer DEFAULT 1 ' )
2019-11-12 14:01:29 +05:00
except :
2018-11-26 02:32:30 +05:00
pass
2019-04-15 15:54:23 +05:00
2020-08-10 21:06:51 +05:00
try :
cursor . execute ( ' ALTER TABLE loginSystem_administrator ADD twoFA integer DEFAULT 0 ' )
except :
pass
2019-04-15 15:54:23 +05:00
try :
cursor . execute ( ' ALTER TABLE loginSystem_administrator ADD api integer ' )
except :
pass
2018-08-28 01:19:34 +05:00
try :
2018-12-14 05:01:10 +05:00
cursor . execute ( ' ALTER TABLE loginSystem_administrator ADD acl_id integer ' )
2018-08-28 01:19:34 +05:00
except :
pass
try :
2019-06-08 21:41:43 +00:00
cursor . execute (
' ALTER TABLE loginSystem_administrator ADD FOREIGN KEY (acl_id) REFERENCES loginSystem_acl(id) ' )
2018-08-28 01:19:34 +05:00
except :
pass
2017-10-24 19:16:36 +05:00
2018-08-28 01:19:34 +05:00
try :
2018-12-14 05:01:10 +05:00
cursor . execute ( " insert into loginSystem_acl (id, name, adminStatus) values (1, ' admin ' ,1) " )
2018-08-28 01:19:34 +05:00
except :
pass
try :
2019-06-08 21:41:43 +00:00
cursor . execute (
" insert into loginSystem_acl (id, name, adminStatus, createNewUser, deleteUser, createWebsite, resellerCenter, modifyWebsite, suspendWebsite, deleteWebsite, createPackage, deletePackage, modifyPackage, createNameServer, restoreBackup) values (2, ' reseller ' ,0,1,1,1,1,1,1,1,1,1,1,1,1) " )
2018-12-14 05:01:10 +05:00
except :
pass
try :
2019-06-08 21:41:43 +00:00
cursor . execute (
" insert into loginSystem_acl (id, name, createDatabase, deleteDatabase, listDatabases, createDNSZone, deleteZone, addDeleteRecords, createEmail, deleteEmail, emailForwarding, changeEmailPassword, dkimManager, createFTPAccount, deleteFTPAccount, listFTPAccounts, createBackup, manageSSL) values (3, ' user ' , 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) " )
2018-08-28 01:19:34 +05:00
except :
pass
try :
2018-12-14 05:01:10 +05:00
cursor . execute ( " UPDATE loginSystem_administrator SET acl_id = 1 where userName = ' admin ' " )
2018-08-28 01:19:34 +05:00
except :
pass
2021-02-21 13:09:50 +05:00
try :
cursor . execute ( ' ALTER TABLE loginSystem_acl ADD config longtext ' )
except :
pass
try :
2021-02-21 13:18:38 +05:00
cursor . execute ( " UPDATE loginSystem_acl SET config = ' %s ' where name = ' admin ' " % ( Upgrade . AdminACL ) )
2021-02-21 13:24:53 +05:00
except BaseException as msg :
print ( str ( msg ) )
import sleep
sleep ( 10 )
2021-02-21 13:09:50 +05:00
try :
2021-02-21 13:18:38 +05:00
cursor . execute ( " UPDATE loginSystem_acl SET config = ' %s ' where name = ' reseller ' " % ( Upgrade . ResellerACL ) )
2021-02-21 13:09:50 +05:00
except :
pass
try :
2021-02-21 13:18:38 +05:00
cursor . execute ( " UPDATE loginSystem_acl SET config = ' %s ' where name = ' user ' " % ( Upgrade . UserACL ) )
2021-02-21 13:09:50 +05:00
except :
pass
2018-08-28 01:19:34 +05:00
try :
2018-12-14 05:01:10 +05:00
cursor . execute ( " alter table loginSystem_administrator drop initUserAccountsLimit " )
2018-08-28 01:19:34 +05:00
except :
pass
try :
2019-06-08 21:41:43 +00:00
cursor . execute (
" CREATE TABLE `websiteFunctions_aliasdomains` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `aliasDomain` varchar(75) NOT NULL) " )
2018-12-14 05:01:10 +05:00
except :
pass
try :
cursor . execute ( " ALTER TABLE `websiteFunctions_aliasdomains` ADD COLUMN `master_id` integer NOT NULL " )
2018-08-28 01:19:34 +05:00
except :
pass
2018-12-14 05:01:10 +05:00
try :
2019-06-08 21:41:43 +00:00
cursor . execute (
" ALTER TABLE `websiteFunctions_aliasdomains` ADD CONSTRAINT `websiteFunctions_ali_master_id_726c433d_fk_websiteFu` FOREIGN KEY (`master_id`) REFERENCES `websiteFunctions_websites` (`id`) " )
2018-12-14 05:01:10 +05:00
except :
pass
2021-01-18 11:14:52 +05:00
try :
cursor . execute ( ' ALTER TABLE websiteFunctions_websites ADD config longtext ' )
except :
pass
2020-03-06 09:25:49 +05:00
try :
cursor . execute ( " ALTER TABLE websiteFunctions_websites MODIFY externalApp varchar(30) " )
except :
pass
2020-09-15 09:35:55 +05:00
try :
cursor . execute ( " ALTER TABLE emailMarketing_smtphosts MODIFY userName varchar(200) " )
except :
pass
try :
cursor . execute ( " ALTER TABLE emailMarketing_smtphosts MODIFY password varchar(200) " )
except :
pass
2020-04-28 17:51:31 +05:00
try :
cursor . execute ( " ALTER TABLE websiteFunctions_backups MODIFY fileName varchar(200) " )
except :
pass
2019-08-13 16:27:56 +05:00
try :
cursor . execute ( " ALTER TABLE loginSystem_acl ADD COLUMN listUsers INT DEFAULT 0; " )
except :
pass
try :
cursor . execute ( " ALTER TABLE loginSystem_acl ADD COLUMN listEmails INT DEFAULT 1; " )
except :
pass
try :
cursor . execute ( " ALTER TABLE loginSystem_acl ADD COLUMN listPackages INT DEFAULT 0; " )
except :
pass
2020-10-08 22:19:55 +05:00
query = """ CREATE TABLE `websiteFunctions_normalbackupdests` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 25 ) NOT NULL ,
` config ` longtext NOT NULL ,
PRIMARY KEY ( ` id ` )
) """
2021-02-05 18:30:07 +05:00
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `cloudAPI_wpdeployments` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` config ` longtext NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` cloudAPI_wpdeploymen_owner_id_506ddf01_fk_websiteFu ` ( ` owner_id ` ) ,
CONSTRAINT ` cloudAPI_wpdeploymen_owner_id_506ddf01_fk_websiteFu ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` websiteFunctions_websites ` ( ` id ` )
) """
2020-10-08 22:19:55 +05:00
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `websiteFunctions_normalbackupjobs` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 25 ) NOT NULL ,
` config ` longtext NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` websiteFunctions_nor_owner_id_3a7a13db_fk_websiteFu ` ( ` owner_id ` ) ,
CONSTRAINT ` websiteFunctions_nor_owner_id_3a7a13db_fk_websiteFu ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` websiteFunctions_normalbackupdests ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `websiteFunctions_normalbackupsites` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` domain_id ` int ( 11 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` websiteFunctions_nor_domain_id_c03362bc_fk_websiteFu ` ( ` domain_id ` ) ,
KEY ` websiteFunctions_nor_owner_id_c6ece6cc_fk_websiteFu ` ( ` owner_id ` ) ,
CONSTRAINT ` websiteFunctions_nor_domain_id_c03362bc_fk_websiteFu ` FOREIGN KEY ( ` domain_id ` ) REFERENCES ` websiteFunctions_websites ` ( ` id ` ) ,
CONSTRAINT ` websiteFunctions_nor_owner_id_c6ece6cc_fk_websiteFu ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` websiteFunctions_normalbackupjobs ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `websiteFunctions_normalbackupjoblogs` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` status ` int ( 11 ) NOT NULL ,
` message ` longtext NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` websiteFunctions_nor_owner_id_69403e73_fk_websiteFu ` ( ` owner_id ` ) ,
CONSTRAINT ` websiteFunctions_nor_owner_id_69403e73_fk_websiteFu ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` websiteFunctions_normalbackupjobs ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
2022-05-22 12:43:39 +05:00
try :
cursor . execute ( ' ALTER TABLE e_users ADD DiskUsage varchar(200) ' )
except :
pass
2022-06-04 13:21:02 +05:00
try :
cursor . execute ( ' CREATE TABLE `websiteFunctions_wpplugins` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `Name` varchar(255) NOT NULL, `config` longtext NOT NULL, `owner_id` integer NOT NULL) ' )
except :
pass
try :
cursor . execute ( ' ALTER TABLE `websiteFunctions_wpplugins` ADD CONSTRAINT `websiteFunctions_wpp_owner_id_493a02c7_fk_loginSyst` FOREIGN KEY (`owner_id`) REFERENCES `loginSystem_administrator` (`id`) ' )
except :
pass
try :
cursor . execute ( ' CREATE TABLE `websiteFunctions_wpsites` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `title` varchar(255) NOT NULL, `path` varchar(255) NOT NULL, `FinalURL` varchar(255) NOT NULL, `AutoUpdates` varchar(100) NOT NULL, `PluginUpdates` varchar(15) NOT NULL, `ThemeUpdates` varchar(15) NOT NULL, `date` datetime(6) NOT NULL, `WPLockState` integer NOT NULL, `owner_id` integer NOT NULL) ' )
except :
pass
try :
cursor . execute ( ' ALTER TABLE `websiteFunctions_wpsites` ADD CONSTRAINT `websiteFunctions_wps_owner_id_6d67df2a_fk_websiteFu` FOREIGN KEY (`owner_id`) REFERENCES `websiteFunctions_websites` (`id`) ' )
except :
pass
try :
cursor . execute ( ' CREATE TABLE `websiteFunctions_wpstaging` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `owner_id` integer NOT NULL, `wpsite_id` integer NOT NULL) ' )
except :
pass
try :
cursor . execute ( ' ALTER TABLE `websiteFunctions_wpstaging` ADD CONSTRAINT `websiteFunctions_wps_owner_id_543d8aec_fk_websiteFu` FOREIGN KEY (`owner_id`) REFERENCES `websiteFunctions_wpsites` (`id`); ' )
except :
pass
try :
cursor . execute ( ' ALTER TABLE `websiteFunctions_wpstaging` ADD CONSTRAINT `websiteFunctions_wps_wpsite_id_82843593_fk_websiteFu` FOREIGN KEY (`wpsite_id`) REFERENCES `websiteFunctions_wpsites` (`id`) ' )
except :
pass
2022-06-07 13:59:06 +05:00
try :
cursor . execute ( " CREATE TABLE `websiteFunctions_wpsitesbackup` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `WPSiteID` integer NOT NULL, `WebsiteID` integer NOT NULL, `config` longtext NOT NULL, `owner_id` integer NOT NULL); " )
except :
pass
try :
cursor . execute ( " ALTER TABLE `websiteFunctions_wpsitesbackup` ADD CONSTRAINT `websiteFunctions_wps_owner_id_8a8dd0c5_fk_loginSyst` FOREIGN KEY (`owner_id`) REFERENCES `loginSystem_administrator` (`id`); " )
except :
pass
2022-07-09 20:38:07 +05:00
query = """ CREATE TABLE `websiteFunctions_remotebackupconfig` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` configtype ` varchar ( 255 ) NOT NULL ,
` config ` longtext NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` )
) """
2022-07-14 22:28:00 +05:00
try :
cursor . execute ( query )
except :
pass
2022-07-09 20:38:07 +05:00
query = """ CREATE TABLE `websiteFunctions_remotebackupschedule` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` Name ` varchar ( 255 ) NOT NULL ,
` timeintervel ` varchar ( 200 ) NOT NULL ,
` fileretention ` varchar ( 200 ) NOT NULL ,
` lastrun ` varchar ( 200 ) NOT NULL ,
` config ` longtext NOT NULL ,
` RemoteBackupConfig_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` websiteFunctions_rem_RemoteBackupConfig_i_224c46fb_fk_websiteFu ` ( ` RemoteBackupConfig_id ` ) ,
CONSTRAINT ` websiteFunctions_rem_RemoteBackupConfig_i_224c46fb_fk_websiteFu ` FOREIGN KEY ( ` RemoteBackupConfig_id ` ) REFERENCES ` websiteFunctions_remotebackupconfig ` ( ` id ` )
) """
2022-07-14 22:28:00 +05:00
try :
cursor . execute ( query )
except :
pass
2022-07-09 20:38:07 +05:00
query = """ CREATE TABLE `websiteFunctions_remotebackupsites` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` WPsites ` int ( 11 ) DEFAULT NULL ,
` database ` int ( 11 ) DEFAULT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` websiteFunctions_rem_owner_id_d6c4475a_fk_websiteFu ` ( ` owner_id ` ) ,
CONSTRAINT ` websiteFunctions_rem_owner_id_d6c4475a_fk_websiteFu ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` websiteFunctions_remotebackupschedule ` ( ` id ` )
) """
2022-07-14 22:28:00 +05:00
try :
cursor . execute ( query )
except :
pass
2022-07-09 20:38:07 +05:00
2018-12-20 16:18:16 +05:00
try :
connection . close ( )
except :
pass
2018-12-14 05:01:10 +05:00
2019-12-10 15:09:10 +05:00
except OSError as msg :
2018-12-14 05:01:10 +05:00
Upgrade . stdOut ( str ( msg ) + " [applyLoginSystemMigrations] " )
@staticmethod
def s3BackupMigrations ( ) :
try :
connection , cursor = Upgrade . setupConnection ( ' cyberpanel ' )
query = """ CREATE TABLE `s3Backups_backupplan` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 50 ) NOT NULL ,
` bucket ` varchar ( 50 ) NOT NULL ,
` freq ` varchar ( 50 ) NOT NULL ,
` retention ` int ( 11 ) NOT NULL ,
` type ` varchar ( 5 ) NOT NULL ,
` lastRun ` varchar ( 50 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
UNIQUE KEY ` name ` ( ` name ` ) ,
KEY ` s3Backups_backupplan_owner_id_7d058ced_fk_loginSyst ` ( ` owner_id ` ) ,
CONSTRAINT ` s3Backups_backupplan_owner_id_7d058ced_fk_loginSyst ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` loginSystem_administrator ` ( ` id ` )
) """
2018-08-28 01:19:34 +05:00
try :
2018-12-14 05:01:10 +05:00
cursor . execute ( query )
2018-08-28 01:19:34 +05:00
except :
pass
2020-12-08 21:19:23 +05:00
try :
cursor . execute ( ' ALTER TABLE s3Backups_backupplan ADD config longtext ' )
except :
pass
2018-12-14 05:01:10 +05:00
query = """ CREATE TABLE `s3Backups_websitesinplan` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` domain ` varchar ( 100 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` s3Backups_websitesin_owner_id_0e9a4fe3_fk_s3Backups ` ( ` owner_id ` ) ,
CONSTRAINT ` s3Backups_websitesin_owner_id_0e9a4fe3_fk_s3Backups ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` s3Backups_backupplan ` ( ` id ` )
) """
2018-08-28 01:19:34 +05:00
try :
2018-12-14 05:01:10 +05:00
cursor . execute ( query )
2018-08-28 01:19:34 +05:00
except :
pass
2018-12-14 05:01:10 +05:00
query = """ CREATE TABLE `s3Backups_backuplogs` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` timeStamp ` varchar ( 200 ) NOT NULL ,
` level ` varchar ( 5 ) NOT NULL ,
` msg ` varchar ( 500 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` s3Backups_backuplogs_owner_id_7b4653af_fk_s3Backups ` ( ` owner_id ` ) ,
CONSTRAINT ` s3Backups_backuplogs_owner_id_7b4653af_fk_s3Backups ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` s3Backups_backupplan ` ( ` id ` )
) """
2018-12-31 22:55:17 +05:00
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `s3Backups_backupplando` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 50 ) NOT NULL ,
` bucket ` varchar ( 50 ) NOT NULL ,
` freq ` varchar ( 50 ) NOT NULL ,
` retention ` int ( 11 ) NOT NULL ,
` type ` varchar ( 5 ) NOT NULL ,
` region ` varchar ( 5 ) NOT NULL ,
` lastRun ` varchar ( 50 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
UNIQUE KEY ` name ` ( ` name ` ) ,
KEY ` s3Backups_backupplan_owner_id_1a3ec86d_fk_loginSyst ` ( ` owner_id ` ) ,
CONSTRAINT ` s3Backups_backupplan_owner_id_1a3ec86d_fk_loginSyst ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` loginSystem_administrator ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `s3Backups_websitesinplando` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` domain ` varchar ( 100 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` s3Backups_websitesin_owner_id_cef3ea04_fk_s3Backups ` ( ` owner_id ` ) ,
CONSTRAINT ` s3Backups_websitesin_owner_id_cef3ea04_fk_s3Backups ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` s3Backups_backupplando ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `s3Backups_backuplogsdo` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` timeStamp ` varchar ( 200 ) NOT NULL ,
` level ` varchar ( 5 ) NOT NULL ,
` msg ` varchar ( 500 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` s3Backups_backuplogs_owner_id_c7cb5872_fk_s3Backups ` ( ` owner_id ` ) ,
CONSTRAINT ` s3Backups_backuplogs_owner_id_c7cb5872_fk_s3Backups ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` s3Backups_backupplando ` ( ` id ` )
) """
2019-01-27 01:18:49 +05:00
try :
cursor . execute ( query )
except :
pass
##
query = """ CREATE TABLE `s3Backups_minionodes` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` endPointURL ` varchar ( 200 ) NOT NULL ,
` accessKey ` varchar ( 200 ) NOT NULL ,
` secretKey ` varchar ( 200 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
UNIQUE KEY ` endPointURL ` ( ` endPointURL ` ) ,
UNIQUE KEY ` accessKey ` ( ` accessKey ` ) ,
KEY ` s3Backups_minionodes_owner_id_e50993d9_fk_loginSyst ` ( ` owner_id ` ) ,
CONSTRAINT ` s3Backups_minionodes_owner_id_e50993d9_fk_loginSyst ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` loginSystem_administrator ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `s3Backups_backupplanminio` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 50 ) NOT NULL ,
` freq ` varchar ( 50 ) NOT NULL ,
` retention ` int ( 11 ) NOT NULL ,
` lastRun ` varchar ( 50 ) NOT NULL ,
` minioNode_id ` int ( 11 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
UNIQUE KEY ` name ` ( ` name ` ) ,
KEY ` s3Backups_backupplan_minioNode_id_a4eaf917_fk_s3Backups ` ( ` minioNode_id ` ) ,
KEY ` s3Backups_backupplan_owner_id_d6830e67_fk_loginSyst ` ( ` owner_id ` ) ,
CONSTRAINT ` s3Backups_backupplan_minioNode_id_a4eaf917_fk_s3Backups ` FOREIGN KEY ( ` minioNode_id ` ) REFERENCES ` s3Backups_minionodes ` ( ` id ` ) ,
CONSTRAINT ` s3Backups_backupplan_owner_id_d6830e67_fk_loginSyst ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` loginSystem_administrator ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `s3Backups_websitesinplanminio` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` domain ` varchar ( 100 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` s3Backups_websitesin_owner_id_224ce049_fk_s3Backups ` ( ` owner_id ` ) ,
CONSTRAINT ` s3Backups_websitesin_owner_id_224ce049_fk_s3Backups ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` s3Backups_backupplanminio ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `s3Backups_backuplogsminio` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` timeStamp ` varchar ( 200 ) NOT NULL ,
` level ` varchar ( 5 ) NOT NULL ,
` msg ` varchar ( 500 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` s3Backups_backuplogs_owner_id_f19e1736_fk_s3Backups ` ( ` owner_id ` ) ,
CONSTRAINT ` s3Backups_backuplogs_owner_id_f19e1736_fk_s3Backups ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` s3Backups_backupplanminio ` ( ` id ` )
) """
2018-08-28 01:19:34 +05:00
try :
2018-12-14 05:01:10 +05:00
cursor . execute ( query )
2018-08-28 01:19:34 +05:00
except :
pass
2018-08-26 04:55:51 +05:00
2018-12-20 16:18:16 +05:00
try :
connection . close ( )
except :
pass
2018-08-19 00:28:31 +05:00
2019-12-10 15:09:10 +05:00
except OSError as msg :
2018-08-19 00:28:31 +05:00
Upgrade . stdOut ( str ( msg ) + " [applyLoginSystemMigrations] " )
2017-10-24 19:16:36 +05:00
2018-04-23 19:23:03 +05:00
@staticmethod
2018-08-21 13:10:40 +05:00
def mailServerMigrations ( ) :
try :
2018-12-14 05:01:10 +05:00
connection , cursor = Upgrade . setupConnection ( ' cyberpanel ' )
2019-07-03 13:15:26 +05:00
try :
cursor . execute (
' ALTER TABLE `e_domains` ADD COLUMN `childOwner_id` integer ' )
except :
pass
try :
cursor . execute (
' ALTER TABLE e_users ADD mail varchar(200) ' )
except :
pass
2019-07-16 23:23:16 +05:00
try :
cursor . execute (
' ALTER TABLE e_users MODIFY password varchar(200) ' )
except :
pass
2018-12-14 05:01:10 +05:00
try :
2019-06-08 21:41:43 +00:00
cursor . execute (
' ALTER TABLE e_forwardings DROP PRIMARY KEY;ALTER TABLE e_forwardings ADD id INT AUTO_INCREMENT PRIMARY KEY ' )
2018-12-14 05:01:10 +05:00
except :
pass
query = """ CREATE TABLE `emailPremium_domainlimits` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` limitStatus ` int ( 11 ) NOT NULL ,
` monthlyLimit ` int ( 11 ) NOT NULL ,
` monthlyUsed ` int ( 11 ) NOT NULL ,
` domain_id ` varchar ( 50 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` emailPremium_domainlimits_domain_id_303ab297_fk_e_domains_domain ` ( ` domain_id ` ) ,
CONSTRAINT ` emailPremium_domainlimits_domain_id_303ab297_fk_e_domains_domain ` FOREIGN KEY ( ` domain_id ` ) REFERENCES ` e_domains ` ( ` domain ` )
) """
2018-08-28 01:19:34 +05:00
try :
2018-12-14 05:01:10 +05:00
cursor . execute ( query )
2018-08-28 01:19:34 +05:00
except :
pass
2018-12-14 05:01:10 +05:00
query = """ CREATE TABLE `emailPremium_emaillimits` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` limitStatus ` int ( 11 ) NOT NULL ,
` monthlyLimits ` int ( 11 ) NOT NULL ,
` monthlyUsed ` int ( 11 ) NOT NULL ,
` hourlyLimit ` int ( 11 ) NOT NULL ,
` hourlyUsed ` int ( 11 ) NOT NULL ,
` emailLogs ` int ( 11 ) NOT NULL ,
` email_id ` varchar ( 80 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` emailPremium_emaillimits_email_id_1c111df5_fk_e_users_email ` ( ` email_id ` ) ,
CONSTRAINT ` emailPremium_emaillimits_email_id_1c111df5_fk_e_users_email ` FOREIGN KEY ( ` email_id ` ) REFERENCES ` e_users ` ( ` email ` )
) """
2018-08-28 01:19:34 +05:00
try :
2018-12-14 05:01:10 +05:00
cursor . execute ( query )
2018-08-28 01:19:34 +05:00
except :
pass
2018-12-14 05:01:10 +05:00
query = """ CREATE TABLE `emailPremium_emaillogs` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` destination ` varchar ( 200 ) NOT NULL ,
` timeStamp ` varchar ( 200 ) NOT NULL ,
` email_id ` varchar ( 80 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` emailPremium_emaillogs_email_id_9ef49552_fk_e_users_email ` ( ` email_id ` ) ,
CONSTRAINT ` emailPremium_emaillogs_email_id_9ef49552_fk_e_users_email ` FOREIGN KEY ( ` email_id ` ) REFERENCES ` e_users ` ( ` email ` )
) """
2018-08-28 01:19:34 +05:00
try :
2018-12-14 05:01:10 +05:00
cursor . execute ( query )
2018-08-28 01:19:34 +05:00
except :
pass
2018-12-14 05:01:10 +05:00
2018-12-20 16:18:16 +05:00
try :
connection . close ( )
except :
pass
2018-08-21 13:10:40 +05:00
except :
pass
2018-07-26 04:11:10 +05:00
2018-10-22 10:55:52 +05:00
@staticmethod
def emailMarketingMigrationsa ( ) :
try :
2018-12-14 05:01:10 +05:00
connection , cursor = Upgrade . setupConnection ( ' cyberpanel ' )
query = """ CREATE TABLE `emailMarketing_emailmarketing` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` userName ` varchar ( 50 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
UNIQUE KEY ` userName ` ( ` userName ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `emailMarketing_emaillists` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` listName ` varchar ( 50 ) NOT NULL ,
` dateCreated ` varchar ( 200 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
UNIQUE KEY ` listName ` ( ` listName ` ) ,
KEY ` emailMarketing_email_owner_id_bf1b4530_fk_websiteFu ` ( ` owner_id ` ) ,
CONSTRAINT ` emailMarketing_email_owner_id_bf1b4530_fk_websiteFu ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` websiteFunctions_websites ` ( ` id ` )
) """
2020-06-10 22:16:49 +05:00
try :
cursor . execute ( query )
except :
pass
query = ' ALTER TABLE emailMarketing_emaillists ADD COLUMN verified INT DEFAULT 0 '
try :
cursor . execute ( query )
except :
pass
query = ' ALTER TABLE emailMarketing_emaillists ADD COLUMN notVerified INT DEFAULT 0 '
2018-12-14 05:01:10 +05:00
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `emailMarketing_emailsinlist` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` email ` varchar ( 50 ) NOT NULL ,
` firstName ` varchar ( 20 ) NOT NULL ,
` lastName ` varchar ( 20 ) NOT NULL ,
` verificationStatus ` varchar ( 100 ) NOT NULL ,
` dateCreated ` varchar ( 200 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` emailMarketing_email_owner_id_c5c27005_fk_emailMark ` ( ` owner_id ` ) ,
CONSTRAINT ` emailMarketing_email_owner_id_c5c27005_fk_emailMark ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` emailMarketing_emaillists ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `emailMarketing_smtphosts` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` host ` varchar ( 150 ) NOT NULL ,
` port ` varchar ( 10 ) NOT NULL ,
` userName ` varchar ( 50 ) NOT NULL ,
` password ` varchar ( 50 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
UNIQUE KEY ` host ` ( ` host ` ) ,
KEY ` emailMarketing_smtph_owner_id_8b2d4ac7_fk_loginSyst ` ( ` owner_id ` ) ,
CONSTRAINT ` emailMarketing_smtph_owner_id_8b2d4ac7_fk_loginSyst ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` loginSystem_administrator ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `emailMarketing_emailtemplate` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 100 ) NOT NULL ,
` subject ` varchar ( 1000 ) NOT NULL ,
` fromName ` varchar ( 100 ) NOT NULL ,
` fromEmail ` varchar ( 150 ) NOT NULL ,
` replyTo ` varchar ( 150 ) NOT NULL ,
` emailMessage ` varchar ( 30000 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
UNIQUE KEY ` name ` ( ` name ` ) ,
KEY ` emailMarketing_email_owner_id_d27e1d00_fk_loginSyst ` ( ` owner_id ` ) ,
CONSTRAINT ` emailMarketing_email_owner_id_d27e1d00_fk_loginSyst ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` loginSystem_administrator ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `emailMarketing_emailjobs` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` date ` varchar ( 200 ) NOT NULL ,
` host ` varchar ( 1000 ) NOT NULL ,
` totalEmails ` int ( 11 ) NOT NULL ,
` sent ` int ( 11 ) NOT NULL ,
` failed ` int ( 11 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` emailMarketing_email_owner_id_73ee4827_fk_emailMark ` ( ` owner_id ` ) ,
CONSTRAINT ` emailMarketing_email_owner_id_73ee4827_fk_emailMark ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` emailMarketing_emailtemplate ` ( ` id ` )
) """
2018-11-14 13:36:34 +05:00
2019-11-02 19:29:02 +05:00
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `mailServer_pipeprograms` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` source ` varchar ( 80 ) NOT NULL ,
` destination ` longtext NOT NULL ,
PRIMARY KEY ( ` id ` )
) """
2020-06-10 22:16:49 +05:00
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `emailMarketing_validationlog` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` status ` int ( 11 ) NOT NULL ,
` message ` longtext NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` emailMarketing_valid_owner_id_240ad36e_fk_emailMark ` ( ` owner_id ` ) ,
CONSTRAINT ` emailMarketing_valid_owner_id_240ad36e_fk_emailMark ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` emailMarketing_emaillists ` ( ` id ` )
) """
2018-12-14 05:01:10 +05:00
try :
cursor . execute ( query )
except :
pass
2018-11-14 13:36:34 +05:00
2018-12-20 16:18:16 +05:00
try :
connection . close ( )
except :
pass
2018-10-22 10:55:52 +05:00
except :
pass
2019-01-09 14:55:10 +05:00
@staticmethod
def dockerMigrations ( ) :
try :
connection , cursor = Upgrade . setupConnection ( ' cyberpanel ' )
query = """ CREATE TABLE `dockerManager_containers` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 50 ) NOT NULL ,
` cid ` varchar ( 64 ) NOT NULL ,
` image ` varchar ( 50 ) NOT NULL ,
` tag ` varchar ( 50 ) NOT NULL ,
` memory ` int ( 11 ) NOT NULL ,
` ports ` longtext NOT NULL ,
` env ` longtext NOT NULL ,
` startOnReboot ` int ( 11 ) NOT NULL ,
` admin_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
UNIQUE KEY ` name ` ( ` name ` ) ,
KEY ` dockerManager_contai_admin_id_58fb62b7_fk_loginSyst ` ( ` admin_id ` ) ,
CONSTRAINT ` dockerManager_contai_admin_id_58fb62b7_fk_loginSyst ` FOREIGN KEY ( ` admin_id ` ) REFERENCES ` loginSystem_administrator ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
2021-02-18 14:56:01 +05:00
try :
cursor . execute ( ' ALTER TABLE loginSystem_administrator ADD config longtext ' )
except :
pass
2021-02-21 13:09:50 +05:00
try :
cursor . execute ( ' ALTER TABLE loginSystem_acl ADD config longtext ' )
except :
pass
2019-01-28 15:19:59 +05:00
try :
cursor . execute ( ' ALTER TABLE dockerManager_containers ADD volumes longtext ' )
except :
pass
2019-01-09 14:55:10 +05:00
try :
connection . close ( )
except :
pass
except :
pass
2019-01-27 01:18:49 +05:00
@staticmethod
def containerMigrations ( ) :
try :
connection , cursor = Upgrade . setupConnection ( ' cyberpanel ' )
query = """ CREATE TABLE `containerization_containerlimits` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` cpuPers ` varchar ( 10 ) NOT NULL ,
` IO ` varchar ( 10 ) NOT NULL ,
` IOPS ` varchar ( 10 ) NOT NULL ,
` memory ` varchar ( 10 ) NOT NULL ,
` networkSpeed ` varchar ( 10 ) NOT NULL ,
` networkHexValue ` varchar ( 10 ) NOT NULL ,
` enforce ` int ( 11 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` containerization_con_owner_id_494eb637_fk_websiteFu ` ( ` owner_id ` ) ,
CONSTRAINT ` containerization_con_owner_id_494eb637_fk_websiteFu ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` websiteFunctions_websites ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
try :
connection . close ( )
except :
pass
except :
pass
2019-07-16 23:23:16 +05:00
@staticmethod
def CLMigrations ( ) :
try :
connection , cursor = Upgrade . setupConnection ( ' cyberpanel ' )
query = """ CREATE TABLE `CLManager_clpackages` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 50 ) NOT NULL ,
` speed ` varchar ( 50 ) NOT NULL ,
` vmem ` varchar ( 50 ) NOT NULL ,
` pmem ` varchar ( 50 ) NOT NULL ,
` io ` varchar ( 50 ) NOT NULL ,
` iops ` varchar ( 50 ) NOT NULL ,
` ep ` varchar ( 50 ) NOT NULL ,
` nproc ` varchar ( 50 ) NOT NULL ,
` inodessoft ` varchar ( 50 ) NOT NULL ,
` inodeshard ` varchar ( 50 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
UNIQUE KEY ` name ` ( ` name ` ) ,
KEY ` CLManager_clpackages_owner_id_9898c1e8_fk_packages_package_id ` ( ` owner_id ` ) ,
CONSTRAINT ` CLManager_clpackages_owner_id_9898c1e8_fk_packages_package_id ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` packages_package ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
2019-08-13 16:27:56 +05:00
query = " ALTER TABLE packages_package ADD COLUMN allowFullDomain INT DEFAULT 1; "
try :
cursor . execute ( query )
except :
pass
2021-04-05 13:50:57 +05:00
query = " ALTER TABLE packages_package ADD COLUMN enforceDiskLimits INT DEFAULT 0; "
try :
cursor . execute ( query )
except :
pass
2019-07-16 23:23:16 +05:00
try :
connection . close ( )
except :
pass
except :
pass
2019-02-05 12:21:37 +05:00
@staticmethod
def manageServiceMigrations ( ) :
try :
connection , cursor = Upgrade . setupConnection ( ' cyberpanel ' )
query = """ CREATE TABLE `manageServices_pdnsstatus` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` serverStatus ` int ( 11 ) NOT NULL ,
` type ` varchar ( 6 ) NOT NULL ,
PRIMARY KEY ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
2019-07-16 23:23:16 +05:00
try :
cursor . execute ( ' alter table manageServices_pdnsstatus add masterServer varchar(200) ' )
except :
pass
try :
cursor . execute ( ' alter table manageServices_pdnsstatus add masterIP varchar(200) ' )
except :
pass
2021-03-05 10:15:01 +05:00
try :
2021-04-04 00:12:36 +05:00
cursor . execute ( ' ALTER TABLE `manageServices_pdnsstatus` CHANGE `type` `type` VARCHAR(10) NULL; ' )
2021-03-05 10:15:01 +05:00
except :
pass
2020-07-27 12:36:36 +05:00
query = ''' CREATE TABLE `databases_dbmeta` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` key ` varchar ( 200 ) NOT NULL ,
` value ` longtext NOT NULL ,
` database_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` databases_dbmeta_database_id_777997bc_fk_databases_databases_id ` ( ` database_id ` ) ,
CONSTRAINT ` databases_dbmeta_database_id_777997bc_fk_databases_databases_id ` FOREIGN KEY ( ` database_id ` ) REFERENCES ` databases_databases ` ( ` id ` )
) '''
2020-08-05 14:20:53 +05:00
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `filemanager_trash` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` originalPath ` varchar ( 500 ) NOT NULL ,
` fileName ` varchar ( 200 ) NOT NULL ,
` website_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` filemanager_trash_website_id_e2762f3c_fk_websiteFu ` ( ` website_id ` ) ,
CONSTRAINT ` filemanager_trash_website_id_e2762f3c_fk_websiteFu ` FOREIGN KEY ( ` website_id ` ) REFERENCES ` websiteFunctions_websites ` ( ` id ` )
) """
2020-08-09 12:45:18 +05:00
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `databases_globaluserdb` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` username ` varchar ( 200 ) NOT NULL ,
` password ` varchar ( 500 ) NOT NULL ,
` token ` varchar ( 20 ) NOT NULL ,
PRIMARY KEY ( ` id ` )
) """
2021-04-11 12:39:05 +05:00
try :
cursor . execute ( query )
except :
pass
query = " CREATE TABLE `databases_databasesusers` (`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `username` varchar(50) NOT NULL UNIQUE, `owner_id` integer NOT NULL) "
try :
cursor . execute ( query )
except :
pass
query = " ALTER TABLE `databases_databasesusers` ADD CONSTRAINT `databases_databasesu_owner_id_908fc638_fk_databases` FOREIGN KEY (`owner_id`) REFERENCES `databases_databases` (`id`); "
2020-07-27 12:36:36 +05:00
try :
cursor . execute ( query )
except :
pass
2019-02-05 12:21:37 +05:00
try :
connection . close ( )
except :
pass
except :
pass
2019-06-08 21:41:43 +00:00
@staticmethod
def GeneralMigrations ( ) :
try :
cwd = os . getcwd ( )
os . chdir ( ' /usr/local/CyberCP ' )
2019-12-26 16:18:27 +05:00
command = ' /usr/local/CyberPanel/bin/python manage.py makemigrations '
2019-06-08 21:41:43 +00:00
Upgrade . executioner ( command , ' python manage.py makemigrations ' , 0 )
2019-12-26 16:18:27 +05:00
command = ' /usr/local/CyberPanel/bin/python manage.py makemigrations '
Upgrade . executioner ( command , ' /usr/local/CyberPanel/bin/python manage.py migrate ' , 0 )
2019-06-08 21:41:43 +00:00
os . chdir ( cwd )
except :
pass
2019-10-15 22:59:22 +05:00
@staticmethod
def IncBackupMigrations ( ) :
try :
connection , cursor = Upgrade . setupConnection ( ' cyberpanel ' )
query = """ CREATE TABLE `IncBackups_backupjob` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` destination ` varchar ( 300 ) NOT NULL ,
` frequency ` varchar ( 50 ) NOT NULL ,
` websiteData ` int ( 11 ) NOT NULL ,
` websiteDatabases ` int ( 11 ) NOT NULL ,
` websiteDataEmails ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` )
) """
2021-04-16 22:00:18 +05:00
try :
cursor . execute ( query )
except :
pass
query = ' ALTER TABLE IncBackups_backupjob ADD retention integer DEFAULT 0 '
2019-10-15 22:59:22 +05:00
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `IncBackups_incjob` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` date ` datetime ( 6 ) NOT NULL ,
` website_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` IncBackups_incjob_website_id_aad31bf6_fk_websiteFu ` ( ` website_id ` ) ,
CONSTRAINT ` IncBackups_incjob_website_id_aad31bf6_fk_websiteFu ` FOREIGN KEY ( ` website_id ` ) REFERENCES ` websiteFunctions_websites ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `IncBackups_jobsites` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` website ` varchar ( 300 ) NOT NULL ,
` job_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` IncBackups_jobsites_job_id_494a1f69_fk_IncBackups_backupjob_id ` ( ` job_id ` ) ,
CONSTRAINT ` IncBackups_jobsites_job_id_494a1f69_fk_IncBackups_backupjob_id ` FOREIGN KEY ( ` job_id ` ) REFERENCES ` IncBackups_backupjob ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `IncBackups_jobsnapshots` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` type ` varchar ( 300 ) NOT NULL ,
` snapshotid ` varchar ( 50 ) NOT NULL ,
` job_id ` int ( 11 ) NOT NULL ,
` destination ` varchar ( 200 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` IncBackups_jobsnapshots_job_id_a8237ca8_fk_IncBackups_incjob_id ` ( ` job_id ` ) ,
CONSTRAINT ` IncBackups_jobsnapshots_job_id_a8237ca8_fk_IncBackups_incjob_id ` FOREIGN KEY ( ` job_id ` ) REFERENCES ` IncBackups_incjob ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
2020-03-19 11:39:10 +05:00
query = """ CREATE TABLE `websiteFunctions_gitlogs` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` date ` datetime ( 6 ) NOT NULL ,
` type ` varchar ( 5 ) NOT NULL ,
` message ` longtext NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` websiteFunctions_git_owner_id_ce74c7de_fk_websiteFu ` ( ` owner_id ` ) ,
CONSTRAINT ` websiteFunctions_git_owner_id_ce74c7de_fk_websiteFu ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` websiteFunctions_websites ` ( ` id ` )
) """
2020-05-20 22:13:06 +05:00
try :
cursor . execute ( query )
except :
pass
2020-05-26 16:11:35 +05:00
query = """ CREATE TABLE `websiteFunctions_backupjob` (
2020-05-20 22:13:06 +05:00
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` logFile ` varchar ( 1000 ) NOT NULL ,
` ipAddress ` varchar ( 50 ) NOT NULL ,
` port ` varchar ( 15 ) NOT NULL ,
2020-05-20 22:23:21 +05:00
` jobFailedSites ` int ( 11 ) NOT NULL ,
` jobSuccessSites ` int ( 11 ) NOT NULL ,
2020-05-20 22:35:54 +05:00
` location ` int ( 11 ) NOT NULL ,
2020-05-20 22:13:06 +05:00
PRIMARY KEY ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `websiteFunctions_backupjoblogs` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` message ` longtext NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
2020-05-20 22:23:21 +05:00
` status ` int ( 11 ) NOT NULL ,
2020-05-20 22:13:06 +05:00
PRIMARY KEY ( ` id ` ) ,
KEY ` websiteFunctions_bac_owner_id_af3d15f9_fk_websiteFu ` ( ` owner_id ` ) ,
CONSTRAINT ` websiteFunctions_bac_owner_id_af3d15f9_fk_websiteFu ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` websiteFunctions_backupjob ` ( ` id ` )
) """
2020-06-14 13:14:28 +05:00
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `websiteFunctions_gdrive` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 50 ) NOT NULL ,
` auth ` longtext NOT NULL ,
` runTime ` varchar ( 20 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
UNIQUE KEY ` name ` ( ` name ` ) ,
KEY ` websiteFunctions_gdr_owner_id_b5b1e86f_fk_loginSyst ` ( ` owner_id ` ) ,
CONSTRAINT ` websiteFunctions_gdr_owner_id_b5b1e86f_fk_loginSyst ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` loginSystem_administrator ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `websiteFunctions_gdrivesites` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` domain ` varchar ( 200 ) NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` websiteFunctions_gdr_owner_id_ff78b305_fk_websiteFu ` ( ` owner_id ` ) ,
CONSTRAINT ` websiteFunctions_gdr_owner_id_ff78b305_fk_websiteFu ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` websiteFunctions_gdrive ` ( ` id ` )
) """
try :
cursor . execute ( query )
except :
pass
query = """ CREATE TABLE `websiteFunctions_gdrivejoblogs` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` status ` int ( 11 ) NOT NULL ,
` message ` longtext NOT NULL ,
` owner_id ` int ( 11 ) NOT NULL ,
PRIMARY KEY ( ` id ` ) ,
KEY ` websiteFunctions_gdr_owner_id_4cf7983e_fk_websiteFu ` ( ` owner_id ` ) ,
CONSTRAINT ` websiteFunctions_gdr_owner_id_4cf7983e_fk_websiteFu ` FOREIGN KEY ( ` owner_id ` ) REFERENCES ` websiteFunctions_gdrive ` ( ` id ` )
) """
2020-03-19 11:39:10 +05:00
try :
cursor . execute ( query )
except :
pass
2019-10-15 22:59:22 +05:00
try :
connection . close ( )
except :
pass
except :
pass
2018-08-21 13:10:40 +05:00
@staticmethod
def enableServices ( ) :
try :
servicePath = ' /home/cyberpanel/powerdns '
writeToFile = open ( servicePath , ' w+ ' )
writeToFile . close ( )
2018-07-19 22:38:37 +05:00
2018-08-21 13:10:40 +05:00
servicePath = ' /home/cyberpanel/postfix '
writeToFile = open ( servicePath , ' w+ ' )
writeToFile . close ( )
2017-10-24 19:16:36 +05:00
2018-08-21 13:10:40 +05:00
servicePath = ' /home/cyberpanel/pureftpd '
writeToFile = open ( servicePath , ' w+ ' )
writeToFile . close ( )
except :
pass
2018-07-26 04:11:10 +05:00
2018-08-21 13:10:40 +05:00
@staticmethod
2020-01-02 14:32:02 +05:00
def downloadAndUpgrade ( versionNumbring , branch ) :
2018-08-21 13:10:40 +05:00
try :
## Download latest version.
2018-07-19 22:38:37 +05:00
2018-08-21 13:10:40 +05:00
## Backup settings file.
2018-07-19 22:38:37 +05:00
2018-08-21 13:10:40 +05:00
Upgrade . stdOut ( " Backing up settings file. " )
2017-10-24 19:16:36 +05:00
2020-04-12 13:01:24 +05:00
## CyberPanel DB Creds
dbName = settings . DATABASES [ ' default ' ] [ ' NAME ' ]
dbUser = settings . DATABASES [ ' default ' ] [ ' USER ' ]
password = settings . DATABASES [ ' default ' ] [ ' PASSWORD ' ]
2020-07-06 12:57:22 +05:00
host = settings . DATABASES [ ' default ' ] [ ' HOST ' ]
port = settings . DATABASES [ ' default ' ] [ ' PORT ' ]
2020-04-12 13:01:24 +05:00
## Root DB Creds
rootdbName = settings . DATABASES [ ' rootdb ' ] [ ' NAME ' ]
rootdbdbUser = settings . DATABASES [ ' rootdb ' ] [ ' USER ' ]
rootdbpassword = settings . DATABASES [ ' rootdb ' ] [ ' PASSWORD ' ]
## Complete db string
completDBString = """ \n DATABASES = {
' default ' : {
' ENGINE ' : ' django.db.backends.mysql ' ,
' NAME ' : ' %s ' ,
' USER ' : ' %s ' ,
' PASSWORD ' : ' %s ' ,
2020-07-06 12:57:22 +05:00
' HOST ' : ' %s ' ,
' PORT ' : ' %s '
2020-04-12 13:01:24 +05:00
} ,
' rootdb ' : {
' ENGINE ' : ' django.db.backends.mysql ' ,
' NAME ' : ' %s ' ,
' USER ' : ' %s ' ,
' PASSWORD ' : ' %s ' ,
2020-07-06 12:57:22 +05:00
' HOST ' : ' %s ' ,
' PORT ' : ' %s ' ,
2020-04-12 13:01:24 +05:00
} ,
2020-07-06 12:57:22 +05:00
} \n """ % (dbName, dbUser, password, host, port, rootdbName, rootdbdbUser, rootdbpassword, host, port)
2020-04-12 13:01:24 +05:00
settingsFile = ' /usr/local/CyberCP/CyberCP/settings.py '
2018-08-21 13:10:40 +05:00
Upgrade . stdOut ( " Settings file backed up. " )
2017-10-24 19:16:36 +05:00
2020-04-12 13:01:24 +05:00
## Check git branch status
2017-10-24 19:16:36 +05:00
2020-04-11 15:31:01 +05:00
os . chdir ( ' /usr/local/CyberCP ' )
2019-11-07 14:47:02 +05:00
2020-06-24 14:08:01 +06:00
command = ' git config --global user.email " support@cyberpanel.net " '
2021-03-24 12:31:56 +05:00
if not Upgrade . executioner ( command , command , 1 ) :
return 0 , ' Failed to execute %s ' % ( command )
2020-03-21 00:14:39 +05:00
2020-04-11 15:31:01 +05:00
command = ' git config --global user.name " CyberPanel " '
2021-03-24 12:31:56 +05:00
if not Upgrade . executioner ( command , command , 1 ) :
return 0 , ' Failed to execute %s ' % ( command )
2020-03-21 00:14:39 +05:00
2020-04-11 15:31:01 +05:00
command = ' git status '
currentBranch = subprocess . check_output ( shlex . split ( command ) ) . decode ( )
2020-03-21 00:14:39 +05:00
2021-02-21 13:09:50 +05:00
if currentBranch . find ( ' On branch %s ' % ( branch ) ) > - 1 and currentBranch . find (
' On branch %s -dev ' % ( branch ) ) == - 1 :
2020-03-21 00:14:39 +05:00
2020-04-11 15:31:01 +05:00
command = ' git stash '
2021-03-24 12:31:56 +05:00
if not Upgrade . executioner ( command , command , 1 ) :
return 0 , ' Failed to execute %s ' % ( command )
2019-11-07 17:13:55 +05:00
2020-04-11 15:31:01 +05:00
command = ' git pull '
2021-03-24 12:31:56 +05:00
if not Upgrade . executioner ( command , command , 1 ) :
return 0 , ' Failed to execute %s ' % ( command )
2019-11-07 14:47:02 +05:00
2020-04-11 18:53:11 +05:00
elif currentBranch . find ( ' not a git repository ' ) > - 1 :
os . chdir ( ' /usr/local ' )
command = ' git clone https://github.com/usmannasir/cyberpanel '
2021-03-24 12:31:56 +05:00
if not Upgrade . executioner ( command , command , 1 ) :
return 0 , ' Failed to execute %s ' % ( command )
2020-04-11 18:53:11 +05:00
if os . path . exists ( ' CyberCP ' ) :
shutil . rmtree ( ' CyberCP ' )
shutil . move ( ' cyberpanel ' , ' CyberCP ' )
2020-04-11 15:31:01 +05:00
else :
2020-04-12 11:26:21 +05:00
command = ' git fetch '
2021-03-24 12:31:56 +05:00
if not Upgrade . executioner ( command , command , 1 ) :
return 0 , ' Failed to execute %s ' % ( command )
2020-04-12 11:26:21 +05:00
2020-04-11 15:31:01 +05:00
command = ' git stash '
2021-03-24 12:31:56 +05:00
if not Upgrade . executioner ( command , command , 1 ) :
return 0 , ' Failed to execute %s ' % ( command )
2019-11-07 14:47:02 +05:00
2020-01-02 14:32:02 +05:00
command = ' git checkout %s ' % ( branch )
2021-03-24 12:31:56 +05:00
if not Upgrade . executioner ( command , command , 1 ) :
return 0 , ' Failed to execute %s ' % ( command )
2020-04-11 15:31:01 +05:00
command = ' git pull '
2021-03-24 12:31:56 +05:00
if not Upgrade . executioner ( command , command , 1 ) :
return 0 , ' Failed to execute %s ' % ( command )
2020-04-11 15:31:01 +05:00
2018-08-21 13:10:40 +05:00
## Copy settings file
2018-11-14 13:36:34 +05:00
2020-04-12 13:29:10 +05:00
settingsData = open ( settingsFile , ' r ' ) . readlines ( )
2020-04-12 13:01:24 +05:00
DATABASESCHECK = 0
writeToFile = open ( settingsFile , ' w ' )
2018-10-12 18:18:10 +05:00
2020-04-12 13:01:24 +05:00
for items in settingsData :
if items . find ( ' DATABASES = { ' ) > - 1 :
DATABASESCHECK = 1
2019-02-09 14:01:43 +05:00
2020-04-12 13:01:24 +05:00
if DATABASESCHECK == 0 :
writeToFile . write ( items )
2019-10-15 22:59:22 +05:00
2020-04-12 13:01:24 +05:00
if items . find ( ' DATABASE_ROUTERS = [ ' ) > - 1 :
DATABASESCHECK = 0
writeToFile . write ( completDBString )
writeToFile . write ( items )
2019-11-06 23:37:32 +05:00
2018-08-21 13:10:40 +05:00
writeToFile . close ( )
2017-10-24 19:16:36 +05:00
2018-08-21 13:10:40 +05:00
Upgrade . stdOut ( ' Settings file restored! ' )
2017-10-24 19:16:36 +05:00
2018-08-21 13:10:40 +05:00
Upgrade . staticContent ( )
2020-03-21 00:14:39 +05:00
2021-03-22 20:13:57 +05:00
return 1 , None
except BaseException as msg :
return 0 , str ( msg )
2017-10-24 19:16:36 +05:00
2018-10-12 18:18:10 +05:00
@staticmethod
2020-02-13 16:16:02 +05:00
def installLSCPD ( branch ) :
2018-10-12 18:18:10 +05:00
try :
Upgrade . stdOut ( " Starting LSCPD installation.. " )
2018-12-17 18:46:34 +05:00
cwd = os . getcwd ( )
os . chdir ( ' /usr/local ' )
2018-12-14 05:01:10 +05:00
command = ' yum -y install gcc gcc-c++ make autoconf glibc rcs '
Upgrade . executioner ( command , ' LSCPD Pre-reqs [one] ' , 0 )
2018-10-12 18:18:10 +05:00
2018-12-14 05:01:10 +05:00
##
2018-10-12 18:18:10 +05:00
2019-07-16 23:23:16 +05:00
lscpdPath = ' /usr/local/lscp/bin/lscpd '
2018-10-12 18:18:10 +05:00
2019-07-16 23:23:16 +05:00
if os . path . exists ( lscpdPath ) :
os . remove ( lscpdPath )
2018-12-24 20:21:14 +05:00
2022-10-06 14:19:28 +05:00
2022-10-06 13:52:17 +05:00
lscpdSelection = ' lscpd-0.3.1 '
2022-10-06 14:17:57 +05:00
if os . path . exists ( Upgrade . UbuntuPath ) :
2022-10-06 14:19:28 +05:00
result = open ( Upgrade . UbuntuPath , ' r ' ) . read ( )
2022-10-06 14:17:57 +05:00
if result . find ( ' 22.04 ' ) > - 1 :
lscpdSelection = ' lscpd.0.4.0 '
2022-10-06 13:52:17 +05:00
command = f ' cp -f /usr/local/CyberCP/ { lscpdSelection } /usr/local/lscp/bin/ { lscpdSelection } '
2020-01-22 16:27:06 +05:00
Upgrade . executioner ( command , command , 0 )
command = ' rm -f /usr/local/lscp/bin/lscpd '
Upgrade . executioner ( command , command , 0 )
2022-10-06 13:52:17 +05:00
command = f ' mv /usr/local/lscp/bin/ { lscpdSelection } /usr/local/lscp/bin/lscpd '
2020-01-22 16:27:06 +05:00
Upgrade . executioner ( command , command , 0 )
2018-10-12 18:18:10 +05:00
2021-10-17 22:06:33 +06:00
command = f ' chmod 755 { lscpdPath } '
2019-07-16 23:23:16 +05:00
Upgrade . executioner ( command , ' LSCPD Download. ' , 0 )
2018-10-12 18:18:10 +05:00
2019-07-16 23:23:16 +05:00
command = ' yum -y install pcre-devel openssl-devel expat-devel geoip-devel zlib-devel udns-devel which curl '
Upgrade . executioner ( command , ' LSCPD Pre-reqs [two] ' , 0 )
2019-04-22 03:38:40 +05:00
2021-10-17 22:06:33 +06:00
try :
pwd . getpwnam ( ' lscpd ' )
except KeyError :
command = ' adduser lscpd -M -d /usr/local/lscp '
Upgrade . executioner ( command , ' Add user LSCPD ' , 0 )
2018-10-12 18:18:10 +05:00
2021-10-17 22:06:33 +06:00
try :
grp . getgrnam ( ' lscpd ' )
except KeyError :
command = ' groupadd lscpd '
Upgrade . executioner ( command , ' Add group LSCPD ' , 0 )
2018-10-12 18:18:10 +05:00
command = ' usermod -a -G lscpd lscpd '
2018-12-14 05:01:10 +05:00
Upgrade . executioner ( command , ' Add group LSCPD ' , 0 )
2018-10-12 18:18:10 +05:00
command = ' usermod -a -G lsadm lscpd '
2018-12-14 05:01:10 +05:00
Upgrade . executioner ( command , ' Add group LSCPD ' , 0 )
2018-10-12 18:18:10 +05:00
command = ' systemctl daemon-reload '
2018-12-14 05:01:10 +05:00
Upgrade . executioner ( command , ' daemon-reload LSCPD ' , 0 )
2018-10-12 18:18:10 +05:00
command = ' systemctl restart lscpd '
2018-12-14 05:01:10 +05:00
Upgrade . executioner ( command , ' Restart LSCPD ' , 0 )
2018-10-12 18:18:10 +05:00
2018-12-17 18:46:34 +05:00
os . chdir ( cwd )
2018-10-12 18:18:10 +05:00
Upgrade . stdOut ( " LSCPD successfully installed! " )
2019-12-10 15:09:10 +05:00
except BaseException as msg :
2018-10-12 18:18:10 +05:00
Upgrade . stdOut ( str ( msg ) + " [installLSCPD] " )
2018-07-19 22:38:37 +05:00
2018-11-26 02:32:30 +05:00
@staticmethod
def fixPermissions ( ) :
try :
2020-10-04 13:08:02 +05:00
try :
2020-10-04 13:15:25 +05:00
def generate_pass ( length = 14 ) :
chars = string . ascii_uppercase + string . ascii_lowercase + string . digits
size = length
return ' ' . join ( random . choice ( chars ) for x in range ( size ) )
2020-10-04 13:08:02 +05:00
content = """ <?php
2022-04-29 00:27:41 +02:00
$ _ENV [ ' snappymail_INCLUDE_AS_API ' ] = true ;
include ' /usr/local/CyberCP/public/snappymail/index.php ' ;
2020-10-04 13:08:02 +05:00
2022-04-29 00:27:41 +02:00
$ oConfig = \snappymail \Api : : Config ( ) ;
2020-10-04 13:08:02 +05:00
$ oConfig - > SetPassword ( ' %s ' ) ;
echo $ oConfig - > Save ( ) ? ' Done ' : ' Error ' ;
2020-10-04 13:15:25 +05:00
? > """ % (generate_pass())
2020-10-04 13:08:02 +05:00
2022-04-29 00:27:41 +02:00
writeToFile = open ( ' /usr/local/CyberCP/public/snappymail.php ' , ' w ' )
2020-10-04 13:08:02 +05:00
writeToFile . write ( content )
writeToFile . close ( )
2020-10-05 22:22:28 +05:00
2022-04-29 00:27:41 +02:00
command = " chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/snappymail/data "
2020-10-05 22:22:28 +05:00
subprocess . call ( shlex . split ( command ) )
2020-10-04 13:08:02 +05:00
except :
pass
2018-11-26 02:32:30 +05:00
Upgrade . stdOut ( " Fixing permissions.. " )
2019-04-15 15:54:23 +05:00
command = " usermod -G lscpd,lsadm,nobody lscpd "
Upgrade . executioner ( command , ' chown core code ' , 0 )
command = " usermod -G lscpd,lsadm,nogroup lscpd "
Upgrade . executioner ( command , ' chown core code ' , 0 )
###### fix Core CyberPanel permissions
2019-03-26 16:19:03 +05:00
command = " find /usr/local/CyberCP -type d -exec chmod 0755 {} \ ; "
2018-12-14 05:01:10 +05:00
Upgrade . executioner ( command , ' chown core code ' , 0 )
2018-11-26 02:32:30 +05:00
2019-03-26 16:19:03 +05:00
command = " find /usr/local/CyberCP -type f -exec chmod 0644 {} \ ; "
Upgrade . executioner ( command , ' chown core code ' , 0 )
command = " chmod -R 755 /usr/local/CyberCP/bin "
Upgrade . executioner ( command , ' chown core code ' , 0 )
2019-04-15 15:54:23 +05:00
## change owner
2019-03-26 16:19:03 +05:00
command = " chown -R root:root /usr/local/CyberCP "
Upgrade . executioner ( command , ' chown core code ' , 0 )
2018-11-26 02:32:30 +05:00
2019-04-15 15:54:23 +05:00
########### Fix LSCPD
command = " find /usr/local/lscp -type d -exec chmod 0755 {} \ ; "
Upgrade . executioner ( command , ' chown core code ' , 0 )
command = " find /usr/local/lscp -type f -exec chmod 0644 {} \ ; "
Upgrade . executioner ( command , ' chown core code ' , 0 )
command = " chmod -R 755 /usr/local/lscp/bin "
Upgrade . executioner ( command , ' chown core code ' , 0 )
command = " chmod -R 755 /usr/local/lscp/fcgi-bin "
Upgrade . executioner ( command , ' chown core code ' , 0 )
command = " chown -R lscpd:lscpd /usr/local/CyberCP/public/phpmyadmin/tmp "
Upgrade . executioner ( command , ' chown core code ' , 0 )
## change owner
command = " chown -R root:root /usr/local/lscp "
Upgrade . executioner ( command , ' chown core code ' , 0 )
2022-05-20 15:54:07 +05:00
command = " chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop "
2019-04-15 15:54:23 +05:00
Upgrade . executioner ( command , ' chown core code ' , 0 )
command = " chmod 700 /usr/local/CyberCP/cli/cyberPanel.py "
Upgrade . executioner ( command , ' chown core code ' , 0 )
command = " chmod 700 /usr/local/CyberCP/plogical/upgradeCritical.py "
Upgrade . executioner ( command , ' chown core code ' , 0 )
2019-12-02 16:40:00 +05:00
command = " chmod 755 /usr/local/CyberCP/postfixSenderPolicy/client.py "
2019-04-15 15:54:23 +05:00
Upgrade . executioner ( command , ' chown core code ' , 0 )
2019-04-22 03:38:40 +05:00
command = " chmod 640 /usr/local/CyberCP/CyberCP/settings.py "
Upgrade . executioner ( command , ' chown core code ' , 0 )
command = " chown root:cyberpanel /usr/local/CyberCP/CyberCP/settings.py "
2019-04-15 15:54:23 +05:00
Upgrade . executioner ( command , ' chown core code ' , 0 )
2018-11-26 02:32:30 +05:00
2019-07-16 23:23:16 +05:00
command = ' chmod +x /usr/local/CyberCP/CLManager/CLPackages.py '
Upgrade . executioner ( command , ' chmod CLPackages ' , 0 )
files = [ ' /etc/yum.repos.d/MariaDB.repo ' , ' /etc/pdns/pdns.conf ' , ' /etc/systemd/system/lscpd.service ' ,
' /etc/pure-ftpd/pure-ftpd.conf ' , ' /etc/pure-ftpd/pureftpd-pgsql.conf ' ,
' /etc/pure-ftpd/pureftpd-mysql.conf ' , ' /etc/pure-ftpd/pureftpd-ldap.conf ' ,
' /etc/dovecot/dovecot.conf ' , ' /usr/local/lsws/conf/httpd_config.xml ' ,
' /usr/local/lsws/conf/modsec.conf ' , ' /usr/local/lsws/conf/httpd.conf ' ]
for items in files :
command = ' chmod 644 %s ' % ( items )
Upgrade . executioner ( command , ' chown core code ' , 0 )
impFile = [ ' /etc/pure-ftpd/pure-ftpd.conf ' , ' /etc/pure-ftpd/pureftpd-pgsql.conf ' ,
' /etc/pure-ftpd/pureftpd-mysql.conf ' , ' /etc/pure-ftpd/pureftpd-ldap.conf ' ,
2019-08-03 14:53:31 +05:00
' /etc/dovecot/dovecot.conf ' , ' /etc/pdns/pdns.conf ' , ' /etc/pure-ftpd/db/mysql.conf ' ,
' /etc/powerdns/pdns.conf ' ]
2019-07-16 23:23:16 +05:00
for items in impFile :
command = ' chmod 600 %s ' % ( items )
Upgrade . executioner ( command , ' chown core code ' , 0 )
command = ' chmod 640 /etc/postfix/*.cf '
subprocess . call ( command , shell = True )
command = ' chmod 640 /etc/dovecot/*.conf '
subprocess . call ( command , shell = True )
command = ' chmod 640 /etc/dovecot/dovecot-sql.conf.ext '
subprocess . call ( command , shell = True )
fileM = [ ' /usr/local/lsws/FileManager/ ' , ' /usr/local/CyberCP/install/FileManager ' ,
' /usr/local/CyberCP/serverStatus/litespeed/FileManager ' ,
' /usr/local/lsws/Example/html/FileManager ' ]
for items in fileM :
try :
shutil . rmtree ( items )
except :
pass
command = ' chmod 755 /etc/pure-ftpd/ '
subprocess . call ( command , shell = True )
command = ' chmod 644 /etc/dovecot/dovecot.conf '
subprocess . call ( command , shell = True )
command = ' chmod 644 /etc/postfix/main.cf '
subprocess . call ( command , shell = True )
2019-08-28 02:25:39 +05:00
command = ' chmod 644 /etc/postfix/dynamicmaps.cf '
subprocess . call ( command , shell = True )
2019-12-04 14:40:59 +05:00
command = ' chmod +x /usr/local/CyberCP/plogical/renew.py '
Upgrade . executioner ( command , command , 0 )
2019-12-22 12:08:24 +05:00
command = ' chmod +x /usr/local/CyberCP/CLManager/CLPackages.py '
Upgrade . executioner ( command , command , 0 )
2021-02-21 13:09:50 +05:00
clScripts = [ ' /usr/local/CyberCP/CLScript/panel_info.py ' ,
' /usr/local/CyberCP/CLScript/CloudLinuxPackages.py ' ,
' /usr/local/CyberCP/CLScript/CloudLinuxUsers.py ' ,
' /usr/local/CyberCP/CLScript/CloudLinuxDomains.py '
, ' /usr/local/CyberCP/CLScript/CloudLinuxResellers.py ' ,
' /usr/local/CyberCP/CLScript/CloudLinuxAdmins.py ' ,
2019-12-31 19:55:29 +05:00
' /usr/local/CyberCP/CLScript/CloudLinuxDB.py ' , ' /usr/local/CyberCP/CLScript/UserInfo.py ' ]
2019-12-28 18:01:12 +05:00
for items in clScripts :
command = ' chmod +x %s ' % ( items )
Upgrade . executioner ( command , 0 )
2020-01-14 16:34:06 +05:00
command = ' chmod 600 /usr/local/CyberCP/plogical/adminPass.py '
Upgrade . executioner ( command , 0 )
2020-01-29 17:27:43 +05:00
command = ' chmod 600 /etc/cagefs/exclude/cyberpanelexclude '
Upgrade . executioner ( command , 0 )
2020-01-19 15:43:59 +05:00
command = " find /usr/local/CyberCP/ -name ' *.pyc ' -delete "
Upgrade . executioner ( command , 0 )
2020-01-17 14:17:44 +05:00
2022-06-25 02:14:01 +08:00
if os . path . exists ( Upgrade . CentOSPath ) or os . path . exists ( Upgrade . openEulerPath ) :
2020-09-16 18:06:38 +05:00
command = ' chown root:pdns /etc/pdns/pdns.conf '
Upgrade . executioner ( command , 0 )
command = ' chmod 640 /etc/pdns/pdns.conf '
Upgrade . executioner ( command , 0 )
2022-09-26 23:04:42 +05:00
else :
2022-09-26 23:34:49 +05:00
command = ' chown root:pdns /etc/powerdns/pdns.conf '
2022-09-26 23:04:42 +05:00
Upgrade . executioner ( command , 0 )
command = ' chmod 640 /etc/powerdns/pdns.conf '
Upgrade . executioner ( command , 0 )
2020-06-22 11:14:16 +05:00
2020-09-16 21:06:04 +05:00
command = ' chmod 640 /usr/local/lscp/cyberpanel/logs/access.log '
Upgrade . executioner ( command , 0 )
2022-04-29 00:27:41 +02:00
command = ' /usr/local/lsws/lsphp72/bin/php /usr/local/CyberCP/public/snappymail.php '
2020-10-04 13:08:02 +05:00
Upgrade . executioner ( command , 0 )
2022-04-29 00:27:41 +02:00
command = ' chmod 600 /usr/local/CyberCP/public/snappymail.php '
2021-07-29 13:06:20 +05:00
Upgrade . executioner ( command , 0 )
2021-07-29 16:21:50 +05:00
###
WriteToFile = open ( ' /etc/fstab ' , ' a ' )
WriteToFile . write ( ' proc /proc proc defaults,hidepid=2 0 0 \n ' )
WriteToFile . close ( )
command = ' mount -o remount,rw,hidepid=2 /proc '
Upgrade . executioner ( command , 0 )
###
2021-07-31 16:54:47 +05:00
CentOSPath = ' /etc/redhat-release '
2022-06-25 02:14:01 +08:00
openEulerPath = ' /etc/openEuler-release '
2021-07-31 16:54:47 +05:00
2022-06-25 02:14:01 +08:00
if not os . path . exists ( CentOSPath ) or not os . path . exists ( openEulerPath ) :
2021-07-31 16:54:47 +05:00
group = ' nobody '
else :
group = ' nogroup '
command = ' chown root: %s /usr/local/lsws/logs ' % ( group )
Upgrade . executioner ( command , 0 )
command = ' chmod 750 /usr/local/lsws/logs '
Upgrade . executioner ( command , 0 )
2021-08-20 20:25:28 +05:00
## symlink protection
writeToFile = open ( ' /usr/lib/sysctl.d/50-default.conf ' , ' a ' )
writeToFile . writelines ( ' fs.protected_hardlinks = 1 \n ' )
writeToFile . writelines ( ' fs.protected_symlinks = 1 \n ' )
writeToFile . close ( )
command = ' sysctl --system '
Upgrade . executioner ( command , 0 )
2021-10-05 11:28:04 +05:00
command = ' chmod 700 %s ' % ( ' /home/cyberpanel ' )
Upgrade . executioner ( command , 0 )
2021-12-28 19:17:25 +05:00
destPrivKey = " /usr/local/lscp/conf/key.pem "
command = ' chmod 600 %s ' % ( destPrivKey )
Upgrade . executioner ( command , 0 )
2018-11-26 02:32:30 +05:00
Upgrade . stdOut ( " Permissions updated. " )
2019-12-10 15:09:10 +05:00
except BaseException as msg :
2018-12-14 05:01:10 +05:00
Upgrade . stdOut ( str ( msg ) + " [installLSCPD] " )
2018-11-26 02:32:30 +05:00
2019-12-04 14:40:59 +05:00
@staticmethod
def AutoUpgradeAcme ( ) :
command = ' /root/.acme.sh/acme.sh --upgrade --auto-upgrade '
Upgrade . executioner ( command , command , 0 )
2021-06-14 16:52:28 +05:00
command = ' /root/.acme.sh/acme.sh --set-default-ca --server letsencrypt '
Upgrade . executioner ( command , command , 0 )
2019-12-04 14:40:59 +05:00
2018-12-20 16:18:16 +05:00
@staticmethod
def installPHP73 ( ) :
try :
2020-04-11 11:31:13 +05:00
if Upgrade . installedOutput . find ( ' lsphp73 ' ) == - 1 :
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-odbc lsphp73-mysqlnd lsphp73-mcrypt lsphp73-mbstring lsphp73-ldap lsphp73-intl lsphp73-imap ' \
' lsphp73-gmp lsphp73-gd lsphp73-enchant lsphp73-dba lsphp73-common lsphp73-bcmath '
Upgrade . executioner ( command , ' Install PHP 73, 0 ' )
if Upgrade . installedOutput . find ( ' lsphp74 ' ) == - 1 :
command = ' yum install -y lsphp74 lsphp74-json lsphp74-xmlrpc lsphp74-xml lsphp74-tidy lsphp74-soap lsphp74-snmp ' \
' lsphp74-recode lsphp74-pspell lsphp74-process lsphp74-pgsql lsphp74-pear lsphp74-pdo lsphp74-opcache ' \
' lsphp74-odbc lsphp74-mysqlnd lsphp74-mcrypt lsphp74-mbstring lsphp74-ldap lsphp74-intl lsphp74-imap ' \
' lsphp74-gmp lsphp74-gd lsphp74-enchant lsphp74-dba lsphp74-common lsphp74-bcmath '
Upgrade . executioner ( command , ' Install PHP 74, 0 ' )
2019-12-26 15:52:55 +05:00
2020-12-02 19:21:57 +05:00
if Upgrade . installedOutput . find ( ' lsphp80 ' ) == - 1 :
2020-12-03 11:04:06 +05:00
command = ' yum install lsphp80* -y '
2020-12-02 19:21:57 +05:00
subprocess . call ( command , shell = True )
2021-12-25 12:41:38 +05:00
if Upgrade . installedOutput . find ( ' lsphp81 ' ) == - 1 :
2021-12-25 12:40:45 +05:00
command = ' yum install lsphp81* -y '
subprocess . call ( command , shell = True )
2018-12-20 16:18:16 +05:00
except :
command = ' DEBIAN_FRONTEND=noninteractive apt-get -y install ' \
' lsphp7? lsphp7?-common lsphp7?-curl lsphp7?-dev lsphp7?-imap lsphp7?-intl lsphp7?-json ' \
' lsphp7?-ldap lsphp7?-mysql lsphp7?-opcache lsphp7?-pspell lsphp7?-recode ' \
' lsphp7?-sqlite3 lsphp7?-tidy '
Upgrade . executioner ( command , ' Install PHP 73, 0 ' )
2020-12-03 11:40:45 +05:00
command = ' DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp80* '
os . system ( command )
2020-12-02 19:21:57 +05:00
2021-12-25 12:40:45 +05:00
command = ' DEBIAN_FRONTEND=noninteractive apt-get -y install lsphp81* '
os . system ( command )
2019-08-03 14:53:31 +05:00
CentOSPath = ' /etc/redhat-release '
2022-06-25 02:14:01 +08:00
openEulerPath = ' /etc/openEuler-release '
2019-08-03 14:53:31 +05:00
2022-11-14 13:50:27 +05:00
#if not os.path.exists(CentOSPath) or not os.path.exists(openEulerPath):
#command = 'cp /usr/local/lsws/lsphp71/bin/php /usr/bin/'
#Upgrade.executioner(command, 'Set default PHP 7.0, 0')
2019-04-15 15:54:23 +05:00
@staticmethod
def someDirectories ( ) :
command = " mkdir -p /usr/local/lscpd/admin/ "
Upgrade . executioner ( command , 0 )
command = " mkdir -p /usr/local/lscp/cyberpanel/logs "
Upgrade . executioner ( command , 0 )
2019-07-03 13:15:26 +05:00
@staticmethod
def upgradeDovecot ( ) :
2019-07-25 14:12:54 +05:00
try :
Upgrade . stdOut ( " Upgrading Dovecot.. " )
CentOSPath = ' /etc/redhat-release '
2022-06-25 02:14:01 +08:00
openEulerPath = ' /etc/openEuler-release '
2019-07-25 14:12:54 +05:00
2020-09-16 19:25:59 +05:00
dovecotConfPath = ' /etc/dovecot/ '
postfixConfPath = ' /etc/postfix/ '
2019-07-03 13:15:26 +05:00
2020-09-16 19:25:59 +05:00
## Take backup of configurations
2020-06-10 22:35:52 +05:00
2020-09-16 19:25:59 +05:00
configbackups = ' /home/cyberpanel/configbackups '
2019-07-03 13:15:26 +05:00
2020-09-16 19:25:59 +05:00
command = ' mkdir %s ' % ( configbackups )
Upgrade . executioner ( command , 0 )
2019-07-03 13:15:26 +05:00
2020-09-16 20:00:56 +05:00
command = ' cp -pR %s %s ' % ( dovecotConfPath , configbackups )
2020-09-16 19:25:59 +05:00
Upgrade . executioner ( command , 0 )
2020-06-11 10:27:04 +05:00
2020-09-16 20:00:56 +05:00
command = ' cp -pR %s %s ' % ( postfixConfPath , configbackups )
2020-09-16 19:25:59 +05:00
Upgrade . executioner ( command , 0 )
2020-06-11 10:27:04 +05:00
2022-06-25 02:14:01 +08:00
if Upgrade . FindOperatingSytem ( ) == CENTOS8 or Upgrade . FindOperatingSytem ( ) == CENTOS7 or Upgrade . FindOperatingSytem ( ) == openEuler22 or Upgrade . FindOperatingSytem ( ) == openEuler20 :
2020-06-11 10:55:51 +05:00
2020-09-03 12:44:32 +05:00
command = " yum makecache -y "
Upgrade . executioner ( command , 0 )
2019-07-03 13:15:26 +05:00
2020-09-03 12:44:32 +05:00
command = " yum update -y "
Upgrade . executioner ( command , 0 )
2019-07-03 13:15:26 +05:00
2021-02-21 16:10:33 +05:00
if Upgrade . FindOperatingSytem ( ) == CENTOS8 :
2020-09-03 12:44:32 +05:00
command = ' dnf remove dovecot23 dovecot23-mysql -y '
Upgrade . executioner ( command , 0 )
2019-07-16 23:23:16 +05:00
2020-09-03 12:44:32 +05:00
command = ' dnf install --enablerepo=gf-plus dovecot23 dovecot23-mysql -y '
Upgrade . executioner ( command , 0 )
2020-01-02 14:45:11 +05:00
import django
os . environ . setdefault ( " DJANGO_SETTINGS_MODULE " , " CyberCP.settings " )
django . setup ( )
from mailServer . models import EUsers
2019-08-25 14:06:28 +05:00
Upgrade . stdOut ( " Upgrading passwords... " )
for items in EUsers . objects . all ( ) :
if items . password . find ( ' CRYPT ' ) > - 1 :
continue
command = ' doveadm pw -p %s ' % ( items . password )
2019-12-15 13:30:40 +05:00
items . password = subprocess . check_output ( shlex . split ( command ) ) . decode ( " utf-8 " ) . strip ( ' \n ' )
2019-08-25 14:06:28 +05:00
items . save ( )
2019-07-03 13:15:26 +05:00
2019-07-25 14:12:54 +05:00
command = " systemctl restart dovecot "
Upgrade . executioner ( command , 0 )
2019-08-30 20:15:09 +05:00
### Postfix Upgrade
2020-09-03 12:44:32 +05:00
command = ' yum remove postfix -y '
Upgrade . executioner ( command , 0 )
2019-08-30 20:15:09 +05:00
2020-09-03 12:44:32 +05:00
command = ' yum clean all '
Upgrade . executioner ( command , 0 )
2019-08-30 20:15:09 +05:00
2021-02-21 16:10:33 +05:00
if Upgrade . FindOperatingSytem ( ) == CENTOS7 :
2020-09-03 12:44:32 +05:00
command = ' yum makecache fast '
else :
command = ' yum makecache -y '
2020-06-10 22:35:52 +05:00
2020-09-03 12:44:32 +05:00
Upgrade . executioner ( command , 0 )
2019-08-30 20:15:09 +05:00
2021-02-21 16:10:33 +05:00
if Upgrade . FindOperatingSytem ( ) == CENTOS7 :
2020-09-09 18:23:44 +05:00
command = ' yum install --enablerepo=gf-plus -y postfix3 postfix3-ldap postfix3-mysql postfix3-pcre '
2020-09-03 12:44:32 +05:00
else :
command = ' dnf install --enablerepo=gf-plus postfix3 postfix3-mysql -y '
2019-08-30 20:15:09 +05:00
2020-09-03 12:44:32 +05:00
Upgrade . executioner ( command , 0 )
2019-08-30 20:15:09 +05:00
2020-09-16 19:25:59 +05:00
### Restore dovecot/postfix conf
2020-10-14 14:47:12 +05:00
command = ' cp -pR %s /dovecot/ /etc/ ' % ( configbackups )
2020-09-16 19:28:27 +05:00
Upgrade . executioner ( command , 0 )
2020-09-16 19:25:59 +05:00
2020-10-14 14:47:12 +05:00
command = ' cp -pR %s /postfix/ /etc/ ' % ( configbackups )
2020-09-16 19:28:27 +05:00
Upgrade . executioner ( command , 0 )
2020-09-16 19:25:59 +05:00
## Restored
2020-09-03 12:44:32 +05:00
command = ' systemctl restart postfix '
Upgrade . executioner ( command , 0 )
2022-09-25 12:39:47 +05:00
elif Upgrade . FindOperatingSytem ( ) == Ubuntu20 or Upgrade . FindOperatingSytem ( ) == Ubuntu22 :
2021-02-21 16:10:33 +05:00
debPath = ' /etc/apt/sources.list.d/dovecot.list '
2021-03-18 15:20:34 +05:00
# writeToFile = open(debPath, 'w')
# writeToFile.write('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/focal focal main\n')
# writeToFile.close()
#
# command = "apt update -y"
# Upgrade.executioner(command, command)
#
# command = 'dpkg --configure -a'
# subprocess.call(command, shell=True)
#
# command = 'apt --fix-broken install -y'
# subprocess.call(command, shell=True)
#
# command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade -y'
# subprocess.call(command, shell=True)
2021-02-21 16:10:33 +05:00
2019-08-30 20:15:09 +05:00
2020-01-27 12:19:27 +05:00
dovecotConf = ' /etc/dovecot/dovecot.conf '
dovecotContent = open ( dovecotConf , ' r ' ) . read ( )
if dovecotContent . find ( ' service stats ' ) == - 1 :
2021-02-21 13:09:50 +05:00
writeToFile = open ( dovecotConf , ' a ' )
2020-01-27 12:19:27 +05:00
content = """ \n service stats {
unix_listener stats - reader {
user = vmail
group = vmail
mode = 0660
}
unix_listener stats - writer {
user = vmail
group = vmail
mode = 0660
}
} \n """
writeToFile . write ( content )
writeToFile . close ( )
command = ' systemctl restart dovecot '
Upgrade . executioner ( command , command , 0 )
2020-10-14 15:26:00 +05:00
command = ' rm -rf %s ' % ( configbackups )
Upgrade . executioner ( command , command , 0 )
2019-07-25 14:12:54 +05:00
Upgrade . stdOut ( " Dovecot upgraded. " )
2019-12-10 15:09:10 +05:00
except BaseException as msg :
2019-07-25 14:12:54 +05:00
Upgrade . stdOut ( str ( msg ) + " [upgradeDovecot] " )
2019-07-03 13:15:26 +05:00
2019-10-15 22:59:22 +05:00
@staticmethod
def installRestic ( ) :
CentOSPath = ' /etc/redhat-release '
2022-06-25 02:14:01 +08:00
openEulerPath = ' /etc/openEuler-release '
2019-10-15 22:59:22 +05:00
2022-06-25 02:14:01 +08:00
if os . path . exists ( CentOSPath ) or os . path . exists ( openEulerPath ) :
2020-04-11 11:31:13 +05:00
if Upgrade . installedOutput . find ( ' restic ' ) == - 1 :
command = ' yum install restic -y '
Upgrade . executioner ( command , ' Install Restic ' )
2022-04-28 19:42:04 -06:00
command = ' restic self-update '
Upgrade . executioner ( command , ' Install Restic ' )
2019-10-15 22:59:22 +05:00
else :
2020-04-23 13:44:52 +05:00
if Upgrade . installedOutput . find ( ' restic/bionic,now 0.8 ' ) == - 1 :
command = ' apt-get update -y '
Upgrade . executioner ( command , ' Install Restic ' )
command = ' apt-get install restic -y '
Upgrade . executioner ( command , ' Install Restic ' )
2022-04-28 19:42:04 -06:00
command = ' restic self-update '
Upgrade . executioner ( command , ' Install Restic ' )
2019-10-15 22:59:22 +05:00
2019-11-19 11:36:38 +05:00
@staticmethod
def UpdateMaxSSLCons ( ) :
command = " sed -i ' s|<maxConnections>2000</maxConnections>|<maxConnections>10000</maxConnections>|g ' /usr/local/lsws/conf/httpd_config.xml "
Upgrade . executioner ( command , 0 )
command = " sed -i ' s|<maxSSLConnections>200</maxSSLConnections>|<maxSSLConnections>10000</maxSSLConnections>|g ' /usr/local/lsws/conf/httpd_config.xml "
Upgrade . executioner ( command , 0 )
2019-12-28 18:01:12 +05:00
@staticmethod
def installCLScripts ( ) :
try :
CentOSPath = ' /etc/redhat-release '
2022-06-25 02:14:01 +08:00
openEulerPath = ' /etc/openEuler-release '
2019-12-28 18:01:12 +05:00
2022-06-25 02:14:01 +08:00
if os . path . exists ( CentOSPath ) or os . path . exists ( openEulerPath ) :
2019-12-28 18:01:12 +05:00
command = ' mkdir -p /opt/cpvendor/etc/ '
Upgrade . executioner ( command , 0 )
content = """ [integration_scripts]
panel_info = / usr / local / CyberCP / CLScript / panel_info . py
packages = / usr / local / CyberCP / CLScript / CloudLinuxPackages . py
users = / usr / local / CyberCP / CLScript / CloudLinuxUsers . py
domains = / usr / local / CyberCP / CLScript / CloudLinuxDomains . py
resellers = / usr / local / CyberCP / CLScript / CloudLinuxResellers . py
admins = / usr / local / CyberCP / CLScript / CloudLinuxAdmins . py
2019-12-31 19:55:29 +05:00
db_info = / usr / local / CyberCP / CLScript / CloudLinuxDB . py
2019-12-28 18:01:12 +05:00
[ lvemanager_config ]
2019-12-31 19:55:29 +05:00
ui_user_info = / usr / local / CyberCP / CLScript / UserInfo . py
base_path = / usr / local / lvemanager
2019-12-28 18:01:12 +05:00
run_service = 1
service_port = 9000
"""
if not os . path . exists ( ' /opt/cpvendor/etc/integration.ini ' ) :
writeToFile = open ( ' /opt/cpvendor/etc/integration.ini ' , ' w ' )
writeToFile . write ( content )
writeToFile . close ( )
2020-01-29 17:27:43 +05:00
command = ' mkdir -p /etc/cagefs/exclude '
Upgrade . executioner ( command , command , 0 )
content = """ cyberpanel
docker
ftpuser
lscpd
opendkim
pdns
vmail
"""
writeToFile = open ( ' /etc/cagefs/exclude/cyberpanelexclude ' , ' w ' )
writeToFile . write ( content )
writeToFile . close ( )
2019-12-28 18:01:12 +05:00
except :
pass
2020-02-03 21:23:48 +05:00
@staticmethod
def runSomeImportantBash ( ) :
2022-09-10 23:58:50 +05:00
2020-02-03 22:43:23 -05:00
# Remove invalid crons from /etc/crontab Reference: https://github.com/usmannasir/cyberpanel/issues/216
2022-09-10 23:58:50 +05:00
command = """ sed -i ' /CyberCP/d ' /etc/crontab """
Upgrade . executioner ( command , command , 0 , True )
if os . path . exists ( ' /usr/local/lsws/conf/httpd.conf ' ) :
# Setup /usr/local/lsws/conf/httpd.conf to use new Logformat standard for better stats and accesslogs
command = """ sed -i " s|^LogFormat.*|LogFormat ' % h % l %u % t \" %r \" % >s % b \" % {Referer} i \" \" % { User-Agent}i \" ' combined|g " /usr/local/lsws/conf/httpd.conf """
Upgrade . executioner ( command , command , 0 , True )
# Fix all existing vhost confs to use new Logformat standard for better stats and accesslogs
command = """ find /usr/local/lsws/conf/vhosts/ -type f -name ' vhost.conf ' -exec sed -i " s/.*CustomLog.*/ LogFormat ' % h % l %u % t \" %r \" % >s % b \" % {Referer} i \" \" % { User-Agent}i \" ' combined \n &/g " {} \ ; """
Upgrade . executioner ( command , command , 0 , True )
2020-02-03 21:23:48 +05:00
2020-02-03 22:43:23 -05:00
# Install any Cyberpanel missing crons to root crontab so its visible to users via crontab -l as root user
2020-02-03 21:50:59 +05:00
# Install findBWUsage cron if missing
2020-02-12 13:28:09 +05:00
CentOSPath = ' /etc/redhat-release '
2022-06-25 02:14:01 +08:00
openEulerPath = ' /etc/openEuler-release '
2020-02-03 21:50:59 +05:00
2022-06-25 02:14:01 +08:00
if os . path . exists ( CentOSPath ) or os . path . exists ( openEulerPath ) :
2020-02-12 13:28:09 +05:00
cronPath = ' /var/spool/cron/root '
else :
cronPath = ' /var/spool/cron/crontabs/root '
2020-02-03 21:50:59 +05:00
2020-02-12 13:28:09 +05:00
if os . path . exists ( cronPath ) :
data = open ( cronPath , ' r ' ) . read ( )
2020-02-03 21:50:59 +05:00
2020-02-12 13:28:09 +05:00
if data . find ( ' findBWUsage ' ) == - 1 :
2020-02-29 08:12:03 +05:00
content = """
0 * * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / plogical / findBWUsage . py > / dev / null 2 > & 1
2020-02-12 14:45:31 +05:00
0 * * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / postfixSenderPolicy / client . py hourlyCleanup > / dev / null 2 > & 1
0 0 1 * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / postfixSenderPolicy / client . py monthlyCleanup > / dev / null 2 > & 1
0 2 * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / plogical / upgradeCritical . py > / dev / null 2 > & 1
0 2 * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / plogical / renew . py > / dev / null 2 > & 1
7 0 * * * " /root/.acme.sh " / acme . sh - - cron - - home " /root/.acme.sh " > / dev / null
2020-08-27 00:20:54 +05:00
* / 3 * * * * if ! find / home / * / public_html / - maxdepth 2 - type f - newer / usr / local / lsws / cgid - name ' .htaccess ' - exec false { } + ; then / usr / local / lsws / bin / lswsctrl restart ; fi
2020-02-12 14:45:31 +05:00
"""
2020-02-03 21:50:59 +05:00
2020-02-12 13:28:09 +05:00
writeToFile = open ( cronPath , ' w ' )
writeToFile . write ( content )
writeToFile . close ( )
2020-02-29 08:12:03 +05:00
if data . find ( ' IncScheduler.py ' ) == - 1 :
content = """
2020-03-11 15:06:42 +05:00
0 12 * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / IncBackups / IncScheduler . py Daily
0 0 * * 0 / usr / local / CyberCP / bin / python / usr / local / CyberCP / IncBackups / IncScheduler . py Weekly
2020-02-29 08:12:03 +05:00
"""
2020-02-29 08:18:55 +05:00
writeToFile = open ( cronPath , ' a ' )
2020-02-29 08:12:03 +05:00
writeToFile . write ( content )
writeToFile . close ( )
2022-07-04 19:58:58 +05:00
if data . find ( " IncScheduler.py ' 30 Minutes ' " ) == - 1 :
content = """
2022-07-04 23:34:29 +05:00
* / 30 * * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / IncBackups / IncScheduler . py ' 30 Minutes '
0 * * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / IncBackups / IncScheduler . py ' 1 Hour '
0 * / 6 * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / IncBackups / IncScheduler . py ' 6 Hours '
0 * / 12 * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / IncBackups / IncScheduler . py ' 12 Hours '
0 1 * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / IncBackups / IncScheduler . py ' 1 Day '
0 0 * / 3 * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / IncBackups / IncScheduler . py ' 3 Days '
2022-07-04 19:58:58 +05:00
0 0 * * 0 / usr / local / CyberCP / bin / python / usr / local / CyberCP / IncBackups / IncScheduler . py ' 1 Week '
"""
writeToFile = open ( cronPath , ' a ' )
writeToFile . write ( content )
writeToFile . close ( )
2020-02-12 13:28:09 +05:00
else :
2020-02-29 08:12:03 +05:00
content = """
0 * * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / plogical / findBWUsage . py > / dev / null 2 > & 1
2020-02-12 13:28:09 +05:00
0 * * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / postfixSenderPolicy / client . py hourlyCleanup > / dev / null 2 > & 1
0 0 1 * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / postfixSenderPolicy / client . py monthlyCleanup > / dev / null 2 > & 1
0 2 * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / plogical / upgradeCritical . py > / dev / null 2 > & 1
0 2 * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / plogical / renew . py > / dev / null 2 > & 1
7 0 * * * " /root/.acme.sh " / acme . sh - - cron - - home " /root/.acme.sh " > / dev / null
2021-06-02 08:45:13 -04:00
0 0 * * * / usr / local / CyberCP / bin / python / usr / local / CyberCP / IncBackups / IncScheduler . py Daily
2020-03-11 15:06:42 +05:00
0 0 * * 0 / usr / local / CyberCP / bin / python / usr / local / CyberCP / IncBackups / IncScheduler . py Weekly
2020-02-12 13:28:09 +05:00
"""
writeToFile = open ( cronPath , ' w ' )
writeToFile . write ( content )
writeToFile . close ( )
2020-02-03 21:50:59 +05:00
2021-05-08 14:37:31 +05:00
### Check and remove OLS restart if lsws ent detected
if not os . path . exists ( ' /usr/local/lsws/bin/openlitespeed ' ) :
data = open ( cronPath , ' r ' ) . readlines ( )
writeToFile = open ( cronPath , ' w ' )
for items in data :
if items . find ( ' -maxdepth 2 -type f -newer ' ) > - 1 :
pass
else :
writeToFile . writelines ( items )
writeToFile . close ( )
2022-06-25 02:14:01 +08:00
if not os . path . exists ( CentOSPath ) or not os . path . exists ( openEulerPath ) :
2020-03-25 12:00:32 +05:00
command = ' chmod 600 %s ' % ( cronPath )
Upgrade . executioner ( command , 0 )
2021-02-21 14:04:11 +05:00
@staticmethod
def UpdateConfigOfCustomACL ( ) :
2021-02-21 14:10:11 +05:00
sys . path . append ( ' /usr/local/CyberCP ' )
os . environ . setdefault ( " DJANGO_SETTINGS_MODULE " , " CyberCP.settings " )
import django
django . setup ( )
2021-02-21 13:58:42 +05:00
from loginSystem . models import ACL
for acl in ACL . objects . all ( ) :
if acl . name == ' admin ' or acl . name == ' reseller ' or acl . name == ' user ' :
continue
elif acl . config == ' {} ' :
2021-04-15 19:47:12 -04:00
acl . config = ' { " adminStatus " : %s , " versionManagement " : %s , " createNewUser " : %s , " listUsers " : %s , " deleteUser " : %s , " resellerCenter " : %s , " changeUserACL " : %s , " createWebsite " : %s , " modifyWebsite " : %s , " suspendWebsite " : %s , " deleteWebsite " : %s , " createPackage " : %s , " listPackages " : %s , " deletePackage " : %s , " modifyPackage " : %s , " createDatabase " : %s , " deleteDatabase " : %s , " listDatabases " : %s , " createNameServer " : %s , " createDNSZone " : %s , " deleteZone " : %s , " addDeleteRecords " : %s , " createEmail " : %s , " listEmails " : %s , " deleteEmail " : %s , " emailForwarding " : %s , " changeEmailPassword " : %s , " dkimManager " : %s , " createFTPAccount " : %s , " deleteFTPAccount " : %s , " listFTPAccounts " : %s , " createBackup " : %s , " restoreBackup " : %s , " addDeleteDestinations " : %s , " scheduleBackups " : %s , " remoteBackups " : %s , " googleDriveBackups " : %s , " manageSSL " : %s , " hostnameSSL " : %s , " mailServerSSL " : %s } ' \
2021-02-21 13:58:42 +05:00
% ( str ( acl . adminStatus ) , str ( acl . versionManagement ) , str ( acl . createNewUser ) ,
str ( acl . listUsers ) , str ( acl . deleteUser ) , str ( acl . resellerCenter ) , str ( acl . changeUserACL ) ,
str ( acl . createWebsite ) , str ( acl . modifyWebsite ) , str ( acl . suspendWebsite ) , str ( acl . deleteWebsite ) ,
str ( acl . createPackage ) , str ( acl . listPackages ) , str ( acl . deletePackage ) , str ( acl . modifyPackage ) ,
str ( acl . createDatabase ) , str ( acl . deleteDatabase ) , str ( acl . listDatabases ) , str ( acl . createNameServer ) ,
str ( acl . createDNSZone ) , str ( acl . deleteZone ) , str ( acl . addDeleteRecords ) , str ( acl . createEmail ) ,
str ( acl . listEmails ) , str ( acl . deleteEmail ) , str ( acl . emailForwarding ) , str ( acl . changeEmailPassword ) ,
str ( acl . dkimManager ) , str ( acl . createFTPAccount ) , str ( acl . deleteFTPAccount ) , str ( acl . listFTPAccounts ) ,
2021-04-15 19:47:12 -04:00
str ( acl . createBackup ) , str ( acl . restoreBackup ) , str ( acl . addDeleteDestinations ) , str ( acl . scheduleBackups ) , str ( acl . remoteBackups ) , ' 1 ' ,
2021-02-21 13:58:42 +05:00
str ( acl . manageSSL ) , str ( acl . hostnameSSL ) , str ( acl . mailServerSSL ) )
acl . save ( )
2018-08-21 13:10:40 +05:00
@staticmethod
2020-01-02 14:32:02 +05:00
def upgrade ( branch ) :
2017-10-24 19:16:36 +05:00
2019-06-08 21:41:43 +00:00
# Upgrade.stdOut("Upgrades are currently disabled")
# return 0
2019-04-15 15:54:23 +05:00
2022-06-25 02:14:01 +08:00
if os . path . exists ( Upgrade . CentOSPath ) or os . path . exists ( Upgrade . openEulerPath ) :
2020-04-11 11:31:13 +05:00
command = ' yum list installed '
2020-04-11 12:37:12 +05:00
Upgrade . installedOutput = subprocess . check_output ( shlex . split ( command ) ) . decode ( )
2020-04-23 13:44:52 +05:00
else :
command = ' apt list '
Upgrade . installedOutput = subprocess . check_output ( shlex . split ( command ) ) . decode ( )
2019-11-06 14:17:52 +05:00
command = ' systemctl stop cpssh '
Upgrade . executioner ( command , ' fix csf if there ' , 0 )
2020-01-05 12:09:53 +05:00
## Add LSPHP7.4 TO LSWS Ent configs
2020-01-05 12:20:48 +05:00
if not os . path . exists ( ' /usr/local/lsws/bin/openlitespeed ' ) :
2020-04-23 13:44:52 +05:00
if os . path . exists ( ' httpd_config.xml ' ) :
os . remove ( ' httpd_config.xml ' )
2020-01-05 12:09:53 +05:00
command = ' wget https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/install/litespeed/httpd_config.xml '
2020-01-05 12:20:48 +05:00
Upgrade . executioner ( command , command , 0 )
2021-02-21 13:09:50 +05:00
# os.remove('/usr/local/lsws/conf/httpd_config.xml')
# shutil.copy('httpd_config.xml', '/usr/local/lsws/conf/httpd_config.xml')
2020-01-05 12:09:53 +05:00
2019-07-16 23:23:16 +05:00
postfixPath = ' /home/cyberpanel/postfix '
pdns = ' /home/cyberpanel/pdns '
pureftpd = ' /home/cyberpanel/ftp '
2019-11-25 18:00:31 +05:00
Upgrade . updateRepoURL ( )
2018-08-21 13:10:40 +05:00
os . chdir ( " /usr/local " )
2017-10-24 19:16:36 +05:00
2019-07-24 22:37:37 +05:00
command = ' yum remove yum-plugin-priorities -y '
Upgrade . executioner ( command , ' remove yum-plugin-priorities ' , 0 )
2018-08-21 13:10:40 +05:00
## Current Version
2017-10-24 19:16:36 +05:00
2018-11-14 13:36:34 +05:00
command = " systemctl stop lscpd "
2018-12-14 05:01:10 +05:00
Upgrade . executioner ( command , ' stop lscpd ' , 0 )
2018-07-19 22:38:37 +05:00
2019-04-15 15:54:23 +05:00
Upgrade . fixSudoers ( )
2021-05-27 22:05:57 +05:00
Upgrade . mountTemp ( )
2019-04-15 15:54:23 +05:00
Upgrade . dockerUsers ( )
Upgrade . setupComposer ( )
2018-08-21 13:10:40 +05:00
##
2017-10-24 19:16:36 +05:00
2018-08-21 13:10:40 +05:00
versionNumbring = Upgrade . downloadLink ( )
2018-05-06 14:18:41 +05:00
2018-08-21 13:10:40 +05:00
if os . path . exists ( ' /usr/local/CyberPanel. ' + versionNumbring ) :
os . remove ( ' /usr/local/CyberPanel. ' + versionNumbring )
2017-10-24 19:16:36 +05:00
2018-08-21 13:10:40 +05:00
##
2018-12-14 05:01:10 +05:00
2020-01-02 14:32:02 +05:00
Upgrade . downloadAndUpgrade ( versionNumbring , branch )
2019-04-15 15:54:23 +05:00
Upgrade . download_install_phpmyadmin ( )
Upgrade . downoad_and_install_raindloop ( )
2018-12-14 05:01:10 +05:00
2018-08-21 13:10:40 +05:00
##
2018-12-14 05:01:10 +05:00
2018-08-21 13:10:40 +05:00
##
2018-07-19 22:38:37 +05:00
2018-08-21 13:10:40 +05:00
Upgrade . mailServerMigrations ( )
2018-10-22 10:55:52 +05:00
Upgrade . emailMarketingMigrationsa ( )
2019-01-09 14:55:10 +05:00
Upgrade . dockerMigrations ( )
2019-07-16 23:23:16 +05:00
Upgrade . CLMigrations ( )
2019-10-15 22:59:22 +05:00
Upgrade . IncBackupMigrations ( )
Upgrade . installRestic ( )
2018-07-19 22:38:37 +05:00
2018-08-21 13:10:40 +05:00
##
2018-07-19 22:38:37 +05:00
2021-02-21 13:09:50 +05:00
# Upgrade.setupVirtualEnv()
2018-06-25 03:37:23 +05:00
2018-08-21 13:10:40 +05:00
##
2017-10-24 19:16:36 +05:00
2018-08-28 01:19:34 +05:00
Upgrade . applyLoginSystemMigrations ( )
2021-02-21 13:58:42 +05:00
## Put function here to update custom ACLs
Upgrade . UpdateConfigOfCustomACL ( )
2018-12-14 05:01:10 +05:00
Upgrade . s3BackupMigrations ( )
2019-01-27 01:18:49 +05:00
Upgrade . containerMigrations ( )
2019-02-05 12:21:37 +05:00
Upgrade . manageServiceMigrations ( )
2018-08-28 01:19:34 +05:00
Upgrade . enableServices ( )
2018-08-19 00:28:31 +05:00
2018-12-20 16:18:16 +05:00
Upgrade . installPHP73 ( )
2018-07-23 02:09:33 +05:00
Upgrade . setupCLI ( )
2019-04-15 15:54:23 +05:00
Upgrade . someDirectories ( )
2020-02-13 16:16:02 +05:00
Upgrade . installLSCPD ( branch )
2021-04-29 00:03:32 +05:00
### General migrations are not needed any more
# Upgrade.GeneralMigrations()
2021-02-21 13:09:50 +05:00
# Upgrade.p3()
2019-07-16 23:23:16 +05:00
2021-04-29 00:03:32 +05:00
## Also disable email service upgrade
# if os.path.exists(postfixPath):
# Upgrade.upgradeDovecot()
2018-05-14 22:26:25 +05:00
2018-04-23 19:23:03 +05:00
## Upgrade version
2020-03-23 11:20:42 +05:00
2020-04-11 15:31:01 +05:00
Upgrade . fixPermissions ( )
2020-03-23 11:20:42 +05:00
##
2021-04-29 00:03:32 +05:00
### Disable version upgrade too
# Upgrade.upgradeVersion()
2019-11-19 11:36:38 +05:00
Upgrade . UpdateMaxSSLCons ( )
2017-10-24 19:16:36 +05:00
2019-12-28 17:11:17 +05:00
## Update LSCPD PHP
phpPath = ' /usr/local/lscp/fcgi-bin/lsphp '
try :
os . remove ( phpPath )
except :
pass
2022-09-26 23:02:31 +05:00
command = ' cp /usr/local/lsws/lsphp74/bin/lsphp %s ' % ( phpPath )
2019-12-28 17:11:17 +05:00
Upgrade . executioner ( command , 0 )
2018-08-28 01:19:34 +05:00
try :
command = " systemctl start lscpd "
2018-12-14 05:01:10 +05:00
Upgrade . executioner ( command , ' Start LSCPD ' , 0 )
2018-08-28 01:19:34 +05:00
except :
pass
2017-10-30 14:34:07 +05:00
2019-11-06 14:02:30 +05:00
command = ' csf -uf '
Upgrade . executioner ( command , ' fix csf if there ' , 0 )
2022-03-08 19:26:11 +05:00
command = ' systemctl stop cpssh '
2019-11-06 14:17:52 +05:00
Upgrade . executioner ( command , ' fix csf if there ' , 0 )
2019-12-04 14:40:59 +05:00
Upgrade . AutoUpgradeAcme ( )
2019-12-28 18:01:12 +05:00
Upgrade . installCLScripts ( )
2020-02-03 21:50:59 +05:00
Upgrade . runSomeImportantBash ( )
2019-11-06 14:02:30 +05:00
2022-10-15 14:04:05 +05:00
# ## Move static files
#
# imunifyPath = '/usr/local/CyberCP/public/imunify'
#
# if os.path.exists(imunifyPath):
# command = "yum reinstall imunify360-firewall-generic -y"
# Upgrade.executioner(command, command, 1)
#
# imunifyAVPath = '/etc/sysconfig/imunify360/integration.conf'
#
# if os.path.exists(imunifyAVPath):
# execPath = "/usr/local/CyberCP/bin/python /usr/local/CyberCP/CLManager/CageFS.py"
# command = execPath + " --function submitinstallImunifyAV"
# Upgrade.executioner(command, command, 1)
#
# command = 'chmod +x /usr/local/CyberCP/public/imunifyav/bin/execute.py'
# Upgrade.executioner(command, command, 1)
2020-04-26 23:29:59 +05:00
2022-06-22 12:35:50 +05:00
2018-07-19 22:38:37 +05:00
Upgrade . stdOut ( " Upgrade Completed. " )
2017-10-24 19:16:36 +05:00
2018-12-14 05:01:10 +05:00
def main ( ) :
2021-04-30 03:54:08 +05:00
2020-01-02 14:32:02 +05:00
parser = argparse . ArgumentParser ( description = ' CyberPanel Installer ' )
parser . add_argument ( ' branch ' , help = ' Install from branch name. ' )
args = parser . parse_args ( )
Upgrade . upgrade ( args . branch )
2018-12-14 05:01:10 +05:00
2019-06-08 21:41:43 +00:00
2018-12-14 05:01:10 +05:00
if __name__ == " __main__ " :
2019-08-03 14:53:31 +05:00
main ( )