diff --git a/docker.tar.gz b/docker.tar.gz new file mode 100644 index 0000000..3be7b2f Binary files /dev/null and b/docker.tar.gz differ diff --git a/docker/cron-jobs b/docker/cron-jobs index ec48208..cc20a27 100644 --- a/docker/cron-jobs +++ b/docker/cron-jobs @@ -1,8 +1,11 @@ # python +20 */4 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainOPNsense.py +25 */4 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainDocker.py +# 20 19 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainOPNsense.py # 25 19 * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainDocker.py #*/3 * * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainDocker.py #*/3 * * * * /etc/debmirror/venv/bin/python3 /etc/debmirror/mainOPNsense.py # git push -# 30 19 * * * /bin/sh /etc/debmirror/gitPush.sh +30 */4 * * * /bin/sh /etc/debmirror/gitPush.sh #*/1 * * * * /bin/sh /etc/debmirror/gitPush.sh \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 0c40460..9c51747 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -3,14 +3,14 @@ services: debmirup: container_name: Debian_Mirrors_Updater - build: ./ - image: debmirrorupd:V2.0.1 + # build: ./ + image: yuruc3/debianrepolist:v0.3 environment: - DEBMIRRORURL=https://www.debian.org/mirror/list - GITURLPROTO=https - GITURL=tea.shupogaki.org - - GITREPOPATH=YuruC3/Debain-repos.git - - GITEA_TOKEN= + - GITREPOPATH=YuruC3/Repo-IP-lists.git + - GITEA_TOKEN=0938a2033324b987bbcb2976b56d147a9a00d8a2 - EXTRAREPOS=True - SECURITYREPOS=True restart: unless-stopped diff --git a/docker/gitPush.sh b/docker/gitPush.sh index f79280c..96b1ca5 100644 --- a/docker/gitPush.sh +++ b/docker/gitPush.sh @@ -5,39 +5,74 @@ WORKPTH="/etc/debmirror/" REPO_DIR="$WORKPTH/Repo-IP-lists" REPO_URL="${GITURLPROTO}://${GITURL}/${GITREPOPATH}" - -# Clone repo only if it doesn't already exist +# Clone repo if not exists 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 +# Stage the files git add MirrorListV4 MirrorListV6 OPNS_MirrorListV4 OPNS_MirrorListV6 -# If anything to commit locally, commit it now +# Only proceed if there are staged changes 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 + echo "[$(date)] Committing and pushing changes..." + git commit -m "Auto-update mirror list on $(date -Iseconds)" + git pull --rebase --autostash git push --quiet - echo "[$(date)] Changes pushed successfully." + echo "[$(date)] Changes pushed." +else + echo "[$(date)] No changes to commit or push." fi + +# #!/bin/sh +# set -e + +# WORKPTH="/etc/debmirror/" +# REPO_DIRd="$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 +