Nimbin[12]?Web & Tools / Git-Server / cron/gitsync

Git-Server git · main

gitsync + this read-only git browser

git php bash apache self-hosted · first commit 2026-10-05 · last commit 2026-10-06 (3 days ago) · synced 3 days ago

PHP 77.1% CSS 11.4% Markdown 8.6% Makefile 2.9%
git clone https://git.christianimmanuel.de/web-tools/Git-Server.gitwget https://git.christianimmanuel.de/web-tools/Git-Server/archive/Git-Server.tar.gz
cron/gitsync 896 B · 22 lines raw
#!/bin/sh
# /etc/cron.daily/gitsync - publish repos once a day, as the normal user.
# Runs as root via cron.daily, drops to USER (config, ssh key and repos live in that home).
# If the server is not reachable it retries a few times, then gives up until tomorrow.
USER=n76310
HOST=162.19.227.194
RETRIES=6        # attempts
WAIT=600         # seconds between attempts (10 min)

# root-only files of backup.conf projects ([root:*], [system:*]) -> /var/cache/gitsync/USER.tar
/usr/bin/gitsync --collect-root "$USER" -q || echo "gitsync: collecting root-only files failed" >&2

i=0
while [ "$i" -lt "$RETRIES" ]; do
    if ping -c1 -W5 "$HOST" >/dev/null 2>&1 && su - "$USER" -c '/usr/bin/gitsync -q'; then
        exit 0
    fi
    i=$((i + 1))
    [ "$i" -lt "$RETRIES" ] && sleep "$WAIT"
done
echo "gitsync: server $HOST not reachable after $RETRIES attempts, giving up until tomorrow" >&2
exit 0