38 lines
845 B
Bash
38 lines
845 B
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
WORKPTH="/etc/debmirror/"
|
|
REPO_DIR="$WORKPTH/Debain-repos"
|
|
REPO_URL="https://tea.shupogaki.org/YuruC3/Debain-repos.git"
|
|
|
|
|
|
# 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}@tea.shupogaki.org/YuruC3/Debain-repos.git"
|
|
|
|
git config user.name "UpdateBot"
|
|
git config user.email "UpdateBot@localhost.local"
|
|
|
|
# pull changes
|
|
git pull
|
|
|
|
# stage files
|
|
git add MirrorListV4 MirrorListV6
|
|
|
|
# Commit and push only if there's anything new staged
|
|
if git diff --cached --quiet; then
|
|
echo "[$(date)] No changes to commit."
|
|
else
|
|
git commit -m "Auto-update mirror list on $(date -Iseconds)"
|
|
git push
|
|
echo "[$(date)] Changes pushed successfully."
|
|
fi
|
|
|