From 3fb6d16f40a6b1c4bc4ec4c394d369780bd9489c Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Thu, 7 May 2026 23:31:03 +0100 Subject: add locking mechanism to prevent concurrent script execution --- scripts/push-repo-mirrors.bash | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'scripts/push-repo-mirrors.bash') diff --git a/scripts/push-repo-mirrors.bash b/scripts/push-repo-mirrors.bash index 43db9a7..2cdc6a9 100644 --- a/scripts/push-repo-mirrors.bash +++ b/scripts/push-repo-mirrors.bash @@ -2,6 +2,14 @@ # This script pushes the repository mirrors to their respective remote URLs if they are defined in the .gitinfo file. +LOCK_FILE=/var/lock/push-repo-mirrors.lock + +exec 9>"$LOCK_FILE" +if ! flock --nonblock 9; then + echo "Another instance is already running. Exiting." + exit 1 +fi + for repository in /repositories/*; do echo "Processing repository: $(basename "$repository")" -- cgit v1.2.3