chore: verify time sync (systemd-timesyncd) during deployment

This commit is contained in:
Claus Lohmar 2026-08-05 10:00:15 +01:00
parent 0f78666bf3
commit f1fbd01c19

View file

@ -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}..."