From d9727d81641ce725d975a3d124ba6d72bd7bc0bc Mon Sep 17 00:00:00 2001 From: qtwrk Date: Mon, 30 Aug 2021 22:44:56 +0200 Subject: [PATCH] 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