#!/usr/bin/env python3 """R-613 red-proof on 9202 through the product. argv[1] = before|after. before: the drill template as live. after: + UPTIME_KUMA_DB_TYPE=sqlite (the fix). The lie: the controller reads `running` while the app's own /api/entry-page says setup-database.""" import sys, re, json, time, fcntl sys.path.insert(0, ".") import walk as w mode = sys.argv[1] APP, SUB = "uptime-kuma", "uptime" if mode == "after" and False: with open(f"{w.SC}/drill.lock", "w") as lk: fcntl.flock(lk, fcntl.LOCK_EX) w.sh(["git", "-C", w.DRILL, "pull", "-q", "--rebase", "origin", "main"], timeout=120) p = f"{w.DRILL}/templates/uptime-kuma/docker-compose.yml" s = open(p).read().replace(" - TZ=Europe/Budapest\n", " - TZ=Europe/Budapest\n - UPTIME_KUMA_DB_TYPE=sqlite\n", 1) open(p, "w").write(s) w.sh(["git", "-C", w.DRILL, "commit", "-qam", "DRILL R-613: uptime-kuma skips the DB wizard"]) w.sh(["git", "-C", w.DRILL, "push", "-q", "origin", "main"], timeout=120) w.login() w.sync_rescan() if mode.startswith("after"): for i in range(24): if "UPTIME_KUMA_DB_TYPE" in w.guest("cat /opt/docker/stacks/uptime-kuma/docker-compose.yml"): w.say(f"[{mode}] the box's template carries the fix after {i} extra sync round(s)") break time.sleep(5); w.sync_rescan() w.deploy(APP, SUB) w.wait_app(SUB, "/", want=("200", "302")) time.sleep(30) st = w.stack(APP) rc, code, body = w.app_curl(SUB, "/api/entry-page") rc2, code2, _ = w.app_curl(SUB, "/metrics") w.say(f"[{mode}] controller state={st.get('state')}; app /api/entry-page -> {code} {body[:120]}; /metrics -> {code2}") wizard = "setup-database" in body w.say(f"[{mode}] the app is parked on its database wizard: {wizard}; the box says: {st.get('state')}") json.dump({"mode": mode, "state": st.get("state"), "entry_page": body[:200], "metrics_http": code2, "wizard": wizard}, open(f"apps/uptime-kuma/r613-{mode}.json", "w"), indent=2) w.remove(APP) open(f"apps/uptime-kuma/r613-{mode}.log", "w").write("\n".join(w.LOG) + "\n")