#!/bin/sh set -e WORKPTH="/etc/debmirror/" REPO_DIR="$WORKPTH/Repo-IP-lists" REPO_URL="${GITURLPROTO}://${GITURL}/${GITREPOPATH}" # Clone repo only if it doesn't already exist if [ ! -d "$REPO_DIR/.git" ]; then echo "[$(date)] Cloning repository..." git clone "$REPO_URL" "$REPO_DIR" fi cd "$REPO_DIR" git remote set-url origin "https://${GITEA_TOKEN}@${GITURL}/${GITREPOPATH}" git config user.name "UpdateBot" git config user.email "UpdateBot@localhost.local" # stage files git add MirrorListV4 MirrorListV6 OPNS_MirrorListV4 OPNS_MirrorListV6 # If anything to commit locally, commit it now if ! git diff --quiet --cached; then echo "[$(date)] Committing local changes before pulling" git commit -m "Auto-commit before pull on $(date -Iseconds)" fi # Now pull the latest git pull --rebase --autostash # Commit and push only if there's anything new staged if git diff --quiet; then echo "[$(date)] No changes to commit." else git commit -a -m "Auto-update mirror list on $(date -Iseconds)" --quiet git push --quiet echo "[$(date)] Changes pushed successfully." fi