Files
felhom.eu/documentation/audits/release-2b-3-2026-11-15/part2/wait-moved.sh
T

11 lines
641 B
Bash

#!/bin/bash
# wait-moved.sh SSH_TARGET [MINUTES] — wait until the box's agent config holds a ca_file (a read each 30 s).
T=$1; M=${2:-25}
end=$(( $(date +%s) + M*60 ))
while [ "$(date +%s)" -lt "$end" ]; do
cur=$(timeout 15 ssh -o BatchMode=yes -o ConnectTimeout=8 "$T" "python3 -c 'import json;t=json.load(open(\"/etc/felhom-agent/agent.json\")).get(\"proxmox\",{}).get(\"tls\",{});print(\"ca=\"+t.get(\"ca_file\",\"\")+\" fp=\"+(\"set\" if t.get(\"fingerprint\") else \"empty\"))'" 2>/dev/null)
case "$cur" in ca=/*) echo "$(date +%T) $T $cur"; exit 0;; esac
sleep 30
done
echo "$(date +%T) $T TIMEOUT: ${cur:-unreadable}"; exit 1