"""chain.py — press "run tonight's chain now" (POST /api/debug/backup/night-chain, R-705) on the box and quote the update leg's own lines; then read Plex's four observables. D39 = B proof (felhom.eu audits/security-lane-2026-10-23).""" import json, re, sys, time sys.path.insert(0, "/mnt/5_hdd/felhom.eu/git/app-catalog-felhom.eu/scripts") import box_walk as w w.LOG = [] w.login() w.refresh_box_mirror() w.sync_rescan("plex", "plexinc/pms-docker:1.43.5.11029-6bf8af3f0", tries=20, delay=6) print("before:", json.dumps(w.observables("plex"))) print("badge before:", w.badges("plex")) since = w.guest("date -u +%Y-%m-%dT%H:%M:%SZ").strip() code, d = w.ctl("POST", "/api/debug/backup/night-chain") print("night chain ->", code, str(d)[:200]) leg = "" for _ in range(240): time.sleep(10) leg = w.guest("docker logs --since %s felhom-controller 2>&1 | grep -E 'update-leg' | grep -v DEBUG | cut -c1-400" % since) if re.search(r"update leg .*: done=", leg): break print("the leg's own lines:\n" + leg) time.sleep(10) print("after:", json.dumps(w.observables("plex"))) st = w.stack("plex") print("state", st.get("state"), "hold", st.get("hold_reason"), "phase", st.get("update_phase"))