Skip to content

Commit d9727d8

Browse files
committed
update some permissions
1 parent 9d6220f commit d9727d8

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

cyberpanel.sh

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ Git_Content_URL=""
9595
Git_Clone_URL=""
9696

9797
LSWS_Latest_URL="https://cyberpanel.sh/update.litespeedtech.com/ws/latest.php"
98-
curl --silent --max-time 30 -4 -o /tmp/lsws_latest "$LSWS_Latest_URL" 2>/dev/null
99-
LSWS_Stable_Line=$(grep "LSWS_STABLE" /tmp/lsws_latest)
98+
LSWS_Tmp=$(curl --silent --max-time 30 -4 "$LSWS_Latest_URL")
99+
LSWS_Stable_Line=$(echo "$LSWS_Tmp" | grep "LSWS_STABLE")
100100
LSWS_Stable_Version=$(expr "$LSWS_Stable_Line" : '.*LSWS_STABLE=\(.*\) BUILD .*')
101101
#grab the LSWS latest stable version.
102102

@@ -107,7 +107,7 @@ Debug_Log2 "Starting installation..,1"
107107
}
108108

109109
Debug_Log() {
110-
echo -e "\n${1}=${2}\n" >> /tmp/cyberpanel_debug.log
110+
echo -e "\n${1}=${2}\n" >> "/var/log/cyberpanel_debug_$(date +"%Y-%m-%d")_${Random_Log_Name}.log"
111111
}
112112

113113
Debug_Log2() {
@@ -174,12 +174,12 @@ Retry_Command() {
174174
# shellcheck disable=SC2034
175175
for i in {1..50};
176176
do
177-
if [[ "$i" = "50" ]] ; then
177+
if [[ "$i" = "50" ]] ; then
178178
echo "command $1 failed for 50 times, exit..."
179179
exit 2
180180
else
181181
$1 && break || echo -e "\n$1 has failed for $i times\nWait for 3 seconds and try again...\n"; sleep 3;
182-
fi
182+
fi
183183
done
184184
}
185185

@@ -213,12 +213,12 @@ Server_IP=$(curl --silent --max-time 30 -4 https://cyberpanel.sh/?ip)
213213

214214
echo -e "\nChecking server location...\n"
215215

216-
if [[ "$Server_Country" != "CN" ]] ; then
216+
if [[ "$Server_Country" != "CN" ]] ; then
217217
Server_Country=$(curl --silent --max-time 10 -4 https://cyberpanel.sh/?country)
218218
if [[ ${#Server_Country} != "2" ]] ; then
219219
Server_Country="Unknow"
220220
fi
221-
fi
221+
fi
222222
#to avoid repeated check_ip called by debug_log2 to break force mirror for CN servers.
223223

224224
if [[ "$Debug" = "On" ]] ; then
@@ -829,7 +829,7 @@ if [[ $Server_OS = "CentOS" ]] ; then
829829
yum autoremove -y epel-release
830830
rm -f /etc/yum.repos.d/epel.repo
831831
rm -f /etc/yum.repos.d/epel.repo.rpmsave
832-
832+
833833
yum install -y yum-plugin-copr
834834
Check_Return "yum repo" "no_exit"
835835
yum copr enable -y copart/restic
@@ -1335,7 +1335,7 @@ else
13351335

13361336
Retry_Command "/root/.acme.sh/acme.sh --upgrade --auto-upgrade"
13371337
#install acme and upgrade it beforehand, to prevent gitee fail
1338-
fi
1338+
fi
13391339
#install acme.sh before main installation for issues #705 #707 #708 #709
13401340

13411341
echo -e "Preparing...\n"
@@ -1559,7 +1559,9 @@ Webadmin_Pass=$(
15591559

15601560
Encrypt_string=$(/usr/local/lsws/admin/fcgi-bin/${PHP_Command} /usr/local/lsws/admin/misc/htpasswd.php "${Webadmin_Pass}")
15611561
echo "" >/usr/local/lsws/admin/conf/htpasswd
1562-
echo "admin:$Encrypt_string" >/usr/local/lsws/admin/conf/htpasswd
1562+
echo "admin:$Encrypt_string" > /usr/local/lsws/admin/conf/htpasswd
1563+
chown lsadm:lsadm /usr/local/lsws/admin/conf/htpasswd
1564+
chmod 600 /usr/local/lsws/admin/conf/htpasswd
15631565
echo "${Webadmin_Pass}" >/etc/cyberpanel/webadmin_passwd
15641566
chmod 600 /etc/cyberpanel/webadmin_passwd
15651567
}
@@ -1766,6 +1768,7 @@ rm -rf /etc/profile.d/cyberpanel*
17661768
curl --silent -o /etc/profile.d/cyberpanel.sh https://cyberpanel.sh/?banner 2>/dev/null
17671769
chmod 700 /etc/profile.d/cyberpanel.sh
17681770
echo "$Admin_Pass" > /etc/cyberpanel/adminPass
1771+
chmod 600 /etc/cyberpanel/adminPass
17691772
/usr/local/CyberPanel/bin/python /usr/local/CyberCP/plogical/adminPass.py --password "$Admin_Pass"
17701773
mkdir -p /etc/opendkim
17711774

@@ -1851,8 +1854,6 @@ systemctl start lsws >/dev/null 2>&1
18511854
echo -e "\nFinalizing...\n"
18521855
echo -e "Cleaning up...\n"
18531856
rm -rf /root/cyberpanel
1854-
rm -f /tmp/cyberpanel_debug.log
1855-
rm -f /tmp/lsws_latest
18561857

18571858
if [[ "$Server_Country" = "CN" ]] ; then
18581859
Post_Install_CN_Replacement
@@ -1877,8 +1878,10 @@ echo -e "\nInitializing...\n"
18771878

18781879
if [[ "$*" = *"--debug"* ]] ; then
18791880
Debug="On"
1880-
rm -f /tmp/cyberpanel_debug.log
1881-
echo -e "$(date)" > /tmp/cyberpanel_debug.log
1881+
find /var/log -name 'cyberpanel_debug_*' -exec rm {} +
1882+
Random_Log_Name=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
1883+
echo -e "$(date)" > "/var/log/cyberpanel_debug_$(date +"%Y-%m-%d")_${Random_Log_Name}.log"
1884+
chmod 600 "/var/log/cyberpanel_debug_$(date +"%Y-%m-%d")_${Random_Log_Name}.log"
18821885
fi
18831886

18841887
Set_Default_Variables

cyberpanel_upgrade.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ MySQL_Password=$(cat /etc/cyberpanel/mysqlPassword)
4141

4242

4343
LSWS_Latest_URL="https://cyberpanel.sh/update.litespeedtech.com/ws/latest.php"
44-
curl --silent --max-time 30 -4 -o /tmp/lsws_latest "$LSWS_Latest_URL" 2>/dev/null
45-
LSWS_Stable_Line=$(grep "LSWS_STABLE" /tmp/lsws_latest)
44+
LSWS_Tmp=$(curl --silent --max-time 30 -4 "$LSWS_Latest_URL")
45+
LSWS_Stable_Line=$(echo "$LSWS_Tmp" | grep "LSWS_STABLE")
4646
LSWS_Stable_Version=$(expr "$LSWS_Stable_Line" : '.*LSWS_STABLE=\(.*\) BUILD .*')
4747
#grab the LSWS latest stable version.
4848

@@ -54,7 +54,7 @@ cd /root/cyberpanel_upgrade_tmp || exit
5454
}
5555

5656
Debug_Log() {
57-
echo -e "\n${1}=${2}\n" >> /tmp/cyberpanel_debug_upgrade.log
57+
echo -e "\n${1}=${2}\n" >> "/var/log/cyberpanel_debug_upgrade_$(date +"%Y-%m-%d")_${Random_Log_Name}.log"
5858
}
5959

6060
Debug_Log2() {
@@ -676,6 +676,9 @@ if [[ -f /etc/cyberpanel/webadmin_passwd ]]; then
676676
chmod 600 /etc/cyberpanel/webadmin_passwd
677677
fi
678678

679+
chown lsadm:lsadm /usr/local/lsws/admin/conf/htpasswd
680+
chmod 600 /usr/local/lsws/admin/conf/htpasswd
681+
679682
if [[ -f /etc/pure-ftpd/pure-ftpd.conf ]]; then
680683
sed -i 's|NoAnonymous no|NoAnonymous yes|g' /etc/pure-ftpd/pure-ftpd.conf
681684
fi
@@ -740,8 +743,10 @@ fi
740743

741744
if [[ "$*" = *"--debug"* ]] ; then
742745
Debug="On"
743-
rm -f /tmp/cyberpanel_debug_upgrade.log
744-
echo -e "$(date)" > /tmp/cyberpanel_debug_upgrade.log
746+
Random_Log_Name=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 5)
747+
find /var/log -name 'cyberpanel_debug_upgrade_*' -exec rm {} +
748+
echo -e "$(date)" > "/var/log/cyberpanel_debug_upgrade_$(date +"%Y-%m-%d")_${Random_Log_Name}.log"
749+
chmod 600 "/var/log/cyberpanel_debug_upgrade_$(date +"%Y-%m-%d")_${Random_Log_Name}.log"
745750
fi
746751

747752
Set_Default_Variables

0 commit comments

Comments
 (0)