2017-10-24 19:16:36 +05:00
|
|
|
import os
|
2018-07-19 22:38:37 +05:00
|
|
|
import os.path
|
|
|
|
|
import sys
|
|
|
|
|
import django
|
2019-06-08 21:41:43 +00:00
|
|
|
|
2018-07-19 22:38:37 +05:00
|
|
|
sys.path.append('/usr/local/CyberCP')
|
|
|
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
|
|
|
|
django.setup()
|
2017-10-24 19:16:36 +05:00
|
|
|
import shlex
|
|
|
|
|
import subprocess
|
2018-04-23 19:23:03 +05:00
|
|
|
import shutil
|
2017-10-24 19:16:36 +05:00
|
|
|
import requests
|
2018-04-23 19:23:03 +05:00
|
|
|
import json
|
2018-05-14 22:26:25 +05:00
|
|
|
import time
|
2018-07-19 22:38:37 +05:00
|
|
|
from baseTemplate.models import version
|
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
|
2019-07-03 13:15:26 +05:00
|
|
|
from mailServer.models import EUsers
|
2017-10-24 19:16:36 +05:00
|
|
|
|
2019-06-08 21:41:43 +00:00
|
|
|
|
2017-10-24 19:16:36 +05:00
|
|
|
class Upgrade:
|
|
|
|
|
logPath = "/usr/local/lscp/logs/upgradeLog"
|
|
|
|
|
|
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")
|
|
|
|
|
print ("[" + time.strftime(
|
2019-10-08 13:17:33 -04:00
|
|
|
"%m.%d.%Y_%H-%M-%S") + "] #########################################################################\n")
|
|
|
|
|
print("[" + time.strftime("%m.%d.%Y_%H-%M-%S") + "] " + message + "\n")
|
2018-07-19 22:38:37 +05:00
|
|
|
print ("[" + time.strftime(
|
2019-10-08 13:17:33 -04:00
|
|
|
"%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:
|
|
|
|
|
os._exit(0)
|
|
|
|
|
|
2018-11-14 13:36:34 +05:00
|
|
|
@staticmethod
|
2019-06-08 21:41:43 +00:00
|
|
|
def executioner(command, component, do_exit=0):
|
2018-11-14 13:36:34 +05:00
|
|
|
try:
|
2018-12-14 05:01:10 +05:00
|
|
|
count = 0
|
|
|
|
|
while True:
|
2019-03-26 16:19:03 +05:00
|
|
|
res = subprocess.call(shlex.split(command))
|
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:
|
|
|
|
|
return 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()
|
|
|
|
|
|
|
|
|
|
except BaseException, msg:
|
|
|
|
|
Upgrade.stdOut(str(msg) + " [mountTemp]", 0)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def setupPythonWSGI():
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
cwd = os.getcwd()
|
|
|
|
|
|
|
|
|
|
command = "wget http://www.litespeedtech.com/packages/lsapi/wsgi-lsapi-1.4.tgz"
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
command = "tar xf wsgi-lsapi-1.4.tgz"
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
os.chdir("wsgi-lsapi-1.4")
|
|
|
|
|
|
|
|
|
|
command = "python ./configure.py"
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
command = "make"
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
command = "cp lswsgi /usr/local/CyberCP/bin/"
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
os.chdir(cwd)
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def dockerUsers():
|
|
|
|
|
### Docker User/group
|
|
|
|
|
|
|
|
|
|
command = "adduser docker"
|
|
|
|
|
Upgrade.executioner(command, 'adduser docker', 0)
|
|
|
|
|
|
|
|
|
|
command = 'groupadd docker'
|
|
|
|
|
Upgrade.executioner(command, 'adduser docker', 0)
|
|
|
|
|
|
|
|
|
|
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("%sudo 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
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
os.chdir("/usr/local/CyberCP/public")
|
|
|
|
|
|
|
|
|
|
command = '/usr/local/lsws/lsphp70/bin/php /usr/bin/composer create-project phpmyadmin/phpmyadmin'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
## Write secret phrase
|
|
|
|
|
|
|
|
|
|
rString = ''.join([random.choice(string.ascii_letters + string.digits) for n in xrange(32)])
|
|
|
|
|
|
|
|
|
|
data = open('phpmyadmin/config.sample.inc.php', 'r').readlines()
|
|
|
|
|
|
|
|
|
|
writeToFile = open('phpmyadmin/config.inc.php', 'w')
|
|
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
else:
|
|
|
|
|
writeToFile.writelines(items)
|
|
|
|
|
|
|
|
|
|
writeToFile.writelines("$cfg['TempDir'] = '/usr/local/CyberCP/public/phpmyadmin/tmp';\n")
|
|
|
|
|
|
|
|
|
|
writeToFile.close()
|
|
|
|
|
|
|
|
|
|
os.mkdir('/usr/local/CyberCP/public/phpmyadmin/tmp')
|
|
|
|
|
|
|
|
|
|
os.chdir(cwd)
|
|
|
|
|
|
|
|
|
|
except BaseException, msg:
|
|
|
|
|
Upgrade.stdOut(str(msg) + " [download_install_phpmyadmin]", 0)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def setupComposer():
|
|
|
|
|
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:
|
|
|
|
|
#######
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
path = "/usr/local/CyberCP/public/rainloop/rainloop/v/1.12.1/include.php"
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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):
|
|
|
|
|
command = 'wget https://www.rainloop.net/repository/webmail/rainloop-community-latest.zip'
|
|
|
|
|
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 = 'unzip rainloop-community-latest.zip -d /usr/local/CyberCP/public/rainloop'
|
|
|
|
|
|
|
|
|
|
cmd = shlex.split(command)
|
|
|
|
|
res = subprocess.call(cmd)
|
|
|
|
|
if res != 0:
|
|
|
|
|
count = count + 1
|
|
|
|
|
if count == 3:
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
os.remove("rainloop-community-latest.zip")
|
|
|
|
|
|
|
|
|
|
#######
|
|
|
|
|
|
|
|
|
|
os.chdir("/usr/local/CyberCP/public/rainloop")
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
else:
|
|
|
|
|
break
|
|
|
|
|
######
|
|
|
|
|
|
2019-08-27 14:40:02 +05:00
|
|
|
iPath = os.listdir('/usr/local/CyberCP/public/rainloop/rainloop/v/')
|
|
|
|
|
|
|
|
|
|
path = "/usr/local/CyberCP/public/rainloop/rainloop/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(
|
|
|
|
|
" $sCustomDataPath = '/usr/local/lscp/cyberpanel/rainloop/data';\n")
|
|
|
|
|
else:
|
|
|
|
|
writeToFile.writelines(items)
|
|
|
|
|
|
2019-08-27 14:40:02 +05:00
|
|
|
writeToFile.close()
|
|
|
|
|
|
2019-09-02 15:09:17 +05:00
|
|
|
command = "mkdir -p /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/configs/"
|
|
|
|
|
Upgrade.executioner(command, 'mkdir rainloop configs', 0)
|
|
|
|
|
|
|
|
|
|
labsPath = '/usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/configs/application.ini'
|
|
|
|
|
|
|
|
|
|
labsData = """[labs]
|
|
|
|
|
imap_folder_list_limit = 0
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
writeToFile = open(labsPath, 'w')
|
|
|
|
|
writeToFile.write(labsData)
|
|
|
|
|
writeToFile.close()
|
|
|
|
|
|
2019-04-15 15:54:23 +05:00
|
|
|
os.chdir(cwd)
|
|
|
|
|
|
|
|
|
|
except BaseException, msg:
|
|
|
|
|
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:
|
|
|
|
|
url = "https://cyberpanel.net/version.txt"
|
|
|
|
|
r = requests.get(url, verify=True)
|
|
|
|
|
data = json.loads(r.text)
|
|
|
|
|
version_number = str(data['version'])
|
2018-08-21 13:10:40 +05:00
|
|
|
version_build = str(data['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")
|
|
|
|
|
except BaseException, msg:
|
|
|
|
|
Upgrade.stdOut(str(msg) + ' [downloadLink]')
|
|
|
|
|
os._exit(0)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def setupVirtualEnv():
|
|
|
|
|
try:
|
2018-11-14 13:36:34 +05:00
|
|
|
Upgrade.stdOut('Setting up virtual environment for CyberPanel.')
|
2018-07-19 22:38:37 +05:00
|
|
|
##
|
|
|
|
|
|
2018-12-14 05:01:10 +05:00
|
|
|
command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel"
|
|
|
|
|
Upgrade.executioner(command, 'VirtualEnv Pre-reqs', 0)
|
|
|
|
|
|
2019-02-03 13:37:14 +05:00
|
|
|
command = "yum install -y libattr-devel xz-devel gpgme-devel curl-devel"
|
|
|
|
|
Upgrade.executioner(command, 'VirtualEnv Pre-reqs', 0)
|
|
|
|
|
|
2018-07-19 22:38:37 +05:00
|
|
|
##
|
|
|
|
|
|
2018-12-14 05:01:10 +05:00
|
|
|
command = "pip install virtualenv"
|
|
|
|
|
Upgrade.executioner(command, 'VirtualEnv Install', 0)
|
2018-07-19 22:38:37 +05:00
|
|
|
|
|
|
|
|
####
|
|
|
|
|
|
2018-12-14 05:01:10 +05:00
|
|
|
command = "virtualenv --system-site-packages /usr/local/CyberCP"
|
|
|
|
|
Upgrade.executioner(command, 'Setting up VirtualEnv [One]', 1)
|
2018-07-19 22:38:37 +05:00
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
|
|
|
|
env_path = '/usr/local/CyberCP'
|
2019-03-26 16:19:03 +05:00
|
|
|
subprocess.call(['virtualenv', env_path])
|
2018-07-19 22:38:37 +05:00
|
|
|
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
|
|
|
|
|
execfile(activate_this, dict(__file__=activate_this))
|
|
|
|
|
|
|
|
|
|
##
|
|
|
|
|
|
2018-12-14 05:01:10 +05:00
|
|
|
command = "pip install --ignore-installed -r /usr/local/CyberCP/requirments.txt"
|
2019-10-19 13:03:00 +05:00
|
|
|
Upgrade.executioner(command, 'CyberPanel requirements', 0)
|
2018-08-21 13:10:40 +05:00
|
|
|
|
2018-11-14 13:36:34 +05:00
|
|
|
command = "virtualenv --system-site-packages /usr/local/CyberCP"
|
2019-10-19 13:03:00 +05:00
|
|
|
Upgrade.executioner(command, 'Setting up VirtualEnv [Two]', 0)
|
2018-08-21 13:10:40 +05:00
|
|
|
|
|
|
|
|
Upgrade.stdOut('Virtual enviroment for CyberPanel successfully installed.')
|
2018-07-19 22:38:37 +05:00
|
|
|
except OSError, msg:
|
2018-12-14 05:01:10 +05:00
|
|
|
Upgrade.stdOut(str(msg) + " [setupVirtualEnv]", 0)
|
2018-07-19 22:38:37 +05:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def fileManager():
|
|
|
|
|
## Copy File manager files
|
|
|
|
|
|
2018-11-14 13:36:34 +05:00
|
|
|
command = "rm -rf /usr/local/lsws/Example/html/FileManager"
|
2018-12-14 05:01:10 +05:00
|
|
|
Upgrade.executioner(command, 'Remove old Filemanager', 0)
|
2018-07-19 22:38:37 +05:00
|
|
|
|
2018-11-14 13:36:34 +05:00
|
|
|
if os.path.exists('/usr/local/lsws/bin/openlitespeed'):
|
2018-12-14 05:01:10 +05:00
|
|
|
command = "mv /usr/local/CyberCP/install/FileManager /usr/local/lsws/Example/html"
|
|
|
|
|
Upgrade.executioner(command, 'Setup new Filemanager', 0)
|
2018-11-14 13:36:34 +05:00
|
|
|
else:
|
2018-12-14 05:01:10 +05:00
|
|
|
command = "mv /usr/local/CyberCP/install/FileManager /usr/local/lsws"
|
|
|
|
|
Upgrade.executioner(command, 'Setup new Filemanager', 0)
|
2018-11-14 13:36:34 +05:00
|
|
|
|
2018-12-14 05:01:10 +05:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
command = "chmod -R 777 /usr/local/lsws/Example/html/FileManager"
|
|
|
|
|
Upgrade.executioner(command, 'Filemanager permissions change', 0)
|
2018-07-19 22:38:37 +05:00
|
|
|
|
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
|
|
|
|
2018-11-14 13:36:34 +05:00
|
|
|
except OSError, 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")
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
vers = version.objects.get(pk=1)
|
|
|
|
|
getVersion = requests.get('https://cyberpanel.net/version.txt')
|
|
|
|
|
latest = getVersion.json()
|
|
|
|
|
vers.currentVersion = latest['version']
|
|
|
|
|
vers.build = latest['build']
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
except BaseException, msg:
|
|
|
|
|
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
|
|
|
|
2018-08-28 01:19:34 +05:00
|
|
|
try:
|
2019-06-08 21:41:43 +00:00
|
|
|
cursor.execute(
|
|
|
|
|
'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
|
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:
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|
|
2018-12-20 16:18:16 +05:00
|
|
|
try:
|
|
|
|
|
connection.close()
|
|
|
|
|
except:
|
|
|
|
|
pass
|
2018-12-14 05:01:10 +05:00
|
|
|
|
|
|
|
|
except OSError, msg:
|
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
except OSError, msg:
|
|
|
|
|
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`)
|
|
|
|
|
)"""
|
|
|
|
|
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`)
|
|
|
|
|
)"""
|
|
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|
|
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
|
|
|
|
|
|
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-10-19 14:02:48 +05:00
|
|
|
command = '/usr/local/CyberPanel/bin/python2 manage.py makemigrations'
|
2019-06-08 21:41:43 +00:00
|
|
|
Upgrade.executioner(command, 'python manage.py makemigrations', 0)
|
|
|
|
|
|
2019-10-19 14:02:48 +05:00
|
|
|
command = '/usr/local/CyberPanel/bin/python2 manage.py makemigrations'
|
|
|
|
|
Upgrade.executioner(command, '/usr/local/CyberPanel/bin/python2 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`)
|
|
|
|
|
)"""
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2019-11-07 14:47:02 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def installGit():
|
|
|
|
|
try:
|
|
|
|
|
if os.path.exists("/etc/lsb-release"):
|
|
|
|
|
command = 'apt -y install git'
|
|
|
|
|
Upgrade.executioner(command, 'installGit', 0)
|
|
|
|
|
else:
|
|
|
|
|
command = 'sudo yum -y install http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm'
|
|
|
|
|
Upgrade.executioner(command, 'installGit', 0)
|
|
|
|
|
|
|
|
|
|
command = 'sudo yum install git -y'
|
|
|
|
|
Upgrade.executioner(command, 'installGit', 0)
|
|
|
|
|
|
|
|
|
|
except BaseException, msg:
|
|
|
|
|
pass
|
|
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
@staticmethod
|
2018-12-14 05:01:10 +05:00
|
|
|
def downloadAndUpgrade(versionNumbring):
|
2018-08-21 13:10:40 +05:00
|
|
|
try:
|
|
|
|
|
## Download latest version.
|
2018-07-19 22:38:37 +05:00
|
|
|
|
2019-11-07 14:47:02 +05:00
|
|
|
Upgrade.installGit()
|
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
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
shutil.copy("/usr/local/CyberCP/CyberCP/settings.py", "/usr/local/settings.py")
|
2018-07-19 22:38:37 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
Upgrade.stdOut("Settings file backed up.")
|
2017-10-24 19:16:36 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
## Extract Latest files
|
2017-10-24 19:16:36 +05:00
|
|
|
|
2019-11-07 14:47:02 +05:00
|
|
|
os.chdir('/usr/local')
|
|
|
|
|
|
|
|
|
|
if os.path.exists('cyberpanel'):
|
|
|
|
|
shutil.rmtree('cyberpanel')
|
|
|
|
|
|
2019-11-07 17:13:55 +05:00
|
|
|
if os.path.exists('CyberCP'):
|
|
|
|
|
shutil.rmtree('CyberCP')
|
|
|
|
|
|
2019-11-07 14:47:02 +05:00
|
|
|
command = 'git clone https://github.com/usmannasir/cyberpanel'
|
|
|
|
|
Upgrade.executioner(command, 'Download CyberPanel', 1)
|
|
|
|
|
|
|
|
|
|
shutil.move('cyberpanel', 'CyberCP')
|
|
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
## Copy settings file
|
2018-11-14 13:36:34 +05:00
|
|
|
|
2018-10-12 18:18:10 +05:00
|
|
|
data = open("/usr/local/settings.py", 'r').readlines()
|
|
|
|
|
|
2019-07-16 23:23:16 +05:00
|
|
|
csrfCheck = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('CsrfViewMiddleware') > -1:
|
|
|
|
|
csrfCheck = 0
|
|
|
|
|
|
2018-10-12 18:18:10 +05:00
|
|
|
pluginCheck = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('pluginHolder') > -1:
|
|
|
|
|
pluginCheck = 0
|
|
|
|
|
|
2018-10-22 10:55:52 +05:00
|
|
|
emailMarketing = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('emailMarketing') > -1:
|
|
|
|
|
emailMarketing = 0
|
|
|
|
|
|
2018-11-14 13:36:34 +05:00
|
|
|
emailPremium = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('emailPremium') > -1:
|
|
|
|
|
emailPremium = 0
|
|
|
|
|
|
2018-12-14 05:01:10 +05:00
|
|
|
s3Backups = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('s3Backups') > -1:
|
|
|
|
|
s3Backups = 0
|
|
|
|
|
|
2019-01-13 23:58:09 +05:00
|
|
|
dockerManager = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('dockerManager') > -1:
|
|
|
|
|
dockerManager = 0
|
|
|
|
|
|
2019-01-27 01:18:49 +05:00
|
|
|
containerization = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('containerization') > -1:
|
|
|
|
|
containerization = 0
|
|
|
|
|
|
2019-02-09 14:01:43 +05:00
|
|
|
manageServices = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('manageServices') > -1:
|
|
|
|
|
manageServices = 0
|
|
|
|
|
|
2019-07-16 23:23:16 +05:00
|
|
|
CLManager = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('CLManager') > -1:
|
|
|
|
|
CLManager = 0
|
|
|
|
|
|
2019-10-15 22:59:22 +05:00
|
|
|
IncBackups = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('IncBackups') > -1:
|
|
|
|
|
IncBackups = 0
|
|
|
|
|
|
2019-11-02 19:33:39 +05:00
|
|
|
WebTerminal = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('WebTerminal') > -1:
|
|
|
|
|
WebTerminal = 0
|
|
|
|
|
|
2019-11-05 14:07:37 +05:00
|
|
|
SESSION_COOKIE_SECURE = 1
|
|
|
|
|
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('SESSION_COOKIE_SECURE') > -1:
|
|
|
|
|
SESSION_COOKIE_SECURE = 0
|
|
|
|
|
|
2019-11-06 23:37:32 +05:00
|
|
|
DATABASE_ROUTERS = 1
|
|
|
|
|
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('DATABASE_ROUTERS') > -1:
|
|
|
|
|
DATABASE_ROUTERS = 0
|
|
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
Upgrade.stdOut('Restoring settings file!')
|
2017-10-24 19:16:36 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
writeToFile = open("/usr/local/CyberCP/CyberCP/settings.py", 'w')
|
2018-07-19 22:38:37 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
for items in data:
|
2019-07-16 23:23:16 +05:00
|
|
|
if items.find("CommonMiddleware") > -1:
|
|
|
|
|
if csrfCheck == 1:
|
2019-08-25 21:14:04 +05:00
|
|
|
writeToFile.writelines(" 'django.middleware.csrf.CsrfViewMiddleware',\n")
|
2019-07-16 23:23:16 +05:00
|
|
|
|
2019-11-05 14:07:37 +05:00
|
|
|
if items.find('DATABASE_ROUTERS') > -1:
|
2019-11-06 23:37:32 +05:00
|
|
|
writeToFile.writelines(items)
|
2019-11-05 14:07:37 +05:00
|
|
|
if SESSION_COOKIE_SECURE == 1:
|
|
|
|
|
con = """SESSION_COOKIE_SECURE = True
|
|
|
|
|
CSRF_COOKIE_SECURE = True
|
|
|
|
|
"""
|
|
|
|
|
writeToFile.writelines(con)
|
|
|
|
|
|
2019-08-27 14:40:02 +05:00
|
|
|
elif items.find("'filemanager',") > -1:
|
2018-08-21 13:10:40 +05:00
|
|
|
writeToFile.writelines(items)
|
2018-10-12 18:18:10 +05:00
|
|
|
if pluginCheck == 1:
|
|
|
|
|
writeToFile.writelines(" 'pluginHolder',\n")
|
2018-10-22 10:55:52 +05:00
|
|
|
if emailMarketing == 1:
|
|
|
|
|
writeToFile.writelines(" 'emailMarketing',\n")
|
2018-11-14 13:36:34 +05:00
|
|
|
if emailPremium == 1:
|
2018-09-03 16:46:51 +05:00
|
|
|
writeToFile.writelines(" 'emailPremium',\n")
|
2018-12-14 05:01:10 +05:00
|
|
|
if s3Backups == 1:
|
|
|
|
|
writeToFile.writelines(" 's3Backups',\n")
|
2019-01-13 23:58:09 +05:00
|
|
|
if dockerManager == 1:
|
|
|
|
|
writeToFile.writelines(" 'dockerManager',\n")
|
2019-01-27 01:18:49 +05:00
|
|
|
|
|
|
|
|
if containerization == 1:
|
|
|
|
|
writeToFile.writelines(" 'containerization',\n")
|
|
|
|
|
|
2019-02-09 14:01:43 +05:00
|
|
|
if manageServices == 1:
|
|
|
|
|
writeToFile.writelines(" 'manageServices',\n")
|
|
|
|
|
|
2019-10-15 22:59:22 +05:00
|
|
|
|
2019-07-16 23:23:16 +05:00
|
|
|
if CLManager == 1:
|
|
|
|
|
writeToFile.writelines(" 'CLManager',\n")
|
|
|
|
|
|
2019-10-15 22:59:22 +05:00
|
|
|
if IncBackups == 1:
|
|
|
|
|
writeToFile.writelines(" 'IncBackups',\n")
|
|
|
|
|
|
2019-11-02 19:33:39 +05:00
|
|
|
if WebTerminal == 1:
|
|
|
|
|
writeToFile.writelines(" 'WebTerminal',\n")
|
|
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
else:
|
|
|
|
|
writeToFile.writelines(items)
|
2017-10-24 19:16:36 +05:00
|
|
|
|
2019-01-28 15:19:59 +05:00
|
|
|
MEDIA_URL = 1
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('MEDIA_URL') > -1:
|
|
|
|
|
MEDIA_URL = 0
|
|
|
|
|
|
|
|
|
|
if MEDIA_URL == 1:
|
|
|
|
|
writeToFile.writelines("MEDIA_URL = '/home/cyberpanel/media/'\n")
|
|
|
|
|
writeToFile.writelines('MEDIA_ROOT = MEDIA_URL\n')
|
|
|
|
|
|
2019-11-06 23:37:32 +05:00
|
|
|
if DATABASE_ROUTERS == 1:
|
2019-11-09 22:29:38 +05:00
|
|
|
writeToFile.writelines("\nDATABASE_ROUTERS = ['backup.backupRouter.backupRouter']\n")
|
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
|
|
|
## Move static files
|
2017-10-24 19:16:36 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
Upgrade.staticContent()
|
|
|
|
|
except:
|
|
|
|
|
pass
|
2017-10-24 19:16:36 +05:00
|
|
|
|
2018-10-22 10:55:52 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def installPYDNS():
|
|
|
|
|
try:
|
|
|
|
|
command = "pip install pydns"
|
2018-12-14 05:01:10 +05:00
|
|
|
Upgrade.executioner(command, 'Install PyDNS', 1)
|
2018-10-22 10:55:52 +05:00
|
|
|
except OSError, msg:
|
|
|
|
|
Upgrade.stdOut(str(msg) + " [installPYDNS]")
|
|
|
|
|
return 0
|
|
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def installTLDExtract():
|
|
|
|
|
try:
|
2018-12-14 05:01:10 +05:00
|
|
|
command = "pip install tldextract"
|
|
|
|
|
Upgrade.executioner(command, 'Install tldextract', 1)
|
2019-07-16 23:23:16 +05:00
|
|
|
command = "pip install bcrypt"
|
|
|
|
|
Upgrade.executioner(command, 'Install tldextract', 1)
|
2018-08-21 13:10:40 +05:00
|
|
|
except OSError, msg:
|
|
|
|
|
Upgrade.stdOut(str(msg) + " [installTLDExtract]")
|
|
|
|
|
return 0
|
2018-07-19 22:38:37 +05:00
|
|
|
|
2018-10-12 18:18:10 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def installLSCPD():
|
|
|
|
|
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
|
|
|
|
2019-07-16 23:23:16 +05:00
|
|
|
command = 'wget https://cyberpanel.sh/lscpd -P /usr/local/lscp/bin/'
|
|
|
|
|
Upgrade.executioner(command, 'LSCPD Download.', 0)
|
2018-10-12 18:18:10 +05:00
|
|
|
|
2019-07-16 23:23:16 +05:00
|
|
|
command = 'chmod 755 %s' % (lscpdPath)
|
|
|
|
|
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
|
|
|
|
2018-10-12 18:18:10 +05:00
|
|
|
command = 'adduser lscpd -M -d /usr/local/lscp'
|
2018-12-14 05:01:10 +05:00
|
|
|
Upgrade.executioner(command, 'Add user LSCPD', 0)
|
2018-10-12 18:18:10 +05:00
|
|
|
|
|
|
|
|
command = 'groupadd 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 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!")
|
|
|
|
|
|
2018-12-14 05:01:10 +05:00
|
|
|
except BaseException, 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:
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
command = "chown -R lscpd:lscpd /usr/local/lscp/cyberpanel/rainloop/data"
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
command = "chmod 700 /usr/local/CyberCP/postfixSenderPolicy/client.py"
|
|
|
|
|
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)
|
|
|
|
|
|
2018-11-26 02:32:30 +05:00
|
|
|
Upgrade.stdOut("Permissions updated.")
|
|
|
|
|
|
2018-12-14 05:01:10 +05:00
|
|
|
except BaseException, msg:
|
|
|
|
|
Upgrade.stdOut(str(msg) + " [installLSCPD]")
|
2018-11-26 02:32:30 +05:00
|
|
|
|
2018-12-20 16:18:16 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def installPHP73():
|
|
|
|
|
try:
|
|
|
|
|
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')
|
|
|
|
|
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')
|
|
|
|
|
|
2019-08-03 14:53:31 +05:00
|
|
|
CentOSPath = '/etc/redhat-release'
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(CentOSPath):
|
|
|
|
|
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 upgradePDNS():
|
2019-07-24 22:37:37 +05:00
|
|
|
command = "yum install epel-release && curl -o /etc/yum.repos.d/powerdns-auth-42.repo https://repo.powerdns.com/repo-files/centos-auth-42.repo && yum --enablerepo=epel install pdns"
|
2019-07-03 13:15:26 +05:00
|
|
|
subprocess.call(command, shell=True)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def upgradeDovecot():
|
2019-07-25 14:12:54 +05:00
|
|
|
try:
|
|
|
|
|
Upgrade.stdOut("Upgrading Dovecot..")
|
|
|
|
|
CentOSPath = '/etc/redhat-release'
|
|
|
|
|
|
|
|
|
|
if os.path.exists(CentOSPath):
|
|
|
|
|
path = '/etc/yum.repos.d/dovecot.repo'
|
|
|
|
|
content = """[dovecot-2.3-latest]
|
2019-08-03 14:53:31 +05:00
|
|
|
name=Dovecot 2.3 CentOS $releasever - $basearch
|
|
|
|
|
baseurl=http://repo.dovecot.org/ce-2.3-latest/centos/$releasever/RPMS/$basearch
|
|
|
|
|
gpgkey=https://repo.dovecot.org/DOVECOT-REPO-GPG
|
|
|
|
|
gpgcheck=1
|
|
|
|
|
enabled=1"""
|
2019-07-25 14:12:54 +05:00
|
|
|
writeToFile = open(path, 'w')
|
|
|
|
|
writeToFile.write(content)
|
|
|
|
|
writeToFile.close()
|
2019-07-03 13:15:26 +05:00
|
|
|
|
2019-07-25 14:12:54 +05:00
|
|
|
command = "yum makecache -y"
|
|
|
|
|
Upgrade.executioner(command, 0)
|
2019-07-03 13:15:26 +05:00
|
|
|
|
2019-07-25 14:12:54 +05:00
|
|
|
command = "yum update -y"
|
|
|
|
|
Upgrade.executioner(command, 0)
|
2019-07-03 13:15:26 +05:00
|
|
|
|
2019-07-25 14:12:54 +05:00
|
|
|
## Remove Default Password Scheme
|
2019-07-03 13:15:26 +05:00
|
|
|
|
2019-07-25 14:12:54 +05:00
|
|
|
path = '/etc/dovecot/dovecot-sql.conf.ext'
|
2019-07-03 13:15:26 +05:00
|
|
|
|
2019-07-25 14:12:54 +05:00
|
|
|
data = open(path, 'r').readlines()
|
2019-07-03 13:15:26 +05:00
|
|
|
|
2019-07-25 14:12:54 +05:00
|
|
|
updatePasswords = 1
|
2019-07-16 23:23:16 +05:00
|
|
|
|
2019-07-25 14:12:54 +05:00
|
|
|
writeToFile = open(path, 'w')
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('default_pass_scheme') > -1:
|
|
|
|
|
updatePasswords = 0
|
|
|
|
|
continue
|
|
|
|
|
else:
|
|
|
|
|
writeToFile.writelines(items)
|
2019-07-03 13:15:26 +05:00
|
|
|
|
2019-07-25 14:12:54 +05:00
|
|
|
writeToFile.close()
|
2019-07-03 13:15:26 +05:00
|
|
|
|
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)
|
|
|
|
|
items.password = subprocess.check_output(shlex.split(command)).strip('\n')
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
shutil.copy('/etc/postfix/master.cf', '/etc/master.cf')
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
shutil.copy('/etc/postfix/main.cf', '/etc/main.cf')
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
gf = '/etc/yum.repos.d/gf.repo'
|
|
|
|
|
|
|
|
|
|
gfContent = """[gf]
|
|
|
|
|
name=Ghettoforge packages that won't overwrite core distro packages.
|
|
|
|
|
mirrorlist=http://mirrorlist.ghettoforge.org/el/7/gf/$basearch/mirrorlist
|
|
|
|
|
enabled=1
|
|
|
|
|
gpgcheck=1
|
|
|
|
|
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
|
|
|
|
|
failovermethod=priority
|
|
|
|
|
|
|
|
|
|
[gf-plus]
|
|
|
|
|
name=Ghettoforge packages that will overwrite core distro packages.
|
|
|
|
|
mirrorlist=http://mirrorlist.ghettoforge.org/el/7/plus/$basearch/mirrorlist
|
|
|
|
|
# Please read http://ghettoforge.org/index.php/Usage *before* enabling this repository!
|
|
|
|
|
enabled=1
|
|
|
|
|
gpgcheck=1
|
|
|
|
|
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
|
|
|
|
|
failovermethod=priority
|
|
|
|
|
"""
|
|
|
|
|
writeToFile = open(gf, 'w')
|
|
|
|
|
writeToFile.write(gfContent)
|
|
|
|
|
writeToFile.close()
|
|
|
|
|
|
|
|
|
|
command = 'yum remove postfix -y'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
command = 'rpm -Uvh http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
command = 'yum clean all'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
command = 'yum makecache fast'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
command = 'yum install -y postfix3 postfix3-mysql'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
shutil.move('/etc/master.cf', '/etc/postfix/master.cf')
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
try:
|
|
|
|
|
shutil.move('/etc/main.cf', '/etc/postfix/main.cf')
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
command = 'systemctl restart postfix'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
2019-07-25 14:12:54 +05:00
|
|
|
else:
|
|
|
|
|
command = 'curl https://repo.dovecot.org/DOVECOT-REPO-GPG | gpg --import'
|
|
|
|
|
subprocess.call(command, shell=True)
|
|
|
|
|
|
|
|
|
|
command = 'gpg --export ED409DA1 > /etc/apt/trusted.gpg.d/dovecot.gpg'
|
|
|
|
|
subprocess.call(command, shell=True)
|
|
|
|
|
|
|
|
|
|
debPath = '/etc/apt/sources.list.d/dovecot.list'
|
|
|
|
|
writeToFile = open(debPath, 'w')
|
|
|
|
|
writeToFile.write('deb https://repo.dovecot.org/ce-2.3-latest/ubuntu/bionic bionic main\n')
|
|
|
|
|
writeToFile.close()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
command = 'apt update -y'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
try:
|
2019-08-03 14:53:31 +05:00
|
|
|
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
|
|
|
|
subprocess.call(command, shell=True)
|
|
|
|
|
|
|
|
|
|
command = 'dpkg --configure -a'
|
2019-07-25 14:12:54 +05:00
|
|
|
Upgrade.executioner(command, 0)
|
2019-08-03 14:53:31 +05:00
|
|
|
|
|
|
|
|
command = 'apt --fix-broken install -y'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
command = 'DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical sudo apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" --only-upgrade install dovecot-mysql -y'
|
|
|
|
|
subprocess.call(command, shell=True)
|
2019-07-25 14:12:54 +05:00
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
## Remove Default Password Scheme
|
|
|
|
|
|
|
|
|
|
path = '/etc/dovecot/dovecot-sql.conf.ext'
|
|
|
|
|
|
|
|
|
|
data = open(path, 'r').readlines()
|
|
|
|
|
|
2019-08-03 14:53:31 +05:00
|
|
|
updatePasswords = 0
|
2019-07-25 14:12:54 +05:00
|
|
|
|
|
|
|
|
writeToFile = open(path, 'w')
|
|
|
|
|
for items in data:
|
|
|
|
|
if items.find('default_pass_scheme') > -1:
|
2019-08-03 14:53:31 +05:00
|
|
|
updatePasswords = 1
|
2019-07-25 14:12:54 +05:00
|
|
|
continue
|
|
|
|
|
else:
|
|
|
|
|
writeToFile.writelines(items)
|
|
|
|
|
|
|
|
|
|
writeToFile.close()
|
|
|
|
|
|
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)
|
|
|
|
|
items.password = subprocess.check_output(shlex.split(command)).strip('\n')
|
|
|
|
|
items.save()
|
|
|
|
|
|
2019-07-25 14:12:54 +05:00
|
|
|
|
|
|
|
|
command = "systemctl restart dovecot"
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
Upgrade.stdOut("Dovecot upgraded.")
|
|
|
|
|
|
|
|
|
|
except BaseException, msg:
|
|
|
|
|
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'
|
|
|
|
|
|
|
|
|
|
if os.path.exists(CentOSPath):
|
|
|
|
|
command = 'yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/copart/restic/repo/epel-7/copart-restic-epel-7.repo'
|
|
|
|
|
Upgrade.executioner(command, 'Add restic repo.')
|
|
|
|
|
|
|
|
|
|
command = 'yum install restic -y'
|
|
|
|
|
Upgrade.executioner(command, 'Install Restic')
|
|
|
|
|
else:
|
|
|
|
|
command = 'apt-get update -y'
|
|
|
|
|
Upgrade.executioner(command, 'Install Restic')
|
|
|
|
|
|
|
|
|
|
command = 'apt-get install restic -y'
|
|
|
|
|
Upgrade.executioner(command, 'Install Restic')
|
|
|
|
|
|
|
|
|
|
cronTab = '/etc/crontab'
|
|
|
|
|
|
|
|
|
|
data = open(cronTab, 'r').read()
|
|
|
|
|
|
|
|
|
|
if data.find('IncScheduler') == -1:
|
2019-10-19 13:03:00 +05:00
|
|
|
cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'
|
2019-10-15 22:59:22 +05:00
|
|
|
|
|
|
|
|
writeToFile = open(cronTab, 'a')
|
|
|
|
|
writeToFile.writelines(cronJob)
|
|
|
|
|
|
2019-10-19 13:03:00 +05:00
|
|
|
cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python2 /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'
|
2019-10-15 22:59:22 +05:00
|
|
|
writeToFile.writelines(cronJob)
|
|
|
|
|
writeToFile.close()
|
|
|
|
|
|
2019-11-02 19:29:02 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def p3():
|
|
|
|
|
|
|
|
|
|
### Virtual Env 3
|
|
|
|
|
|
|
|
|
|
CentOSPath = '/etc/redhat-release'
|
|
|
|
|
|
|
|
|
|
if os.path.exists(CentOSPath):
|
|
|
|
|
command = 'yum -y install python36 -y'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
command = 'virtualenv -p python3 /usr/local/CyberPanel/p3'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
env_path = '/usr/local/CyberPanel/p3'
|
|
|
|
|
subprocess.call(['virtualenv', env_path])
|
|
|
|
|
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
|
|
|
|
|
execfile(activate_this, dict(__file__=activate_this))
|
|
|
|
|
|
2019-11-02 19:54:05 +05:00
|
|
|
command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt')
|
2019-11-02 19:29:02 +05:00
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
command = 'apt install -y python3-pip'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
command = 'apt install build-essential libssl-dev libffi-dev python3-dev -y'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
command = 'apt install -y python3-venv'
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
2019-11-03 22:39:35 +05:00
|
|
|
command = 'virtualenv -p python3 /usr/local/CyberPanel/p3'
|
2019-11-02 19:29:02 +05:00
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
|
|
|
|
env_path = '/usr/local/CyberPanel/p3'
|
|
|
|
|
subprocess.call(['virtualenv', env_path])
|
|
|
|
|
activate_this = os.path.join(env_path, 'bin', 'activate_this.py')
|
|
|
|
|
execfile(activate_this, dict(__file__=activate_this))
|
|
|
|
|
|
|
|
|
|
command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt')
|
|
|
|
|
Upgrade.executioner(command, 0)
|
|
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
@staticmethod
|
|
|
|
|
def upgrade():
|
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
|
|
|
|
2019-11-06 14:17:52 +05:00
|
|
|
command = 'systemctl stop cpssh'
|
|
|
|
|
Upgrade.executioner(command, 'fix csf if there', 0)
|
|
|
|
|
|
2019-07-16 23:23:16 +05:00
|
|
|
postfixPath = '/home/cyberpanel/postfix'
|
|
|
|
|
pdns = '/home/cyberpanel/pdns'
|
|
|
|
|
pureftpd = '/home/cyberpanel/ftp'
|
|
|
|
|
|
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-08-21 13:10:40 +05:00
|
|
|
Version = version.objects.get(pk=1)
|
2018-07-19 22:38:37 +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()
|
|
|
|
|
Upgrade.mountTemp()
|
|
|
|
|
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
|
|
|
if float(Version.currentVersion) < 1.6:
|
|
|
|
|
Upgrade.stdOut('Upgrades works for version 1.6 onwards.')
|
|
|
|
|
os._exit(0)
|
2018-06-25 03:37:23 +05:00
|
|
|
|
2018-08-21 13:10:40 +05:00
|
|
|
##
|
2018-12-14 05:01:10 +05:00
|
|
|
|
2018-10-22 10:55:52 +05:00
|
|
|
Upgrade.installPYDNS()
|
2018-12-14 05:01:10 +05:00
|
|
|
Upgrade.downloadAndUpgrade(versionNumbring)
|
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
|
|
|
Upgrade.installTLDExtract()
|
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
|
|
|
|
|
|
|
|
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()
|
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.setupPythonWSGI()
|
|
|
|
|
Upgrade.someDirectories()
|
2018-10-12 18:18:10 +05:00
|
|
|
Upgrade.installLSCPD()
|
2019-06-08 21:41:43 +00:00
|
|
|
Upgrade.GeneralMigrations()
|
2019-11-04 23:05:13 +05:00
|
|
|
#Upgrade.p3()
|
2019-07-16 23:23:16 +05:00
|
|
|
|
|
|
|
|
if os.path.exists(postfixPath):
|
|
|
|
|
Upgrade.upgradeDovecot()
|
2018-05-14 22:26:25 +05:00
|
|
|
time.sleep(3)
|
|
|
|
|
|
2018-04-23 19:23:03 +05:00
|
|
|
## Upgrade version
|
2019-07-16 23:23:16 +05:00
|
|
|
Upgrade.fixPermissions()
|
2018-07-19 22:38:37 +05:00
|
|
|
Upgrade.upgradeVersion()
|
2017-10-24 19:16:36 +05:00
|
|
|
|
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)
|
2019-11-06 14:17:52 +05:00
|
|
|
command = 'systemctl start cpssh'
|
|
|
|
|
Upgrade.executioner(command, 'fix csf if there', 0)
|
2019-11-06 14:02:30 +05:00
|
|
|
|
2018-07-19 22:38:37 +05:00
|
|
|
Upgrade.stdOut("Upgrade Completed.")
|
2017-10-24 19:16:36 +05:00
|
|
|
|
2019-06-08 21:41:43 +00:00
|
|
|
|
2018-12-14 05:01:10 +05:00
|
|
|
def main():
|
|
|
|
|
Upgrade.upgrade()
|
|
|
|
|
|
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()
|