修复 get_param_value 无法搜寻多个参数的问题.

This commit is contained in:
LamGC 2023-01-28 19:41:25 +08:00
parent 4eb3738352
commit 452c6c8b7a
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D

View File

@ -9,7 +9,7 @@ default_cron="0 0 * * *"
# 脚本 Url # 脚本 Url
script_url="{{ script_url }}" script_url="{{ script_url }}"
########### 脚本区 ########### ############ 脚本区 ##########
script_params=$@ script_params=$@
has_param() { has_param() {
@ -28,15 +28,18 @@ get_param_value() {
local find=false local find=false
for param in $script_params; do for param in $script_params; do
if [ "$find" == "true" ]; then if [ "$find" == "true" ]; then
echo $param
return
fi
if [ "$param" == "$1" ]; then
if [[ $param == -* ]]; then if [[ $param == -* ]]; then
return return
fi fi
find=true echo $param
return
fi fi
for tParam in $@; do
if [ "$tParam" == "$param" ]; then
find=true
break
fi
done
done done
} }
@ -69,6 +72,7 @@ if [ $(has_param "-h" "--help") == "true" ]; then
echo "only available when the script is executed as root:" echo "only available when the script is executed as root:"
echo " -n, --no-install-sshd Do not install SSH Server." echo " -n, --no-install-sshd Do not install SSH Server."
echo " -p, --allow-root-passwd <yes | no> Allow Root to log in with a password." echo " -p, --allow-root-passwd <yes | no> Allow Root to log in with a password."
echo ""
exit 0 exit 0
fi fi