From df2f70209ad26100fd4bd994f7996ba7f2ff0084 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Thu, 2 Jan 2020 14:45:11 +0500 Subject: [PATCH] bug fix: upgrade --- plogical/upgrade.py | 70 +++++++++++---------------------------------- 1 file changed, 17 insertions(+), 53 deletions(-) diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 5b85651c3..14961de5f 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -1,24 +1,19 @@ import os import os.path import sys -import django import argparse - sys.path.append('/usr/local/CyberCP') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") -django.setup() import shlex import subprocess import shutil import requests import json import time -from baseTemplate.models import version import MySQLdb as mysql from CyberCP import settings import random import string -from mailServer.models import EUsers class Upgrade: @@ -488,6 +483,12 @@ class Upgrade: @staticmethod def upgradeVersion(): try: + + import django + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") + django.setup() + from baseTemplate.models import version + vers = version.objects.get(pk=1) getVersion = requests.get('https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/version.txt') latest = getVersion.json() @@ -1794,6 +1795,11 @@ enabled=1""" writeToFile.close() + import django + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") + django.setup() + from mailServer.models import EUsers + Upgrade.stdOut("Upgrading passwords...") for items in EUsers.objects.all(): if items.password.find('CRYPT') > -1: @@ -1921,6 +1927,12 @@ failovermethod=priority writeToFile.close() Upgrade.stdOut("Upgrading passwords...") + + import django + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings") + django.setup() + from mailServer.models import EUsers + for items in EUsers.objects.all(): if items.password.find('CRYPT') > -1: continue @@ -1975,49 +1987,6 @@ failovermethod=priority writeToFile.close() - @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') - exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), dict(__file__=activate_this)) - - command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt') - 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) - - 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') - exec(compile(open(activate_this, "rb").read(), activate_this, 'exec'), dict(__file__=activate_this)) - - command = "pip3 install --ignore-installed -r %s" % ('/usr/local/CyberCP/WebTerminal/requirments.txt') - Upgrade.executioner(command, 0) - @staticmethod def UpdateMaxSSLCons(): command = "sed -i 's|2000|10000|g' /usr/local/lsws/conf/httpd_config.xml" @@ -2085,7 +2054,6 @@ service_port = 9000 ## Current Version - Version = version.objects.get(pk=1) command = "systemctl stop lscpd" Upgrade.executioner(command, 'stop lscpd', 0) @@ -2102,10 +2070,6 @@ service_port = 9000 if os.path.exists('/usr/local/CyberPanel.' + versionNumbring): os.remove('/usr/local/CyberPanel.' + versionNumbring) - if float(Version.currentVersion) < 1.6: - Upgrade.stdOut('Upgrades works for version 1.6 onwards.') - os._exit(0) - ## Upgrade.installPYDNS()