From 324d4c738a3a7712f6811a67b45301fdc0560de7 Mon Sep 17 00:00:00 2001 From: yulei Date: Sat, 30 Nov 2024 14:55:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openclash-special-rules.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/openclash-special-rules.sh b/openclash-special-rules.sh index ced3082..98d45c2 100644 --- a/openclash-special-rules.sh +++ b/openclash-special-rules.sh @@ -1,7 +1,16 @@ #!/bin/bash OUTPUT_DIR="/root/Personal-project/openclash-special-rule/openclash-rule/auto-special-rule/" +LOG_FILE="/var/log/my_script.log" GIT_REPO_DIR="/root/Personal-project/openclash-special-rule/openclash-rule" +# 初始化日志 +> "$LOG_FILE" + +# 日志记录函数 +log() { + echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOG_FILE" +} + cd "$GIT_REPO_DIR" || { log "Failed to change directory to: $GIT_REPO_DIR"; exit 1; } if git pull; then log "Git pull successful" @@ -9,3 +18,18 @@ else log "Git pull failed" exit 1 fi + +rule=( +'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/YouTube/YouTube.yaml', +'https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/Google/Google.yaml') + + +# 遍历数组并下载规则文件 +for rule_name in "${rule[@]}"; do + wget "$rule_name" 2>&1 | tee -a "$LOG_FILE" + if [ $? -eq 0 ]; then + log "Successfully downloaded: $rule_name" + else + log "Failed to download: $rule_name" + fi +done \ No newline at end of file