Updated rules on 2024-06-18 21:32:56

This commit is contained in:
2024-06-18 21:32:56 +08:00
parent 6e3287d072
commit 6959e4e99c

View File

@@ -27,6 +27,7 @@ download_and_save() {
if wget --no-check-certificate -nv -O "$target_path" "$full_url"; then if wget --no-check-certificate -nv -O "$target_path" "$full_url"; then
log "Downloaded ${rule_name}.txt successfully" log "Downloaded ${rule_name}.txt successfully"
return 0
else else
log "Failed to download ${rule_name}.txt" log "Failed to download ${rule_name}.txt"
return 1 # 返回非零值表示失败 return 1 # 返回非零值表示失败
@@ -50,25 +51,50 @@ if [ ${#failed_downloads[@]} -gt 0 ]; then
else else
log "All rules have been successfully downloaded." 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 git config http.postBuffer 157286400
# 添加更改到 Git # 分批次添加、提交和推送
git add . 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")
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" if [ ${#batch1[@]} -gt 0 ]; then
else git add "${batch1[@]}" || { log "Failed to add batch1 changes to Git"; exit 1; }
log "Failed to commit changes to Git" commit_message="Updated rules (batch1) on $(date '+%Y-%m-%d %H:%M:%S')"
exit 1 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
fi fi
# 推送更改 # 提交并推送第二批次
if git push; then if [ ${#batch2[@]} -gt 0 ]; then
log "Pushed changes to remote repository" git add "${batch2[@]}" || { log "Failed to add batch2 changes to Git"; exit 1; }
else commit_message="Updated rules (batch2) on $(date '+%Y-%m-%d %H:%M:%S')"
log "Failed to push changes to remote repository" if git commit -m "$commit_message"; then
exit 1 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
fi fi
fi fi