Files
felhom.eu/documentation/audits/night-2026-09-24/tools/reinstall_n8n.py
T
2026-09-24 14:21:14 +02:00

28 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""After round 2 (the install lost to a docker restart): install n8n again through the product, with no accident,
so round 10 has its ladder step. Also shows whether the lost install's leftovers block a fresh one."""
import json, sys, time
sys.path.insert(0, ".")
import walk as w
import chaos as c
s = c.load()
w.login()
comp = f"{w.DRILL}/templates/n8n/docker-compose.yml"
w.say("drill n8n image line: " + [l for l in open(comp).read().split("\n") if "image:" in l][0].strip())
w.sync_rescan()
t0 = time.time()
ok = w.deploy("n8n", c.SUB["n8n"])
st = w.stack("n8n")
w.say(f"deploy ok={ok} in {round(time.time()-t0)} s pinned={(st.get('app_config') or {}).get('pinned_images')}")
w.wait_app(c.SUB["n8n"], "/", tries=90, delay=4)
A = c.FX["n8n"].seed(w, c.SUB["n8n"], w.say)
s.setdefault("apps", {}).setdefault("n8n", {})["A"] = A
c.save(s)
head = s.get("heads", {}).get("n8n")
if head:
c.drill(lambda: open(comp, "w").write(head), "n8n back to the head (2 steps offered)")
w.sync_rescan(); time.sleep(3); w.sync_rescan()
st = w.stack("n8n")
w.say(f"steps_left={st.get('ladder_steps_left')} badge={w.badges('n8n')['en'][:1]}")
open("../E/round-02b-reinstall.log", "w").write("\n".join(w.LOG) + "\n")