From ce871a2a67cbd6c308a0ab8085a34d462a837822 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Wed, 10 Jun 2020 22:35:52 +0500 Subject: [PATCH] bug fix: cent8 upgrade --- cyberpanel_upgrade.sh | 385 +++++++++++++++++++++--------------------- plogical/upgrade.py | 38 ++++- 2 files changed, 224 insertions(+), 199 deletions(-) diff --git a/cyberpanel_upgrade.sh b/cyberpanel_upgrade.sh index 6eb60345d..2efef0047 100644 --- a/cyberpanel_upgrade.sh +++ b/cyberpanel_upgrade.sh @@ -16,40 +16,42 @@ UBUNTU_20="False" ### Update and remove not needed repos -rm -f /etc/yum.repos.d/ius-archive.repo -rm -f /etc/yum.repos.d/copart-restic-epel-7.repo -rm -f /etc/yum.repos.d/dovecot.repo -rm -f /etc/yum.repos.d/epel.repo -rm -f /etc/yum.repos.d/epel-testing.repo -rm -f /etc/yum.repos.d/frank.repo -rm -f /etc/yum.repos.d/ius.repo -rm -f /etc/yum.repos.d/ius-testing.repo -rm -f /etc/yum.repos.d/MariaDB.repo -rm -f /etc/yum.repos.d/lux.repo -rm -f /etc/yum.repos.d/gf.repo -rm -f /etc/yum.repos.d/powerdns-auth-42.repo -rm -rf /etc/yum.repos.d/powerdns-auth-master.repo -rm -rf /etc/yum.repos.d/gf.repo.rpmnew +if [[ $SERVER_OS == "CentOS" ]]; then + rm -f /etc/yum.repos.d/ius-archive.repo + rm -f /etc/yum.repos.d/copart-restic-epel-7.repo + rm -f /etc/yum.repos.d/dovecot.repo + rm -f /etc/yum.repos.d/epel.repo + rm -f /etc/yum.repos.d/epel-testing.repo + rm -f /etc/yum.repos.d/frank.repo + rm -f /etc/yum.repos.d/ius.repo + rm -f /etc/yum.repos.d/ius-testing.repo + rm -f /etc/yum.repos.d/MariaDB.repo + rm -f /etc/yum.repos.d/lux.repo + rm -f /etc/yum.repos.d/gf.repo + rm -f /etc/yum.repos.d/powerdns-auth-42.repo + rm -rf /etc/yum.repos.d/powerdns-auth-master.repo + rm -rf /etc/yum.repos.d/gf.repo.rpmnew +fi ## -if [[ ${#SERVER_COUNTRY} == "2" ]] || [[ ${#SERVER_COUNTRY} == "6" ]] ; then - echo -e "\nChecking server..." +if [[ ${#SERVER_COUNTRY} == "2" ]] || [[ ${#SERVER_COUNTRY} == "6" ]]; then + echo -e "\nChecking server..." else - echo -e "\nChecking server..." - SERVER_COUNTRY="unknow" + echo -e "\nChecking server..." + SERVER_COUNTRY="unknow" fi #SERVER_COUNTRY="CN" #for test -if [[ $SERVER_COUNTRY == "CN" ]] ; then - GIT_URL="gitee.com/qtwrk/cyberpanel" - GIT_CONTENT_URL="gitee.com/qtwrk/cyberpanel/raw" +if [[ $SERVER_COUNTRY == "CN" ]]; then + GIT_URL="gitee.com/qtwrk/cyberpanel" + GIT_CONTENT_URL="gitee.com/qtwrk/cyberpanel/raw" fi regenerate_cert() { -cat << EOF > /usr/local/CyberCP/cert_conf + cat </usr/local/CyberCP/cert_conf [req] prompt=no distinguished_name=cyberpanel @@ -69,89 +71,88 @@ dnQualifier = CyberPanel [server_exts] extendedKeyUsage = 1.3.6.1.5.5.7.3.1 EOF -if [[ $1 == "8090" ]] ; then -openssl req -x509 -config /usr/local/CyberCP/cert_conf -extensions 'server_exts' -nodes -days 820 -newkey rsa:2048 -keyout /usr/local/lscp/conf/key.pem -out /usr/local/lscp/conf/cert.pem -fi + if [[ $1 == "8090" ]]; then + openssl req -x509 -config /usr/local/CyberCP/cert_conf -extensions 'server_exts' -nodes -days 820 -newkey rsa:2048 -keyout /usr/local/lscp/conf/key.pem -out /usr/local/lscp/conf/cert.pem + fi -if [[ $1 == "7080" ]] ; then - if [[ -f /usr/local/lsws/admin/conf/webadmin.key ]] ; then - key_path="/usr/local/lsws/admin/conf/webadmin.key" - cert_path="/usr/local/lsws/admin/conf/webadmin.crt" - else - key_path="/usr/local/lsws/admin/conf/cert/admin.key" - cert_path="/usr/local/lsws/admin/conf/cert/admin.crt" - fi -openssl req -x509 -config /usr/local/CyberCP/cert_conf -extensions 'server_exts' -nodes -days 820 -newkey rsa:2048 -keyout $key_path -out $cert_path -fi -rm -f /usr/local/CyberCP/cert_conf + if [[ $1 == "7080" ]]; then + if [[ -f /usr/local/lsws/admin/conf/webadmin.key ]]; then + key_path="/usr/local/lsws/admin/conf/webadmin.key" + cert_path="/usr/local/lsws/admin/conf/webadmin.crt" + else + key_path="/usr/local/lsws/admin/conf/cert/admin.key" + cert_path="/usr/local/lsws/admin/conf/cert/admin.crt" + fi + openssl req -x509 -config /usr/local/CyberCP/cert_conf -extensions 'server_exts' -nodes -days 820 -newkey rsa:2048 -keyout $key_path -out $cert_path + fi + rm -f /usr/local/CyberCP/cert_conf } input_branch() { - echo -e "\nPress Enter key to continue with latest version or Enter specific version such as: \e[31m1.9.4\e[39m , \e[31m1.9.5\e[39m ...etc" - echo -e "\nIf nothing is input in 10 seconds , script will proceed with latest stable. " - echo -e "\nPlease press Enter key , or specify a version number ,or wait for 10 seconds timeout: " - printf "%s" "" - read -t 10 TMP_YN + echo -e "\nPress Enter key to continue with latest version or Enter specific version such as: \e[31m1.9.4\e[39m , \e[31m1.9.5\e[39m ...etc" + echo -e "\nIf nothing is input in 10 seconds , script will proceed with latest stable. " + echo -e "\nPlease press Enter key , or specify a version number ,or wait for 10 seconds timeout: " + printf "%s" "" + read -t 10 TMP_YN - if [[ $TMP_YN == "" ]] ; then - BRANCH_NAME="v${TEMP:12:3}.${TEMP:25:1}" - echo -e "\nBranch name set to $BRANCH_NAME" - else - base_number="1.9.3" - if [[ $TMP_YN == *.*.* ]] ; then - #check input if it's valid format as X.Y.Z - output=$(awk -v num1="$base_number" -v num2="$TMP_YN" ' + if [[ $TMP_YN == "" ]]; then + BRANCH_NAME="v${TEMP:12:3}.${TEMP:25:1}" + echo -e "\nBranch name set to $BRANCH_NAME" + else + base_number="1.9.3" + if [[ $TMP_YN == *.*.* ]]; then + #check input if it's valid format as X.Y.Z + output=$(awk -v num1="$base_number" -v num2="$TMP_YN" ' BEGIN { print "num1", (num1 < num2 ? "<" : ">="), "num2" } ') - if [[ $output == *">="* ]] ; then - echo -e "\nYou must use version number higher than 1.9.4" - exit - else - BRANCH_NAME="v$TMP_YN" - echo "set branch name to $BRANCH_NAME" - fi - else - echo -e "\nPlease input a valid format version number." - exit - fi - fi + if [[ $output == *">="* ]]; then + echo -e "\nYou must use version number higher than 1.9.4" + exit + else + BRANCH_NAME="v$TMP_YN" + echo "set branch name to $BRANCH_NAME" + fi + else + echo -e "\nPlease input a valid format version number." + exit + fi + fi } install_utility() { -if [[ ! -f /usr/bin/cyberpanel_utility ]] ; then -wget -q -O /usr/bin/cyberpanel_utility https://cyberpanel.sh/misc/cyberpanel_utility.sh -chmod 700 /usr/bin/cyberpanel_utility -fi + if [[ ! -f /usr/bin/cyberpanel_utility ]]; then + wget -q -O /usr/bin/cyberpanel_utility https://cyberpanel.sh/misc/cyberpanel_utility.sh + chmod 700 /usr/bin/cyberpanel_utility + fi } check_root() { -echo -e "\nChecking root privileges...\n" -if echo $SUDO_TEST | grep SUDO > /dev/null ; then - echo -e "\nYou are using SUDO , please run as root user...\n" - echo -e "\nIf you don't have direct access to root user, please run \e[31msudo su -\e[39m command (do NOT miss the \e[31m-\e[39m at end or it will fail) and then run upgrade command again." - exit -fi + echo -e "\nChecking root privileges...\n" + if echo $SUDO_TEST | grep SUDO >/dev/null; then + echo -e "\nYou are using SUDO , please run as root user...\n" + echo -e "\nIf you don't have direct access to root user, please run \e[31msudo su -\e[39m command (do NOT miss the \e[31m-\e[39m at end or it will fail) and then run upgrade command again." + exit + fi -if [[ $(id -u) != 0 ]] > /dev/null; then - echo -e "\nYou must use root user to upgrade CyberPanel...\n" - exit -else - echo -e "\nYou are runing as root...\n" -fi + if [[ $(id -u) != 0 ]] >/dev/null; then + echo -e "\nYou must use root user to upgrade CyberPanel...\n" + exit + else + echo -e "\nYou are runing as root...\n" + fi } - check_return() { -#check previous command result , 0 = ok , non-0 = something wrong. -if [[ $? -eq "0" ]] ; then - : -else - echo -e "\ncommand failed, exiting..." - exit -fi + #check previous command result , 0 = ok , non-0 = something wrong. + if [[ $? -eq "0" ]]; then + : + else + echo -e "\ncommand failed, exiting..." + exit + fi } input_branch @@ -161,66 +162,68 @@ check_root 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" - curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel.repo > /etc/yum.repos.d/CyberPanel.repo - yum clean all +if echo $OUTPUT | grep -q "CentOS Linux 7"; then + echo -e "\nDetecting CentOS 7.X...\n" + SERVER_OS="CentOS7" + curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel.repo >/etc/yum.repos.d/CyberPanel.repo + yum clean all yum update -y yum autoremove epel-release -y rm -f /etc/yum.repos.d/epel.repo rm -f /etc/yum.repos.d/epel.repo.rpmsave -elif echo $OUTPUT | grep -q "CloudLinux 7" ; then - echo -e "\nDetecting CloudLinux 7.X...\n" - SERVER_OS="CentOS7" - curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel.repo > /etc/yum.repos.d/CyberPanel.repo - yum clean all +elif echo $OUTPUT | grep -q "CloudLinux 7"; then + echo -e "\nDetecting CloudLinux 7.X...\n" + SERVER_OS="CentOS7" + curl https://raw.githubusercontent.com/usmannasir/cyberpanel/v2.0.1/install/CyberPanel.repo >/etc/yum.repos.d/CyberPanel.repo + yum clean all yum update -y yum autoremove epel-release -y rm -f /etc/yum.repos.d/epel.repo rm -f /etc/yum.repos.d/epel.repo.rpmsave -elif echo $OUTPUT | grep -q "CentOS Linux 8" ; then - echo -e "\nDetecting CentOS 8.X...\n" - SERVER_OS="CentOS8" - yum clean all +elif echo $OUTPUT | grep -q "CentOS Linux 8"; then + rm -f /etc/yum.repos.d/CyberPanel.repo + dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-11.gf.el8.noarch.rpm + echo -e "\nDetecting CentOS 8.X...\n" + SERVER_OS="CentOS8" + yum clean all yum update -y yum autoremove epel-release -y rm -f /etc/yum.repos.d/epel.repo rm -f /etc/yum.repos.d/epel.repo.rpmsave yum autoremove epel-release -y dnf install epel-release -y -elif echo $OUTPUT | grep -q "Ubuntu 18.04" ; then - echo -e "\nDetecting Ubuntu 18.04...\n" - SERVER_OS="Ubuntu" -elif echo $OUTPUT | grep -q "Ubuntu 20.04" ; then - echo -e "\nDetecting Ubuntu 20.04...\n" - SERVER_OS="Ubuntu" - UBUNTU_20="True" +elif echo $OUTPUT | grep -q "Ubuntu 18.04"; then + echo -e "\nDetecting Ubuntu 18.04...\n" + SERVER_OS="Ubuntu" +elif echo $OUTPUT | grep -q "Ubuntu 20.04"; then + echo -e "\nDetecting Ubuntu 20.04...\n" + SERVER_OS="Ubuntu" + UBUNTU_20="True" 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 + 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 +if [ $SERVER_OS = "CentOS7" ]; then yum -y install yum-utils yum -y groupinstall development yum --enablerepo=CyberPanel install -y wget strace htop net-tools telnet curl which bc telnet htop libevent-devel gcc libattr-devel xz-devel gpgme-devel curl-devel git socat openssl-devel MariaDB-shared mariadb-devel python36u python36u-pip python36u-devel -elif [ $SERVER_OS = "CentOS8" ] ; then +elif [ $SERVER_OS = "CentOS8" ]; then dnf 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 socat - dnf --enablerepo=PowerTools install gpgme-devel -y - dnf install python3 -y + 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 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 virtualenv git + DEBIAN_FRONTEND=noninteractive apt upgrade -y + DEBIAN_FRONTEND=noninteracitve apt install -y htop telnet 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 virtualenv 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 + DEBIAN_FRONTEND=noninteractive apt install -y build-essential libssl-dev libffi-dev python3-dev + DEBIAN_FRONTEND=noninteractive apt install -y python3-venv fi -if [ $SERVER_OS = "Ubuntu" ] ; then +if [ $SERVER_OS = "Ubuntu" ]; then pip3 install virtualenv check_return else @@ -228,13 +231,12 @@ else check_return fi - -if [[ -f /usr/local/CyberPanel/bin/python2 ]] ; then +if [[ -f /usr/local/CyberPanel/bin/python2 ]]; then echo -e "\nPython 2 dectected, doing resetup...\n" rm -rf /usr/local/CyberPanel/bin virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanel check_return -elif [[ -d /usr/local/CyberPanel/bin/ ]] ; then +elif [[ -d /usr/local/CyberPanel/bin/ ]]; then echo -e "\nNo need to resetup virtualenv at /usr/local/CyberPanel...\n" else echo -e "\nNothing found, need fresh setup...\n" @@ -244,7 +246,7 @@ fi rm -f requirments.txt -if [[ $UBUNTU_20 == "False" ]] ; then +if [[ $UBUNTU_20 == "False" ]]; then wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/cyberpanel-pip.zip else wget -O /usr/local/cyberpanel-pip.zip https://rep.cyberpanel.net/ubuntu-pip.zip @@ -259,10 +261,10 @@ check_return . /usr/local/CyberPanel/bin/activate check_return -if [ $SERVER_OS = "Ubuntu" ] ; then +if [ $SERVER_OS = "Ubuntu" ]; then . /usr/local/CyberPanel/bin/activate check_return - if [[ $UBUNTU_20 == "False" ]] ; then + if [[ $UBUNTU_20 == "False" ]]; then pip3 install --ignore-installed /usr/local/pip-packs/* else pip3 install --ignore-installed /usr/local/packages/* @@ -285,21 +287,21 @@ check_return rm -rf upgrade.py wget https://$GIT_CONTENT_URL/${BRANCH_NAME}/plogical/upgrade.py -if [[ $SERVER_COUNTRY == "CN" ]] ; then -sed -i 's|wget https://raw.githubusercontent.com/usmannasir/cyberpanel/v1.9.4/lscpd-0.2.4 -P /usr/local/lscp/bin/|cp -f /usr/local/CyberCP/lscpd-0.2.4 /usr/local/lscp/bin/lscpd-0.2.4|g' upgrade.py -sed -i 's|wget https://raw.githubusercontent.com/usmannasir/cyberpanel/%s/lscpd-0.2.4 -P /usr/local/lscp/bin/|cp -f /usr/local/CyberCP/lscpd-0.2.4 /usr/local/lscp/bin/lscpd-0.2.4|g' upgrade.py -#sed -i $'s/0.2.4\' % (branch)/0.2.4\'/' upgrade.py -sed -i 's|raw.githubusercontent.com/usmannasir/cyberpanel|'${GIT_CONTENT_URL}'|g' upgrade.py -sed -i 's|git clone https://github.com/usmannasir/cyberpanel|git clone https://'${GIT_URL}'|g' upgrade.py +if [[ $SERVER_COUNTRY == "CN" ]]; then + sed -i 's|wget https://raw.githubusercontent.com/usmannasir/cyberpanel/v1.9.4/lscpd-0.2.4 -P /usr/local/lscp/bin/|cp -f /usr/local/CyberCP/lscpd-0.2.4 /usr/local/lscp/bin/lscpd-0.2.4|g' upgrade.py + sed -i 's|wget https://raw.githubusercontent.com/usmannasir/cyberpanel/%s/lscpd-0.2.4 -P /usr/local/lscp/bin/|cp -f /usr/local/CyberCP/lscpd-0.2.4 /usr/local/lscp/bin/lscpd-0.2.4|g' upgrade.py + #sed -i $'s/0.2.4\' % (branch)/0.2.4\'/' upgrade.py + sed -i 's|raw.githubusercontent.com/usmannasir/cyberpanel|'${GIT_CONTENT_URL}'|g' upgrade.py + sed -i 's|git clone https://github.com/usmannasir/cyberpanel|git clone https://'${GIT_URL}'|g' upgrade.py fi /usr/local/CyberPanel/bin/python upgrade.py $BRANCH_NAME check_return -if [[ -f /usr/local/CyberCP/bin/python2 ]] ; then - rm -rf /usr/local/CyberCP/bin - virtualenv -p /usr/bin/python3 /usr/local/CyberCP -elif [[ -d /usr/local/CyberCP/bin/ ]] ; then +if [[ -f /usr/local/CyberCP/bin/python2 ]]; then + rm -rf /usr/local/CyberCP/bin + virtualenv -p /usr/bin/python3 /usr/local/CyberCP +elif [[ -d /usr/local/CyberCP/bin/ ]]; then echo -e "\nNo need to resetup virtualenv at /usr/local/CyberCP...\n" else virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberCP @@ -308,10 +310,10 @@ fi check_return -if [ $SERVER_OS = "Ubuntu" ] ; then +if [ $SERVER_OS = "Ubuntu" ]; then . /usr/local/CyberCP/bin/activate check_return - if [[ $UBUNTU_20 == "False" ]] ; then + if [[ $UBUNTU_20 == "False" ]]; then pip3 install --ignore-installed /usr/local/pip-packs/* else pip3 install --ignore-installed /usr/local/packages/* @@ -324,7 +326,6 @@ else check_return fi - ## rm -f wsgi-lsapi-1.4.tgz @@ -344,79 +345,76 @@ cp lswsgi /usr/local/CyberCP/bin/ sed -i 's|python2|python|g' /usr/bin/adminPass chmod 700 /usr/bin/adminPass -if [[ ! -f /usr/sbin/ipset ]] && [[ $SERVER_OS == "Ubuntu" ]] ; then -ln -s /sbin/ipset /usr/sbin/ipset +if [[ ! -f /usr/sbin/ipset ]] && [[ $SERVER_OS == "Ubuntu" ]]; then + ln -s /sbin/ipset /usr/sbin/ipset fi -if [[ -f /etc/cyberpanel/webadmin_passwd ]] ; then -chmod 600 /etc/cyberpanel/webadmin_passwd +if [[ -f /etc/cyberpanel/webadmin_passwd ]]; then + chmod 600 /etc/cyberpanel/webadmin_passwd fi -if [[ -f /etc/pure-ftpd/pure-ftpd.conf ]] ; then -sed -i 's|NoAnonymous no|NoAnonymous yes|g' /etc/pure-ftpd/pure-ftpd.conf +if [[ -f /etc/pure-ftpd/pure-ftpd.conf ]]; then + sed -i 's|NoAnonymous no|NoAnonymous yes|g' /etc/pure-ftpd/pure-ftpd.conf fi - install_utility output=$(timeout 3 openssl s_client -connect 127.0.0.1:8090 2>/dev/null) echo $output | grep -q "mail@example.com" -if [[ $? == "0" ]] ; then -# it is using default installer generated cert -regenerate_cert 8090 +if [[ $? == "0" ]]; then + # it is using default installer generated cert + regenerate_cert 8090 fi output=$(timeout 3 openssl s_client -connect 127.0.0.1:7080 2>/dev/null) echo $output | grep -q "mail@example.com" -if [[ $? == "0" ]] ; then -regenerate_cert 7080 +if [[ $? == "0" ]]; then + regenerate_cert 7080 fi +if [[ $SERVER_OS == "CentOS7" ]]; then -if [[ $SERVER_OS == "CentOS7" ]] ; then + sed -i 's|error_reporting = E_ALL \& ~E_DEPRECATED \& ~E_STRICT|error_reporting = E_ALL \& ~E_DEPRECATED \& ~E_STRICT|g' /usr/local/lsws/{lsphp72,lsphp73}/etc/php.ini + #fix php.ini & issue -sed -i 's|error_reporting = E_ALL \& ~E_DEPRECATED \& ~E_STRICT|error_reporting = E_ALL \& ~E_DEPRECATED \& ~E_STRICT|g' /usr/local/lsws/{lsphp72,lsphp73}/etc/php.ini -#fix php.ini & issue - -yum list installed lsphp74-devel - if [[ $? != "0" ]] ; then - yum install -y lsphp74-devel - fi + yum list installed lsphp74-devel + if [[ $? != "0" ]]; then + yum install -y lsphp74-devel + fi fi -if [[ $SERVER_OS == "Ubuntu" ]] ; then - dpkg -l lsphp74-dev > /dev/null 2>&1 - if [[ $? != "0" ]] ; then - apt install -y lsphp74-dev - fi +if [[ $SERVER_OS == "Ubuntu" ]]; then + dpkg -l lsphp74-dev >/dev/null 2>&1 + if [[ $? != "0" ]]; then + apt install -y lsphp74-dev + fi fi -if [[ ! -f /usr/local/lsws/lsphp74/lib64/php/modules/zip.so ]] && [[ $SERVER_OS == "CentOS7" ]] ; then - yum list installed libzip-devel > /dev/null 2>&1 - if [[ $? == "0" ]] ; then - yum remove -y libzip-devel - fi +if [[ ! -f /usr/local/lsws/lsphp74/lib64/php/modules/zip.so ]] && [[ $SERVER_OS == "CentOS7" ]]; then + yum list installed libzip-devel >/dev/null 2>&1 + if [[ $? == "0" ]]; then + yum remove -y libzip-devel + fi - yum install -y https://cdn.cyberpanel.sh/misc/libzip-0.11.2-6.el7.psychotic.x86_64.rpm - yum install -y https://cdn.cyberpanel.sh/misc/libzip-devel-0.11.2-6.el7.psychotic.x86_64.rpm - yum install lsphp74-devel + yum install -y https://cdn.cyberpanel.sh/misc/libzip-0.11.2-6.el7.psychotic.x86_64.rpm + yum install -y https://cdn.cyberpanel.sh/misc/libzip-devel-0.11.2-6.el7.psychotic.x86_64.rpm + yum install lsphp74-devel - if [[ ! -d /usr/local/lsws/lsphp74/tmp ]] ; then - mkdir /usr/local/lsws/lsphp74/tmp - fi + if [[ ! -d /usr/local/lsws/lsphp74/tmp ]]; then + mkdir /usr/local/lsws/lsphp74/tmp + fi - /usr/local/lsws/lsphp74/bin/pecl channel-update pecl.php.net - /usr/local/lsws/lsphp74/bin/pear config-set temp_dir /usr/local/lsws/lsphp74/tmp - /usr/local/lsws/lsphp74/bin/pecl install zip - if [[ $? == 0 ]] ; then - echo "extension=zip.so" > /usr/local/lsws/lsphp74/etc/php.d/20-zip.ini - chmod 755 /usr/local/lsws/lsphp74/lib64/php/modules/zip.so - else - echo -e "\nlsphp74-zip compilation failed..." - fi + /usr/local/lsws/lsphp74/bin/pecl channel-update pecl.php.net + /usr/local/lsws/lsphp74/bin/pear config-set temp_dir /usr/local/lsws/lsphp74/tmp + /usr/local/lsws/lsphp74/bin/pecl install zip + if [[ $? == 0 ]]; then + echo "extension=zip.so" >/usr/local/lsws/lsphp74/etc/php.d/20-zip.ini + chmod 755 /usr/local/lsws/lsphp74/lib64/php/modules/zip.so + else + echo -e "\nlsphp74-zip compilation failed..." + fi fi #fix the lsphp74-zip missing issue. - ## systemctl restart lscpd @@ -431,18 +429,17 @@ rm -f /usr/local/composer.sh ### Disable Centos Default Repos - disable_repos() { -if [[ $SERVER_OS == "CentOS" ]] ; then - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Base.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Debuginfo.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Media.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Vault.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-CR.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-fasttrack.repo - sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Sources.repo -fi + if [[ $SERVER_OS == "CentOS" ]]; then + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Base.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Debuginfo.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Media.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Vault.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-CR.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-fasttrack.repo + sed -i 's|enabled=1|enabled=0|g' /etc/yum.repos.d/CentOS-Sources.repo + fi } diff --git a/plogical/upgrade.py b/plogical/upgrade.py index 8c89749dc..f3da379a8 100755 --- a/plogical/upgrade.py +++ b/plogical/upgrade.py @@ -16,12 +16,23 @@ import string VERSION = '2.0' BUILD = 1 +CENTOS7 = 0 +CENTOS8 = 1 + class Upgrade: logPath = "/usr/local/lscp/logs/upgradeLog" cdn = 'cdn.cyberpanel.sh' installedOutput = '' CentOSPath = '/etc/redhat-release' + @staticmethod + def decideCentosVersion(): + + if open(Upgrade.CentOSPath, 'r').read().find('CentOS Linux release 8') > -1: + return CENTOS8 + else: + return CENTOS7 + @staticmethod def stdOut(message, do_exit=0): print("\n\n") @@ -1706,7 +1717,12 @@ class Upgrade: if os.path.exists(CentOSPath): - if Upgrade.installedOutput.find('2:2.3.10-2') == -1: + if Upgrade.decideCentosVersion() == CENTOS7: + findText = '2:2.3.10-2' + else: + findText = '2.3.10.1-1.gf.el8' + + if Upgrade.installedOutput.find(findText) == -1: command = "yum makecache -y" Upgrade.executioner(command, 0) @@ -1747,7 +1763,12 @@ class Upgrade: ### Postfix Upgrade - if Upgrade.installedOutput.find('2:3.4.7-1.gf.el7') == -1: + if Upgrade.decideCentosVersion() == CENTOS7: + findText = '2:3.4.7-1.gf.el7' + else: + findText = '3.5.2-1.gf.el8' + + if Upgrade.installedOutput.find(findText) == -1: try: shutil.copy('/etc/postfix/master.cf', '/etc/master.cf') except: @@ -1766,10 +1787,17 @@ class Upgrade: command = 'yum clean all' Upgrade.executioner(command, 0) - command = 'yum makecache fast' - Upgrade.executioner(command, 0) + if Upgrade.decideCentosVersion() == CENTOS7: + command = 'yum makecache fast' + else: + command = 'yum makecache -y' + + Upgrade.executioner(command, 0) + if Upgrade.decideCentosVersion() == CENTOS7: + command = 'yum install --enablerepo=CyberPanel -y postfix3 postfix3-mysql' + else: + command = 'dnf install --enablerepo=gf-plus postfix3 postfix3-mysql -y' - command = 'yum install --enablerepo=CyberPanel -y postfix3 postfix3-mysql' Upgrade.executioner(command, 0) try: