From f1fbd01c192b098419ec9d64a302ede4ea1f6b34 Mon Sep 17 00:00:00 2001 From: cclohmar Date: Wed, 5 Aug 2026 10:00:15 +0100 Subject: [PATCH] chore: verify time sync (systemd-timesyncd) during deployment --- setup.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/setup.sh b/setup.sh index 342c300..a366dcf 100755 --- a/setup.sh +++ b/setup.sh @@ -56,6 +56,24 @@ if ! command -v curl &>/dev/null; then sudo apt-get install -y -qq curl fi +# ── 1b. Verify time synchronization (critical for NVR timestamps) ── +log "Checking time sync..." +if systemctl is-active --quiet systemd-timesyncd 2>/dev/null; then + log "systemd-timesyncd is active." +elif ! timedatectl status 2>/dev/null | grep -q "System clock synchronized: yes"; then + warn "Time sync is NOT active. Enabling systemd-timesyncd..." + sudo systemctl enable --now systemd-timesyncd 2>/dev/null || true + sudo timedatectl set-ntp true 2>/dev/null || true + log "Time sync enabled." +else + log "Time sync is active." +fi + +# Verify timezone is sensible. +TZ=$(timedatectl show --property=Timezone --value 2>/dev/null || echo "unknown") +log "Timezone: ${TZ}" +log "Local time: $(date)" + # ── 2. Install Go (user-local, no sudo needed after download) ── log "Step 2/6: Setting up Go ${GO_VERSION}..."