Version 2.1.0

This commit is contained in:
YuruC3 2025-05-24 10:22:28 +02:00
parent f572e9f10e
commit daeff4a3c1
2 changed files with 25 additions and 16 deletions

View File

@ -12,7 +12,7 @@ RUN apk update && \
RUN mkdir /etc/debmirror RUN mkdir /etc/debmirror
WORKDIR /etc/debmirror/ WORKDIR /etc/debmirror/
RUN git clone https://tea.shupogaki.org/YuruC3/Repo-IP-lists && \ RUN git clone https://tea.shupogaki.org/YuruC3/Repo-IP-lists.git && \
ln -s /etc/debmirror/Repo-IP-lists/MirrorListV4 /etc/debmirror/MirrorListV4 && \ ln -s /etc/debmirror/Repo-IP-lists/MirrorListV4 /etc/debmirror/MirrorListV4 && \
ln -s /etc/debmirror/Repo-IP-lists/MirrorListV6 /etc/debmirror/MirrorListV6 && \ ln -s /etc/debmirror/Repo-IP-lists/MirrorListV6 /etc/debmirror/MirrorListV6 && \
ln -s /etc/debmirror/Repo-IP-lists/OPNS_MirrorListV4 /etc/debmirror/OPNS_MirrorListV4 && \ ln -s /etc/debmirror/Repo-IP-lists/OPNS_MirrorListV4 /etc/debmirror/OPNS_MirrorListV4 && \

View File

@ -5,39 +5,48 @@ WORKPTH="/etc/debmirror/"
REPO_DIR="$WORKPTH/Repo-IP-lists" REPO_DIR="$WORKPTH/Repo-IP-lists"
REPO_URL="${GITURLPROTO}://${GITURL}/${GITREPOPATH}" REPO_URL="${GITURLPROTO}://${GITURL}/${GITREPOPATH}"
# Clone repo only if it doesn't already exist # Clone repo only if it doesn't already exist
if [ ! -d "$REPO_DIR/.git" ]; then if [ ! -d "$REPO_DIR/.git" ]; then
echo "[$(date)] Cloning repository..." echo "[$(date)] Cloning repository..."
git clone "$REPO_URL" "$REPO_DIR" git clone "$REPO_URL" "$REPO_DIR"
fi fi
cd "$REPO_DIR" cd "$REPO_DIR"
# Make sure remote includes token for pushing
git remote set-url origin "https://${GITEA_TOKEN}@${GITURL}/${GITREPOPATH}" git remote set-url origin "https://${GITEA_TOKEN}@${GITURL}/${GITREPOPATH}"
# Check for unpushed commits
if [ "$(git rev-list --count origin/main..HEAD)" -gt 0 ]; then
echo "Found commits to push"
git push
echo "Pushed successfully"
else
echo "No new commits to push"
fi
# Set identity
git config user.name "UpdateBot" git config user.name "UpdateBot"
git config user.email "UpdateBot@localhost.local" git config user.email "UpdateBot@localhost.local"
# stage files # Stage and commit any local changes before pulling
git add MirrorListV4 MirrorListV6 OPNS_MirrorListV4 OPNS_MirrorListV6 git add MirrorListV4 MirrorListV6 OPNS_MirrorListV4 OPNS_MirrorListV6
if ! git diff --cached --quiet; then
# If anything to commit locally, commit it now
if ! git diff --quiet --cached; then
echo "[$(date)] Committing local changes before pulling" echo "[$(date)] Committing local changes before pulling"
git commit -m "Auto-commit before pull on $(date -Iseconds)" git commit -m "Auto-commit before pull on $(date -Iseconds)"
fi fi
# Now pull the latest # Pull latest updates
git pull --rebase --autostash git pull --rebase --autostash
# Commit and push only if there's anything new staged # Stage files again in case they changed due to updated script
if git diff --quiet; then git add MirrorListV4 MirrorListV6 OPNS_MirrorListV4 OPNS_MirrorListV6
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
# Commit and push only if there's something to commit
if ! git diff --cached --quiet; then
git commit -m "Auto-update mirror list on $(date -Iseconds)"
git push
echo "[$(date)] Changes pushed successfully."
else
echo "[$(date)] No new changes to commit."
fi