diff options
author | doc <doc@filenotfound.org> | 2025-09-14 22:13:41 +0000 |
---|---|---|
committer | doc <doc@filenotfound.org> | 2025-09-14 22:13:41 +0000 |
commit | 13eb2d51c7284472efabc278bf9b7ec0b8575e47 (patch) | |
tree | 9f0ea15fdc908a2afe4d315beb112fe9545db02e /hbsd-lastsync.sh |
Diffstat (limited to 'hbsd-lastsync.sh')
-rwxr-xr-x | hbsd-lastsync.sh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/hbsd-lastsync.sh b/hbsd-lastsync.sh new file mode 100755 index 0000000..b97b17f --- /dev/null +++ b/hbsd-lastsync.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Upstream (HBSD Geo CDN points to a Tier-1 close to you) +UPSTREAM="rsync://rsync.hardenedbsd.org/all/" + +# Your mirror (the VIP that Arch probes) +MIRROR="https://stygian.failzero.net/mirror/hardenedbsd/lastsync" + +# Log file +LOGFILE="/var/log/mirrors/delay.log" +mkdir -p "$(dirname "$LOGFILE")" + +# Fetch timestamps (seconds since epoch) +u=$(curl -fsS "$UPSTREAM" || echo 0) +m=$(curl -fsS "$MIRROR" || echo 0) + +if [[ "$u" =~ ^[0-9]+$ && "$m" =~ ^[0-9]+$ ]]; then + delay_min=$(( (u - m) / 60 )) + echo "$(date -Is) upstream=$u mirror=$m delay=${delay_min}m" >> "$LOGFILE" +else + echo "$(date -Is) error fetching lastsync" >> "$LOGFILE" + +curl -fsS https://geo.mirror.pkgbuild.com/lastsync > "$LIVE/lastsync" \ + || date -u +%s > "$LIVE/lastsync" + +fi |