From 15e8d7126f9d1ac47c69b2318605530c4ba7b363 Mon Sep 17 00:00:00 2001 From: qtwrk Date: Sat, 21 Aug 2021 01:21:51 +0200 Subject: [PATCH 1/8] install acme.sh before main installation install acme.sh before main installation for issues #705 #707 #708 #709 --- cyberpanel.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index 49b3c20af..48db69dd2 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -1321,7 +1321,24 @@ sed -i 's|mirror.cyberpanel.net|cyberpanel.sh|g' install.py if [[ $Server_Country = "CN" ]] ; then Pre_Install_CN_Replacement -fi +else + sed -i 's|wget -O - https://get.acme.sh \| sh|echo acme|g' install.py + sed -i 's|/root/.acme.sh/acme.sh --upgrade --auto-upgrade|echo acme2|g' install.py + + Current_Dir=$(pwd) + Retry_Command "git clone https://github.com/acmesh-official/acme.sh.git" + cd acme.sh || exit + ./acme.sh --install + cd "$Current_Dir" || exit + rm -rf acme.sh + + # shellcheck disable=SC2016 + sed -i 's|$PROJECT/archive/$BRANCH.tar.gz|https://cyberpanel.sh/codeload.github.com/acmesh-official/acme.sh/tar.gz/master|g' /root/.acme.sh/acme.sh + + Retry_Command "/root/.acme.sh/acme.sh --upgrade --auto-upgrade" + #install acme and upgrade it beforehand, to prevent gitee fail +fi + #install acme.sh before main installation for issues #705 #707 #708 #709 echo -e "Preparing...\n" @@ -1927,4 +1944,4 @@ Post_Install_Setup_Utility Post_Install_Tweak -Post_Install_Display_Final_Info \ No newline at end of file +Post_Install_Display_Final_Info From cd44343c563cb3653244d9c7707b8586a510f9e2 Mon Sep 17 00:00:00 2001 From: qtwrk Date: Sat, 21 Aug 2021 01:25:08 +0200 Subject: [PATCH 2/8] Update cyberpanel.sh --- cyberpanel.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index 48db69dd2..a8d689633 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -1332,9 +1332,6 @@ else cd "$Current_Dir" || exit rm -rf acme.sh - # shellcheck disable=SC2016 - sed -i 's|$PROJECT/archive/$BRANCH.tar.gz|https://cyberpanel.sh/codeload.github.com/acmesh-official/acme.sh/tar.gz/master|g' /root/.acme.sh/acme.sh - Retry_Command "/root/.acme.sh/acme.sh --upgrade --auto-upgrade" #install acme and upgrade it beforehand, to prevent gitee fail fi From bccbe97029875a23f6688e2cb2d85461465e3aca Mon Sep 17 00:00:00 2001 From: qtwrk Date: Tue, 24 Aug 2021 20:39:34 +0200 Subject: [PATCH 3/8] update gf repo --- install/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index f4be7829a..57c58f72d 100755 --- a/install/install.py +++ b/install/install.py @@ -781,7 +781,7 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) elif self.distro == cent8: - command = 'dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-11.gf.el8.noarch.rpm' + command = 'dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-12.gf.el8.noarch.rpm' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) command = 'dnf install --enablerepo=gf-plus postfix3 postfix3-mysql -y' From 2e76d0623266cb8c9f8758d3ee753e6a966ca2a3 Mon Sep 17 00:00:00 2001 From: qtwrk Date: Tue, 24 Aug 2021 20:41:39 +0200 Subject: [PATCH 4/8] update gf repo --- cyberpanel.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index a8d689633..e366000c1 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -1252,10 +1252,10 @@ if [[ "$Server_OS" = "CentOS" ]] ; then sed -i 's|https://mirror.ghettoforge.org/distributions|https://cyberpanel.sh/mirror.ghettoforge.org/distributions|g' install.py if [[ "$Server_OS_Version" = "8" ]] ; then - sed -i 's|dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-11.gf.el8.noarch.rpm|echo gf8|g' install.py - sed -i 's|dnf --nogpg install -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-11.gf.el8.noarch.rpm|echo gf8|g' install.py + sed -i 's|dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-12.gf.el8.noarch.rpm|echo gf8|g' install.py + sed -i 's|dnf --nogpg install -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-12.gf.el8.noarch.rpm|echo gf8|g' install.py - Retry_Command "dnf --nogpg install -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-11.gf.el8.noarch.rpm" + Retry_Command "dnf --nogpg install -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-12.gf.el8.noarch.rpm" sed -i "s|mirrorlist=http://mirrorlist.ghettoforge.org/el/8/gf/\$basearch/mirrorlist|baseurl=https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/|g" /etc/yum.repos.d/gf.repo sed -i "s|mirrorlist=http://mirrorlist.ghettoforge.org/el/8/plus/\$basearch/mirrorlist|baseurl=https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/8/plus/x86_64/|g" /etc/yum.repos.d/gf.repo #get this set up beforehand. From 453fdc2a172dc61ccf1762cf7f83be8b7704fd4d Mon Sep 17 00:00:00 2001 From: qtwrk Date: Tue, 24 Aug 2021 20:44:37 +0200 Subject: [PATCH 5/8] Update cyberpanel.sh --- cyberpanel.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index e366000c1..e701688f8 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -1252,10 +1252,10 @@ if [[ "$Server_OS" = "CentOS" ]] ; then sed -i 's|https://mirror.ghettoforge.org/distributions|https://cyberpanel.sh/mirror.ghettoforge.org/distributions|g' install.py if [[ "$Server_OS_Version" = "8" ]] ; then - sed -i 's|dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-12.gf.el8.noarch.rpm|echo gf8|g' install.py - sed -i 's|dnf --nogpg install -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-12.gf.el8.noarch.rpm|echo gf8|g' install.py + sed -i 's|dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el8.noarch.rpm|echo gf8|g' install.py + sed -i 's|dnf --nogpg install -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el8.noarch.rpm|echo gf8|g' install.py - Retry_Command "dnf --nogpg install -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-12.gf.el8.noarch.rpm" + Retry_Command "dnf --nogpg install -y https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el8.noarch.rpm" sed -i "s|mirrorlist=http://mirrorlist.ghettoforge.org/el/8/gf/\$basearch/mirrorlist|baseurl=https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/|g" /etc/yum.repos.d/gf.repo sed -i "s|mirrorlist=http://mirrorlist.ghettoforge.org/el/8/plus/\$basearch/mirrorlist|baseurl=https://cyberpanel.sh/mirror.ghettoforge.org/distributions/gf/el/8/plus/x86_64/|g" /etc/yum.repos.d/gf.repo #get this set up beforehand. From 8c1658eb123d864907a34a7dc3633c0ce11a061a Mon Sep 17 00:00:00 2001 From: qtwrk Date: Tue, 24 Aug 2021 20:45:54 +0200 Subject: [PATCH 6/8] Update install.py --- install/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/install.py b/install/install.py index 57c58f72d..130657f28 100755 --- a/install/install.py +++ b/install/install.py @@ -781,7 +781,7 @@ $cfg['Servers'][$i]['LogoutURL'] = 'phpmyadminsignin.php?logout'; preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) elif self.distro == cent8: - command = 'dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/el/8/gf/x86_64/gf-release-8-12.gf.el8.noarch.rpm' + command = 'dnf --nogpg install -y https://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el8.noarch.rpm' preFlightsChecks.call(command, self.distro, command, command, 1, 0, os.EX_OSERR) command = 'dnf install --enablerepo=gf-plus postfix3 postfix3-mysql -y' From f5b42657980c8da9f84a8d1543ac21aae93c2713 Mon Sep 17 00:00:00 2001 From: qtwrk Date: Tue, 24 Aug 2021 21:45:09 +0200 Subject: [PATCH 7/8] Update cyberpanel.sh --- cyberpanel.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index e701688f8..8a99be1f2 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -1212,7 +1212,7 @@ tar xzvf "lsws-$LSWS_Stable_Version-ent-x86_64-linux.tar.gz" >/dev/null cd "/root/cyberpanel-tmp/lsws-$LSWS_Stable_Version/conf" || exit if [[ "$License_Key" = "Trial" ]]; then Retry_Command "wget -q https://cyberpanel.sh/license.litespeedtech.com/reseller/trial.key" - sed -i "s|writeSerial = open('lsws-5.4.2/serial.no', 'w')|command = 'wget -q --output-document=./lsws-$LSWS_Stable_Version/trial.key https://cyberpanel.sh/license.litespeedtech.com/reseller/trial.key'|g" "$Current_Dir/installCyberPanel.py" + sed -i "s|writeSerial = open('lsws-6.0/serial.no', 'w')|command = 'wget -q --output-document=./lsws-$LSWS_Stable_Version/trial.key https://cyberpanel.sh/license.litespeedtech.com/reseller/trial.key'|g" "$Current_Dir/installCyberPanel.py" sed -i 's|writeSerial.writelines(self.serial)|subprocess.call(command, shell=True)|g' "$Current_Dir/installCyberPanel.py" sed -i 's|writeSerial.close()||g' "$Current_Dir/installCyberPanel.py" else @@ -1310,6 +1310,7 @@ if [[ $Server_Edition = "Enterprise" ]] ; then sed -i "s|lsws-5.4.2|lsws-$LSWS_Stable_Version|g" installCyberPanel.py sed -i "s|lsws-5.3.5|lsws-$LSWS_Stable_Version|g" installCyberPanel.py + sed -i "s|lsws-6.0|lsws-$LSWS_Stable_Version|g" installCyberPanel.py #this sed must be done after license validation Enterprise_Flag="--ent ent --serial " From e105036056e5d50286a6a020055514b49670f7e3 Mon Sep 17 00:00:00 2001 From: qtwrk Date: Mon, 30 Aug 2021 22:44:56 +0200 Subject: [PATCH 8/8] update some permissions --- cyberpanel.sh | 31 +++++++++++++++++-------------- cyberpanel_upgrade.sh | 15 ++++++++++----- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/cyberpanel.sh b/cyberpanel.sh index 8a99be1f2..a2e4c67fb 100644 --- a/cyberpanel.sh +++ b/cyberpanel.sh @@ -95,8 +95,8 @@ Git_Content_URL="" Git_Clone_URL="" LSWS_Latest_URL="https://cyberpanel.sh/update.litespeedtech.com/ws/latest.php" -curl --silent --max-time 30 -4 -o /tmp/lsws_latest "$LSWS_Latest_URL" 2>/dev/null -LSWS_Stable_Line=$(grep "LSWS_STABLE" /tmp/lsws_latest) +LSWS_Tmp=$(curl --silent --max-time 30 -4 "$LSWS_Latest_URL") +LSWS_Stable_Line=$(echo "$LSWS_Tmp" | grep "LSWS_STABLE") LSWS_Stable_Version=$(expr "$LSWS_Stable_Line" : '.*LSWS_STABLE=\(.*\) BUILD .*') #grab the LSWS latest stable version. @@ -107,7 +107,7 @@ Debug_Log2 "Starting installation..,1" } Debug_Log() { -echo -e "\n${1}=${2}\n" >> /tmp/cyberpanel_debug.log +echo -e "\n${1}=${2}\n" >> "/var/log/cyberpanel_debug_$(date +"%Y-%m-%d")_${Random_Log_Name}.log" } Debug_Log2() { @@ -174,12 +174,12 @@ Retry_Command() { # shellcheck disable=SC2034 for i in {1..50}; do - if [[ "$i" = "50" ]] ; then + if [[ "$i" = "50" ]] ; then echo "command $1 failed for 50 times, exit..." exit 2 else $1 && break || echo -e "\n$1 has failed for $i times\nWait for 3 seconds and try again...\n"; sleep 3; - fi + fi done } @@ -213,12 +213,12 @@ Server_IP=$(curl --silent --max-time 30 -4 https://cyberpanel.sh/?ip) echo -e "\nChecking server location...\n" -if [[ "$Server_Country" != "CN" ]] ; then +if [[ "$Server_Country" != "CN" ]] ; then Server_Country=$(curl --silent --max-time 10 -4 https://cyberpanel.sh/?country) if [[ ${#Server_Country} != "2" ]] ; then Server_Country="Unknow" fi -fi +fi #to avoid repeated check_ip called by debug_log2 to break force mirror for CN servers. if [[ "$Debug" = "On" ]] ; then @@ -829,7 +829,7 @@ if [[ $Server_OS = "CentOS" ]] ; then yum autoremove -y epel-release rm -f /etc/yum.repos.d/epel.repo rm -f /etc/yum.repos.d/epel.repo.rpmsave - + yum install -y yum-plugin-copr Check_Return "yum repo" "no_exit" yum copr enable -y copart/restic @@ -1335,7 +1335,7 @@ else Retry_Command "/root/.acme.sh/acme.sh --upgrade --auto-upgrade" #install acme and upgrade it beforehand, to prevent gitee fail -fi +fi #install acme.sh before main installation for issues #705 #707 #708 #709 echo -e "Preparing...\n" @@ -1559,7 +1559,9 @@ Webadmin_Pass=$( Encrypt_string=$(/usr/local/lsws/admin/fcgi-bin/${PHP_Command} /usr/local/lsws/admin/misc/htpasswd.php "${Webadmin_Pass}") echo "" >/usr/local/lsws/admin/conf/htpasswd -echo "admin:$Encrypt_string" >/usr/local/lsws/admin/conf/htpasswd +echo "admin:$Encrypt_string" > /usr/local/lsws/admin/conf/htpasswd +chown lsadm:lsadm /usr/local/lsws/admin/conf/htpasswd +chmod 600 /usr/local/lsws/admin/conf/htpasswd echo "${Webadmin_Pass}" >/etc/cyberpanel/webadmin_passwd chmod 600 /etc/cyberpanel/webadmin_passwd } @@ -1766,6 +1768,7 @@ rm -rf /etc/profile.d/cyberpanel* curl --silent -o /etc/profile.d/cyberpanel.sh https://cyberpanel.sh/?banner 2>/dev/null chmod 700 /etc/profile.d/cyberpanel.sh echo "$Admin_Pass" > /etc/cyberpanel/adminPass +chmod 600 /etc/cyberpanel/adminPass /usr/local/CyberPanel/bin/python /usr/local/CyberCP/plogical/adminPass.py --password "$Admin_Pass" mkdir -p /etc/opendkim @@ -1851,8 +1854,6 @@ systemctl start lsws >/dev/null 2>&1 echo -e "\nFinalizing...\n" echo -e "Cleaning up...\n" rm -rf /root/cyberpanel -rm -f /tmp/cyberpanel_debug.log -rm -f /tmp/lsws_latest if [[ "$Server_Country" = "CN" ]] ; then Post_Install_CN_Replacement @@ -1877,8 +1878,10 @@ echo -e "\nInitializing...\n" if [[ "$*" = *"--debug"* ]] ; then Debug="On" - rm -f /tmp/cyberpanel_debug.log - echo -e "$(date)" > /tmp/cyberpanel_debug.log + find /var/log -name 'cyberpanel_debug_*' -exec rm {} + + Random_Log_Name=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5) + echo -e "$(date)" > "/var/log/cyberpanel_debug_$(date +"%Y-%m-%d")_${Random_Log_Name}.log" + chmod 600 "/var/log/cyberpanel_debug_$(date +"%Y-%m-%d")_${Random_Log_Name}.log" fi Set_Default_Variables diff --git a/cyberpanel_upgrade.sh b/cyberpanel_upgrade.sh index 5a3a66d7a..809523de8 100644 --- a/cyberpanel_upgrade.sh +++ b/cyberpanel_upgrade.sh @@ -41,8 +41,8 @@ MySQL_Password=$(cat /etc/cyberpanel/mysqlPassword) LSWS_Latest_URL="https://cyberpanel.sh/update.litespeedtech.com/ws/latest.php" -curl --silent --max-time 30 -4 -o /tmp/lsws_latest "$LSWS_Latest_URL" 2>/dev/null -LSWS_Stable_Line=$(grep "LSWS_STABLE" /tmp/lsws_latest) +LSWS_Tmp=$(curl --silent --max-time 30 -4 "$LSWS_Latest_URL") +LSWS_Stable_Line=$(echo "$LSWS_Tmp" | grep "LSWS_STABLE") LSWS_Stable_Version=$(expr "$LSWS_Stable_Line" : '.*LSWS_STABLE=\(.*\) BUILD .*') #grab the LSWS latest stable version. @@ -54,7 +54,7 @@ cd /root/cyberpanel_upgrade_tmp || exit } Debug_Log() { -echo -e "\n${1}=${2}\n" >> /tmp/cyberpanel_debug_upgrade.log +echo -e "\n${1}=${2}\n" >> "/var/log/cyberpanel_debug_upgrade_$(date +"%Y-%m-%d")_${Random_Log_Name}.log" } Debug_Log2() { @@ -676,6 +676,9 @@ if [[ -f /etc/cyberpanel/webadmin_passwd ]]; then chmod 600 /etc/cyberpanel/webadmin_passwd fi +chown lsadm:lsadm /usr/local/lsws/admin/conf/htpasswd +chmod 600 /usr/local/lsws/admin/conf/htpasswd + if [[ -f /etc/pure-ftpd/pure-ftpd.conf ]]; then sed -i 's|NoAnonymous no|NoAnonymous yes|g' /etc/pure-ftpd/pure-ftpd.conf fi @@ -740,8 +743,10 @@ fi if [[ "$*" = *"--debug"* ]] ; then Debug="On" - rm -f /tmp/cyberpanel_debug_upgrade.log - echo -e "$(date)" > /tmp/cyberpanel_debug_upgrade.log + Random_Log_Name=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5) + find /var/log -name 'cyberpanel_debug_upgrade_*' -exec rm {} + + echo -e "$(date)" > "/var/log/cyberpanel_debug_upgrade_$(date +"%Y-%m-%d")_${Random_Log_Name}.log" + chmod 600 "/var/log/cyberpanel_debug_upgrade_$(date +"%Y-%m-%d")_${Random_Log_Name}.log" fi Set_Default_Variables