summaryrefslogtreecommitdiff
path: root/mirror-delay-check.sh
diff options
context:
space:
mode:
authordoc <doc@filenotfound.org>2025-10-01 20:35:47 +0000
committerdoc <doc@filenotfound.org>2025-10-01 20:35:47 +0000
commit772152a5810aa8c4e03cf167381aadc4ec00499f (patch)
treeba9418142f88622da878d9a3483c5da2da3e5c83 /mirror-delay-check.sh
parent13eb2d51c7284472efabc278bf9b7ec0b8575e47 (diff)
mirror scriptsHEADmaster
Diffstat (limited to 'mirror-delay-check.sh')
-rw-r--r--mirror-delay-check.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/mirror-delay-check.sh b/mirror-delay-check.sh
new file mode 100644
index 0000000..7d9b565
--- /dev/null
+++ b/mirror-delay-check.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# Upstream (Arch Geo CDN points to a Tier-1 close to you)
+UPSTREAM="https://geo.mirror.pkgbuild.com/lastsync"
+
+# Your mirror (the VIP that Arch probes)
+MIRROR="https://stygian.failzero.net/mirror/archlinux/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"
+fi