From e1af1b75dbbf0af1cbf5468ed2ef3a87bce44828 Mon Sep 17 00:00:00 2001 From: yulei Date: Tue, 18 Jun 2024 21:42:16 +0800 Subject: [PATCH] Updated rules on 2024-06-18 21:42:16 --- openclash-rule.sh | 58 ++++++++++++----------------------------------- 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/openclash-rule.sh b/openclash-rule.sh index 21c220e..efe3b72 100755 --- a/openclash-rule.sh +++ b/openclash-rule.sh @@ -27,7 +27,6 @@ download_and_save() { if wget --no-check-certificate -nv -O "$target_path" "$full_url"; then log "Downloaded ${rule_name}.txt successfully" - return 0 else log "Failed to download ${rule_name}.txt" return 1 # 返回非零值表示失败 @@ -51,50 +50,23 @@ if [ ${#failed_downloads[@]} -gt 0 ]; then else log "All rules have been successfully downloaded." - # 进入 Git 仓库目录 - cd "$GIT_REPO_DIR" || { log "Failed to change directory to $GIT_REPO_DIR"; exit 1; } - - # 配置 http.postBuffer - git config http.postBuffer 157286400 - - # 分批次添加、提交和推送 - batch1=("auto-update-rule/apple.txt" "auto-update-rule/applications.txt" "auto-update-rule/cncidr.txt" "auto-update-rule/direct.txt" "auto-update-rule/gfw.txt" "auto-update-rule/google.txt") - batch2=("auto-update-rule/icloud.txt" "auto-update-rule/lancidr.txt" "auto-update-rule/private.txt" "auto-update-rule/proxy.txt" "auto-update-rule/reject.txt" "auto-update-rule/telegramcidr.txt" "auto-update-rule/tld-not-cn.txt") - - # 提交并推送第一批次 - if [ ${#batch1[@]} -gt 0 ]; then - git add "${batch1[@]}" || { log "Failed to add batch1 changes to Git"; exit 1; } - commit_message="Updated rules (batch1) on $(date '+%Y-%m-%d %H:%M:%S')" - if git commit -m "$commit_message"; then - log "Committed batch1 changes to Git with message: $commit_message" - if git push; then - log "Pushed batch1 changes to remote repository" - else - log "Failed to push batch1 changes to remote repository" - exit 1 - fi - else - log "Failed to commit batch1 changes to Git" - exit 1 - fi + # 添加更改到 Git + git add . + # 提交更改 + commit_message="Updated rules on $(date '+%Y-%m-%d %H:%M:%S')" + if git commit -m "$commit_message"; then + log "Committed changes to Git with message: $commit_message" + else + log "Failed to commit changes to Git" + exit 1 fi - # 提交并推送第二批次 - if [ ${#batch2[@]} -gt 0 ]; then - git add "${batch2[@]}" || { log "Failed to add batch2 changes to Git"; exit 1; } - commit_message="Updated rules (batch2) on $(date '+%Y-%m-%d %H:%M:%S')" - if git commit -m "$commit_message"; then - log "Committed batch2 changes to Git with message: $commit_message" - if git push; then - log "Pushed batch2 changes to remote repository" - else - log "Failed to push batch2 changes to remote repository" - exit 1 - fi - else - log "Failed to commit batch2 changes to Git" - exit 1 - fi + # 推送更改 + if git push; then + log "Pushed changes to remote repository" + else + log "Failed to push changes to remote repository" + exit 1 fi fi