44 lines
2.2 KiB
Python
44 lines
2.2 KiB
Python
"""h1_tier2.py install|chain|copy|break|unbreak|remove — review round 2, HUNT-2 H1 on scratch 9202 (the product's own
|
|
endpoints; box_walk.py). A bad backup block in an app's .felhom.yml: does the night's second-drive copy then delete the
|
|
app's household-file copies?"""
|
|
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
|
|
APP, SUB = "audiobookshelf", "audiobookshelf"
|
|
MARK = "/mnt/felhom-drives/scratch_hdd/userdata/media/audiobooks/review2-h1-marker.txt"
|
|
COPY = "/mnt/sizing-bench/backups/secondary/audiobookshelf"
|
|
FY = "/opt/docker/stacks/audiobookshelf/.felhom.yml"
|
|
w.LOG = []
|
|
w.login()
|
|
cmd = sys.argv[1]
|
|
if cmd == "install":
|
|
print("deploy:", w.deploy(APP, SUB, {"HDD_PATH": "/mnt/felhom-drives/scratch_hdd"}))
|
|
print(w.guest(f"echo 'review round 2 H1 marker — a household file' > {MARK}; ls -la {MARK}"))
|
|
elif cmd == "chain":
|
|
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)[:160])
|
|
out = ""
|
|
for _ in range(120):
|
|
time.sleep(10)
|
|
out = w.guest(f"docker logs --since {since} felhom-controller 2>&1 | grep -E 'night-chain|Tier 2|tier2|backup block|reconcile' | grep -v DEBUG | cut -c1-260")
|
|
if re.search(r"night-chain\] update-leg: done|night-chain\].*finished|update leg \(manual-chain\)", out):
|
|
break
|
|
print(out)
|
|
elif cmd == "copy":
|
|
print(w.guest(f"find {COPY} -maxdepth 5 | sort | head -40; echo; ls -la {COPY}/userdata/media/audiobooks/ 2>&1 | head"))
|
|
elif cmd == "break":
|
|
print(w.guest(f"""cp -p {FY} /root/review2-h1-felhom.yml.orig && python3 - <<'PY'
|
|
p='{FY}'; s=open(p).read()
|
|
old=' - path: media/podcasts\\n'
|
|
assert old in s, 'anchor'
|
|
s=s.replace(old, ' - path: media/review2-typo\\n class: optional # REVIEW-2 H1 PROOF: a path no compose bind has\\n'+old, 1)
|
|
open(p,'w').write(s)
|
|
PY
|
|
grep -n -B1 -A1 review2-typo {FY}"""))
|
|
elif cmd == "unbreak":
|
|
print(w.guest(f"cp -p /root/review2-h1-felhom.yml.orig {FY} && rm -f /root/review2-h1-felhom.yml.orig && grep -c review2-typo {FY}; echo restored"))
|
|
elif cmd == "remove":
|
|
print(w.remove(APP))
|
|
print(w.guest(f"rm -f {MARK}; ls {COPY} 2>&1 | head -3"))
|