From 452c6c8b7a653d21e0a1b9c3c14367a484e8e5a6 Mon Sep 17 00:00:00 2001 From: LamGC Date: Sat, 28 Jan 2023 19:41:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20get=5Fparam=5Fvalue=20?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=90=9C=E5=AF=BB=E5=A4=9A=E4=B8=AA=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf-sshd.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/conf-sshd.sh b/conf-sshd.sh index ba41d10..5eeb9d6 100644 --- a/conf-sshd.sh +++ b/conf-sshd.sh @@ -9,7 +9,7 @@ default_cron="0 0 * * *" # 脚本 Url script_url="{{ script_url }}" -########### 脚本区 ########### +############ 脚本区 ########## script_params=$@ has_param() { @@ -28,15 +28,18 @@ get_param_value() { local find=false for param in $script_params; do if [ "$find" == "true" ]; then - echo $param - return - fi - if [ "$param" == "$1" ]; then if [[ $param == -* ]]; then return fi - find=true + echo $param + return fi + for tParam in $@; do + if [ "$tParam" == "$param" ]; then + find=true + break + fi + done done } @@ -69,6 +72,7 @@ if [ $(has_param "-h" "--help") == "true" ]; then echo "only available when the script is executed as root:" echo " -n, --no-install-sshd Do not install SSH Server." echo " -p, --allow-root-passwd Allow Root to log in with a password." + echo "" exit 0 fi