From a14c2500448022d22465bd9a18df0a10fb5f7339 Mon Sep 17 00:00:00 2001 From: Trey Bastian Date: Tue, 28 Oct 2025 10:01:00 +0000 Subject: typo --- post-receive | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 post-receive (limited to 'post-receive') diff --git a/post-receive b/post-receive new file mode 100644 index 0000000..ce604a0 --- /dev/null +++ b/post-receive @@ -0,0 +1,28 @@ +#!/bin/bash + +# this post-recieve hook runs globally on my local git machine +# it checks for the precense of a knot.conf file +# if the file exists it reads it to get the remote repo and mirror pushes + + +REPO_PATH=$(pwd) +KNOT_FILE="$REPO_PATH/knot.conf" +LOGFILE="/var/log/knot-sync.log" #log our syncing isssues + +if [ ! -f "$KNOT_FILE" ]; then + echo "[$(date)] $REPO_PATH: knot.conf not found, skipping", >> "$LOGFILE" + exit 0 +fi +REPO_URL=$(cat "$KNOT_FILE" | tr -d '\n' | xargs) +if [ -z "$REPO_URL" ]; then + echo "[$(date)] $REPO_PATH: misconfigured knot.conf, skipping", >> "$LOGFILE" + exit 0 +fi + +sync_repo() { + git push --mirror "$REPO_URL" >> "$LOGFILE" 2>&1 +} + +# make sure the sync occurs in the background +nohup bash -c "sync_repo" > /dev/null 2>&1 & +# vim: filetype=sh -- cgit v1.2.3