From b65f1b8ceb5183e1e3379dded1ecb04cda53c090 Mon Sep 17 00:00:00 2001 From: LamGC Date: Sat, 28 Jan 2023 21:38:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=84=9A=E6=9C=AC=E7=9A=84?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=8A=9F=E8=83=BD.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf-sshd.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/conf-sshd.sh b/conf-sshd.sh index 4cb2649..1416707 100644 --- a/conf-sshd.sh +++ b/conf-sshd.sh @@ -7,7 +7,7 @@ sshkey_url="https://q-ssh.lamgc.me/ssh.keys" # 默认的 Cron 执行计划, 每天凌晨 0 点执行 default_cron="0 0 * * *" # 脚本 Url -script_url="{{ script_url }}" +script_url="https://q-ssh.lamgc.me" ############ 脚本区 ########## @@ -201,8 +201,16 @@ if [ $(has_param "-c" "--cron") == "true" ]; then fi # 将当前脚本移动到 ~/.conf-sshd/conf-sshd.sh 中. mkdir -p ~/.conf-sshd - cp $0 ~/.conf-sshd/conf-sshd.sh + # 检查当前脚本是否为文件 + if [ ! -f $0 ]; then + echo "Downloading conf-sshd script..." + curl -o ~/.conf-sshd/conf-sshd.sh $script_url + else + echo "Copying conf-sshd script..." + cp $0 ~/.conf-sshd/conf-sshd.sh + fi chmod +x ~/.conf-sshd/conf-sshd.sh + echo "Install conf-sshd script successfully." # 将当前脚本添加到 Crontab 中 echo "$cron /bin/bash ~/.conf-sshd/conf-sshd.sh -o -k $sshkey_url" | crontab - fi