From d76d2dbf4b3acedc7c0c8616e0cab77c8d16a7d9 Mon Sep 17 00:00:00 2001 From: usmannasir Date: Tue, 6 Aug 2024 23:20:04 +0500 Subject: [PATCH] take care if due to new packages upgrades dont work --- cyberpanel_upgrade.sh | 58 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/cyberpanel_upgrade.sh b/cyberpanel_upgrade.sh index 3eb9063d2..5495e00e6 100644 --- a/cyberpanel_upgrade.sh +++ b/cyberpanel_upgrade.sh @@ -611,7 +611,52 @@ Pre_Upgrade_Branch_Input() { Main_Upgrade() { /usr/local/CyberPanel/bin/python upgrade.py "$Branch_Name" - Check_Return +# Capture the return code of the last command executed +RETURN_CODE=$? + +# Check if the command was successful (return code 0) +if [ $RETURN_CODE -eq 0 ]; then + echo "Upgrade successful." +else + + + if [ -e /usr/bin/pip3 ]; then + PIP3="/usr/bin/pip3" + else + PIP3="pip3.6" + fi + + rm -rf /usr/local/CyberPanelTemp + virtualenv -p /usr/bin/python3 --system-site-packages /usr/local/CyberPanelTemp + +# shellcheck disable=SC1091 +. /usr/local/CyberPanelTemp/bin/activate + +wget -O /usr/local/requirments-old.txt "${Git_Content_URL}/${Branch_Name}/requirments-old.txt" + + if [[ "$Server_OS" = "CentOS" ]] ; then +# $PIP3 install --default-timeout=3600 virtualenv==16.7.9 +# Check_Return + $PIP3 install --default-timeout=3600 --ignore-installed -r /usr/local/requirments-old.txt + Check_Return +elif [[ "$Server_OS" = "Ubuntu" ]] ; then + # shellcheck disable=SC1091 + . /usr/local/CyberPanelTemp/bin/activate + Check_Return + pip3 install --default-timeout=3600 --ignore-installed -r /usr/local/requirments-old.txt + Check_Return +elif [[ "$Server_OS" = "openEuler" ]] ; then + pip3 install --default-timeout=3600 --ignore-installed -r /usr/local/requirments-old.txt + Check_Return +fi + +/usr/local/CyberPanelTemp/bin/python upgrade.py "$Branch_Name" +Check_Return + +rm -rf /usr/local/CyberPanelTemp + +fi + rm -rf /usr/local/CyberCP/bin rm -rf /usr/local/CyberCP/lib @@ -776,6 +821,17 @@ rm -f /usr/local/requirments.txt chown -R cyberpanel:cyberpanel /usr/local/CyberCP/lib chown -R cyberpanel:cyberpanel /usr/local/CyberCP/lib64 + + + +if [[ "$Server_OS_Version" = "9" ]] || [[ "$Server_OS_Version" = "8" ]]; then + echo "PYTHONHOME=/usr" > /usr/local/lscp/conf/pythonenv.conf + else + # Uncomment and use the following lines if necessary for other OS versions + # rsync -av --ignore-existing /usr/lib64/python3.9/ /usr/local/CyberCP/lib64/python3.9/ + # Check_Return + : +fi systemctl restart lscpd }