mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-13 16:56:09 +01:00
upgrade: adjust to python3
This commit is contained in:
@@ -2,6 +2,7 @@ import os
|
|||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
import django
|
import django
|
||||||
|
import argparse
|
||||||
|
|
||||||
sys.path.append('/usr/local/CyberCP')
|
sys.path.append('/usr/local/CyberCP')
|
||||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||||
@@ -141,7 +142,7 @@ class Upgrade:
|
|||||||
|
|
||||||
os.chdir("wsgi-lsapi-1.4")
|
os.chdir("wsgi-lsapi-1.4")
|
||||||
|
|
||||||
command = "python ./configure.py"
|
command = "/usr/local/CyberPanel/bin/python ./configure.py"
|
||||||
Upgrade.executioner(command, 0)
|
Upgrade.executioner(command, 0)
|
||||||
|
|
||||||
command = "make"
|
command = "make"
|
||||||
@@ -438,47 +439,6 @@ class Upgrade:
|
|||||||
Upgrade.stdOut(str(msg) + ' [downloadLink]')
|
Upgrade.stdOut(str(msg) + ' [downloadLink]')
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def setupVirtualEnv():
|
|
||||||
try:
|
|
||||||
Upgrade.stdOut('Setting up virtual environment for CyberPanel.')
|
|
||||||
##
|
|
||||||
|
|
||||||
command = "yum install -y libattr-devel xz-devel gpgme-devel mariadb-devel curl-devel"
|
|
||||||
Upgrade.executioner(command, 'VirtualEnv Pre-reqs', 0)
|
|
||||||
|
|
||||||
command = "yum install -y libattr-devel xz-devel gpgme-devel curl-devel"
|
|
||||||
Upgrade.executioner(command, 'VirtualEnv Pre-reqs', 0)
|
|
||||||
|
|
||||||
##
|
|
||||||
|
|
||||||
command = "pip install virtualenv"
|
|
||||||
Upgrade.executioner(command, 'VirtualEnv Install', 0)
|
|
||||||
|
|
||||||
####
|
|
||||||
|
|
||||||
command = "virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberCP"
|
|
||||||
Upgrade.executioner(command, 'Setting up VirtualEnv [One]', 1)
|
|
||||||
|
|
||||||
##
|
|
||||||
|
|
||||||
env_path = '/usr/local/CyberCP'
|
|
||||||
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 = "pip install --ignore-installed -r /usr/local/CyberCP/requirments.txt"
|
|
||||||
Upgrade.executioner(command, 'CyberPanel requirements', 0)
|
|
||||||
|
|
||||||
command = "virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberCP"
|
|
||||||
Upgrade.executioner(command, 'Setting up VirtualEnv [Two]', 0)
|
|
||||||
|
|
||||||
Upgrade.stdOut('Virtual enviroment for CyberPanel successfully installed.')
|
|
||||||
except OSError as msg:
|
|
||||||
Upgrade.stdOut(str(msg) + " [setupVirtualEnv]", 0)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fileManager():
|
def fileManager():
|
||||||
## Copy File manager files
|
## Copy File manager files
|
||||||
@@ -1328,7 +1288,7 @@ class Upgrade:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def downloadAndUpgrade(versionNumbring):
|
def downloadAndUpgrade(versionNumbring, branch):
|
||||||
try:
|
try:
|
||||||
## Download latest version.
|
## Download latest version.
|
||||||
|
|
||||||
@@ -1357,6 +1317,15 @@ class Upgrade:
|
|||||||
|
|
||||||
shutil.move('cyberpanel', 'CyberCP')
|
shutil.move('cyberpanel', 'CyberCP')
|
||||||
|
|
||||||
|
if branch != 'stable':
|
||||||
|
os.chdir('CyberCP')
|
||||||
|
command = 'git checkout %s' % (branch)
|
||||||
|
Upgrade.executioner(command, command, 1)
|
||||||
|
os.chdir('/usr/local')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Copy settings file
|
## Copy settings file
|
||||||
|
|
||||||
data = open("/usr/local/settings.py", 'r').readlines()
|
data = open("/usr/local/settings.py", 'r').readlines()
|
||||||
@@ -1990,19 +1959,19 @@ failovermethod=priority
|
|||||||
data = open(cronTab, 'r').read()
|
data = open(cronTab, 'r').read()
|
||||||
|
|
||||||
if data.find('IncScheduler') == -1:
|
if data.find('IncScheduler') == -1:
|
||||||
cronJob = '0 12 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'
|
cronJob = '0 12 * * * root /usr/local/CyberPanel/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'
|
||||||
|
|
||||||
writeToFile = open(cronTab, 'a')
|
writeToFile = open(cronTab, 'a')
|
||||||
writeToFile.writelines(cronJob)
|
writeToFile.writelines(cronJob)
|
||||||
|
|
||||||
cronJob = '0 0 * * 0 root /usr/local/CyberCP/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'
|
cronJob = '0 0 * * 0 root /usr/local/CyberPanel/bin/python /usr/local/CyberCP/IncBackups/IncScheduler.py Daily\n'
|
||||||
writeToFile.writelines(cronJob)
|
writeToFile.writelines(cronJob)
|
||||||
writeToFile.close()
|
writeToFile.close()
|
||||||
|
|
||||||
|
|
||||||
if data.find('renew.py') == -1:
|
if data.find('renew.py') == -1:
|
||||||
writeToFile = open(cronTab, 'a')
|
writeToFile = open(cronTab, 'a')
|
||||||
writeToFile.writelines("0 2 * * * root /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/renew.py\n")
|
writeToFile.writelines("0 2 * * * root /usr/local/CyberPanel/bin/python /usr/local/CyberCP/plogical/renew.py\n")
|
||||||
writeToFile.close()
|
writeToFile.close()
|
||||||
|
|
||||||
|
|
||||||
@@ -2095,7 +2064,7 @@ service_port = 9000
|
|||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def upgrade():
|
def upgrade(branch):
|
||||||
|
|
||||||
# Upgrade.stdOut("Upgrades are currently disabled")
|
# Upgrade.stdOut("Upgrades are currently disabled")
|
||||||
# return 0
|
# return 0
|
||||||
@@ -2140,7 +2109,7 @@ service_port = 9000
|
|||||||
##
|
##
|
||||||
|
|
||||||
Upgrade.installPYDNS()
|
Upgrade.installPYDNS()
|
||||||
Upgrade.downloadAndUpgrade(versionNumbring)
|
Upgrade.downloadAndUpgrade(versionNumbring, branch)
|
||||||
Upgrade.download_install_phpmyadmin()
|
Upgrade.download_install_phpmyadmin()
|
||||||
Upgrade.downoad_and_install_raindloop()
|
Upgrade.downoad_and_install_raindloop()
|
||||||
|
|
||||||
@@ -2159,7 +2128,7 @@ service_port = 9000
|
|||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
Upgrade.setupVirtualEnv()
|
#Upgrade.setupVirtualEnv()
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
||||||
@@ -2217,7 +2186,12 @@ service_port = 9000
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
Upgrade.upgrade()
|
parser = argparse.ArgumentParser(description='CyberPanel Installer')
|
||||||
|
parser.add_argument('branch', help='Install from branch name.')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
Upgrade.upgrade(args.branch)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -1,11 +1,69 @@
|
|||||||
if [ ! -d "/usr/local/CyberPanel" ]; then
|
SERVER_OS='Undefined'
|
||||||
|
OUTPUT=$(cat /etc/*release)
|
||||||
|
|
||||||
|
|
||||||
|
yum clean all
|
||||||
|
yum update -y
|
||||||
|
|
||||||
|
echo -e "\nChecking OS..."
|
||||||
|
OUTPUT=$(cat /etc/*release)
|
||||||
|
if echo $OUTPUT | grep -q "CentOS Linux 7" ; then
|
||||||
|
echo -e "\nDetecting CentOS 7.X...\n"
|
||||||
|
SERVER_OS="CentOS7"
|
||||||
|
elif echo $OUTPUT | grep -q "CloudLinux 7" ; then
|
||||||
|
echo -e "\nDetecting CloudLinux 7.X...\n"
|
||||||
|
SERVER_OS="CentOS7"
|
||||||
|
elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then
|
||||||
|
echo -e "\nDetecting CentOS 8.X...\n"
|
||||||
|
SERVER_OS="CentOS8"
|
||||||
|
elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then
|
||||||
|
echo -e "\nDetecting Ubuntu 18.04...\n"
|
||||||
|
SERVER_OS="Ubuntu"
|
||||||
|
else
|
||||||
|
cat /etc/*release
|
||||||
|
echo -e "\nUnable to detect your OS...\n"
|
||||||
|
echo -e "\nCyberPanel is supported on Ubuntu 18.04, CentOS 7.x, CentOS 8.x and CloudLinux 7.x...\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $SERVER_OS == "CentOS7" ]] ; then
|
||||||
|
yum -y install yum-utils
|
||||||
|
yum -y groupinstall development
|
||||||
|
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
|
||||||
|
yum -y install python36u python36u-pip python36u-devel
|
||||||
|
elif [[ $SERVER_OS == "CentOS8" ]] ; then
|
||||||
|
yum install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel mariadb-devel curl-devel git platform-python-devel tar
|
||||||
|
dnf --enablerepo=PowerTools install gpgme-devel -y
|
||||||
|
dnf install python3 -y
|
||||||
|
else
|
||||||
|
apt update -y
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt upgrade -y
|
||||||
|
DEBIAN_FRONTEND=noninteracitve apt install -y htop telnet python-mysqldb python-dev libcurl4-gnutls-dev libgnutls28-dev libgcrypt20-dev libattr1 libattr1-dev liblzma-dev libgpgme-dev libmariadbclient-dev libcurl4-gnutls-dev libssl-dev nghttp2 libnghttp2-dev idn2 libidn2-dev libidn2-0-dev librtmp-dev libpsl-dev nettle-dev libgnutls28-dev libldap2-dev libgssapi-krb5-2 libk5crypto3 libkrb5-dev libcomerr2 libldap2-dev python-gpg python python-minimal python-setuptools virtualenv python-dev python-pip git
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt install -y python3-pip
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt install -y build-essential libssl-dev libffi-dev python3-dev
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt install -y python3-venv
|
||||||
|
fi
|
||||||
|
|
||||||
|
pip3.6 install virtualenv
|
||||||
|
|
||||||
|
rm -rf /usr/local/CyberPanel
|
||||||
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
|
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
|
||||||
source /usr/local/CyberPanel/bin/activate
|
source /usr/local/CyberPanel/bin/activate
|
||||||
rm -rf requirments.txt
|
rm -rf requirments.txt
|
||||||
wget https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/requirments.txt
|
wget https://raw.githubusercontent.com/usmannasir/cyberpanel/$1/requirments.txt
|
||||||
pip install --ignore-installed -r requirments.txt
|
pip install --ignore-installed -r requirments.txt
|
||||||
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
|
virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel
|
||||||
fi
|
|
||||||
rm -rf upgrade.py
|
rm -rf upgrade.py
|
||||||
wget https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/plogical/upgrade.py
|
wget https://raw.githubusercontent.com/usmannasir/cyberpanel/$1/plogical/upgrade.py
|
||||||
/usr/local/CyberPanel/bin/python upgrade.py
|
/usr/local/CyberPanel/bin/python upgrade.py $1
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|
virtualenv -p /usr/bin/python3 /usr/local/CyberCP
|
||||||
|
source /usr/local/CyberCP/bin/activate
|
||||||
|
wget -O requirements.txt https://raw.githubusercontent.com/usmannasir/cyberpanel/$1/requirments.txt
|
||||||
|
pip3.6 install --ignore-installed -r requirements.txt
|
||||||
|
systemctl restart lscpd
|
||||||
|
|
||||||
|
|
||||||
|
echo " CyberPanel Upgraded Installed " "
|
||||||
Reference in New Issue
Block a user