aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlex Pooley (@zuedev) <zuedev@gmail.com>2026-05-07 23:31:03 +0100
committerAlex Pooley (@zuedev) <zuedev@gmail.com>2026-05-07 23:31:03 +0100
commit3fb6d16f40a6b1c4bc4ec4c394d369780bd9489c (patch)
tree487ef6c1d4ff47ea115c829327f526cd43ccc178 /scripts
parentbf1f98d35de053195c91cc5305b324f1b80c3c85 (diff)
downloadgit.zue.dev-3fb6d16f40a6b1c4bc4ec4c394d369780bd9489c.tar
git.zue.dev-3fb6d16f40a6b1c4bc4ec4c394d369780bd9489c.tar.gz
git.zue.dev-3fb6d16f40a6b1c4bc4ec4c394d369780bd9489c.tar.bz2
git.zue.dev-3fb6d16f40a6b1c4bc4ec4c394d369780bd9489c.tar.xz
git.zue.dev-3fb6d16f40a6b1c4bc4ec4c394d369780bd9489c.zip
add locking mechanism to prevent concurrent script execution
Diffstat (limited to 'scripts')
-rw-r--r--scripts/push-repo-mirrors.bash8
1 files changed, 8 insertions, 0 deletions
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")"