]> git.zue.dev - git.zue.dev/commitdiff
add minutely cron job script
authorAlex Pooley (@zuedev) <zuedev@gmail.com>
Mon, 23 Mar 2026 10:42:08 +0000 (10:42 +0000)
committerAlex Pooley (@zuedev) <zuedev@gmail.com>
Mon, 23 Mar 2026 10:42:08 +0000 (10:42 +0000)
cron/minutely.sh [new file with mode: 0644]

diff --git a/cron/minutely.sh b/cron/minutely.sh
new file mode 100644 (file)
index 0000000..87633d8
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+GIT_ZUE_DEV="/home/git/git.zue.dev/"
+DOCKER_COMPOSE_DIRECTORY="/root/"
+DOCKER_COMPOSE_FILENAME="docker-compose.yaml"
+
+echo "This is a minutely cron job. Current time: $(date)"
+
+# do we have the repo?
+if [ -z "$GIT_ZUE_DEV" ]; then
+    echo "Repository not found. PANIC!"
+    exit 1
+fi
+
+# enter the repo
+cd "$GIT_ZUE_DEV" || { echo "Failed to change directory to $GIT_ZUE_DEV. PANIC!"; exit 1; }
+
+# can we see the docker-compose.yaml file in the repo?
+git cat-file HEAD:"$DOCKER_COMPOSE_FILENAME" > /dev/null 2>&1 || { echo "$DOCKER_COMPOSE_FILENAME not found in the repository. PANIC!"; exit 1; }
+
+# compare our local copy of the docker-compose.yaml with the one in the repo
+if ! git diff --quiet HEAD:"$DOCKER_COMPOSE_FILENAME" "$DOCKER_COMPOSE_DIRECTORY/$DOCKER_COMPOSE_FILENAME"; then
+    echo "$DOCKER_COMPOSE_FILENAME has changed. Updating local copy..."
+    git show HEAD:"$DOCKER_COMPOSE_FILENAME" > "$DOCKER_COMPOSE_DIRECTORY/$DOCKER_COMPOSE_FILENAME"
+
+    # then rebuild the containers
+    echo "Rebuilding Docker containers..."
+    cd "$DOCKER_COMPOSE_DIRECTORY" || { echo "Failed to change directory to $DOCKER_COMPOSE_DIRECTORY. PANIC!"; exit 1; }
+
+    docker compose down
+    docker compose build
+    docker compose up -d
+else
+    echo "$DOCKER_COMPOSE_FILENAME has not changed. No action needed."
+fi
+
+echo "Minutely cron job completed."
\ No newline at end of file
This page took 0.046907 seconds and 4 git commands to generate.