Southcoast matches NA, per its startup checklist: X32s, ProPresenter to Lighting MIDI, pages 19/20
- An explicit look or rebuild may apply inside the auto-fix hours (never while live) - A page move clears the page left behind when only our keys are on it - A rebuild keeps MIDI links that are down now; first-setup import waits for the keys to land - ProPresenter port drift fixed automatically (kind propresenter_port) - sites/sc/config.json kept with the others Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+56
-13
@@ -211,7 +211,7 @@ def setup(data_dir, cid, name=None, say=print, home=None):
|
||||
return new
|
||||
|
||||
|
||||
def rebuild(data_dir, say=print):
|
||||
def rebuild(data_dir, say=print, pages=None):
|
||||
"""A campus's setup made again from what is found now (today's recipes), keeping its name, PIN,
|
||||
pages and site details. Applied like any Apply (it waits for a recording; history keeps the old one)."""
|
||||
from settings import server
|
||||
@@ -224,7 +224,17 @@ def rebuild(data_dir, say=print):
|
||||
rp = (cfg.get("restart_page") or {}).get("page")
|
||||
if not rp:
|
||||
rp = next(p for p in pick_pages(cfg, 3) if p != cfg["page"])
|
||||
new, seen = autoconf.build(template(data_dir), inv, {"id": s.get("id"), "name": s.get("name")}, s.get("editing_code"), (cfg["page"], rp))
|
||||
pages = tuple(pages or (cfg["page"], rp))
|
||||
if pages != (cfg["page"], rp): # moving (19/20 like every campus): only onto pages that are free or ours
|
||||
comp = cfg.get("companion") or {}
|
||||
for p in pages:
|
||||
ok, why = push_page.safe_target(push_page.fetch_page(comp.get("host", "127.0.0.1"), int(comp.get("port", 8000)), p))
|
||||
if not ok:
|
||||
raise RuntimeError("page %d: %s" % (p, why))
|
||||
new, seen = autoconf.build(template(data_dir), inv, {"id": s.get("id"), "name": s.get("name")}, s.get("editing_code"), pages)
|
||||
new, kept = autoconf.keep_from(new, cfg)
|
||||
if kept:
|
||||
say("Kept (down right now, so not found): %s" % ", ".join(kept))
|
||||
for k in ("contacts", "live_services", "ingest_name", "settings_port"):
|
||||
if k in s:
|
||||
new["site"][k] = s[k]
|
||||
@@ -238,11 +248,29 @@ def rebuild(data_dir, say=print):
|
||||
st = wait_applied(site.applier)
|
||||
save_seen(data_dir, load_seen(data_dir) | set(seen))
|
||||
say("%s: %s" % (st.get("state"), st.get("outcome", "")))
|
||||
if st.get("state") == "done":
|
||||
for p in sorted({cfg["page"], rp} - set(pages)):
|
||||
say("Old page %d: %s" % (p, clear_old_page(cfg, p)))
|
||||
say("Keys: %s" % ", ".join(t["label"] for t in new["tiles"] if not t.get("kind")))
|
||||
say("Restart page %s: %s" % (rp, ", ".join(k["label"] for k in new.get("restart_page", {}).get("keys", [])) or "no keys yet"))
|
||||
say("Restart page %s: %s" % (new.get("restart_page", {}).get("page"), ", ".join(k["label"] for k in new.get("restart_page", {}).get("keys", [])) or "no keys yet"))
|
||||
return new
|
||||
|
||||
|
||||
def clear_old_page(cfg, page):
|
||||
"""A page left behind by a move is emptied, but only when it holds nothing a person made."""
|
||||
comp = cfg.get("companion") or {}
|
||||
host, port = comp.get("host", "127.0.0.1"), int(comp.get("port", 8000))
|
||||
ok, why = push_page.safe_target(push_page.fetch_page(host, port, page))
|
||||
if not ok:
|
||||
return "left as it is (%s)" % why
|
||||
ws = push_page.WebSocket(host, port, "/trpc")
|
||||
try:
|
||||
push_page.Trpc(ws).mutation("pages.clearPage", {"pageNumber": page})
|
||||
finally:
|
||||
ws.close()
|
||||
return "cleared"
|
||||
|
||||
|
||||
def upgrade_companion(base, say=print):
|
||||
"""Companion 5.0.7 from `base` (North Attleboro's settings page), as Woonsocket was upgraded on 2026-10-20:
|
||||
the running Companion is quit, the newest settings folder is copied for 5.0 (and marked newest, or the
|
||||
@@ -305,13 +333,14 @@ def record(data_dir, result):
|
||||
|
||||
# --- every ten minutes: what is new ------------------------------------------------------
|
||||
|
||||
def blocked(cfg, applier, now=None):
|
||||
"""Why auto-setup may not apply right now, or None: never during a service or a recording."""
|
||||
def blocked(cfg, applier, now=None, asked=False):
|
||||
"""Why auto-setup may not apply right now, or None: never during a recording; by itself, never in the
|
||||
auto-fix hours either (a person asking - Look now, setting up on site - may)."""
|
||||
now = now or time.time()
|
||||
live, why = applier.live()
|
||||
if live:
|
||||
return "live now (%s)" % why
|
||||
if sp.in_windows((cfg.get("auto_fix") or {}).get("windows") or [], now):
|
||||
if not asked and sp.in_windows((cfg.get("auto_fix") or {}).get("windows") or [], now):
|
||||
return "inside the auto-fix hours (a service day): waits until they end"
|
||||
if applier.busy():
|
||||
return "an Apply is running"
|
||||
@@ -327,7 +356,7 @@ def look_and_add(site, say=lambda s: None, force=False):
|
||||
result = {"at": int(time.time()), "added": [], "waiting": [], "inventory": summary(inv)}
|
||||
if added:
|
||||
auto = (cfg.get("discover") or {}).get("auto")
|
||||
why = blocked(cfg, site.applier)
|
||||
why = blocked(cfg, site.applier, asked=force)
|
||||
if not (auto or force):
|
||||
result["waiting"] = added
|
||||
result["why"] = "adding by itself is off (Settings > Site)"
|
||||
@@ -449,10 +478,14 @@ if ! /usr/bin/nc -z -G 2 127.0.0.1 22 >/dev/null 2>&1; then
|
||||
echo
|
||||
echo "One more thing: turn on Remote Login (System Settings > General > Sharing), so North Attleboro can help remotely."
|
||||
fi
|
||||
# This Mac's wired address (the default route's port, not en0: at Southcoast en0 is a Dante-style link).
|
||||
IF=$(/sbin/route -n get default 2>/dev/null | awk '/interface:/{print $2}')
|
||||
ME=$(/usr/sbin/ipconfig getifaddr "$IF" 2>/dev/null || hostname)
|
||||
echo
|
||||
echo "Next, on each other computer here (ProPresenter, Tracks, Lighting...):"
|
||||
echo " Mac: open Terminal and paste curl -fsSL http://$(ipconfig getifaddr en0 2>/dev/null || hostname):8020/join | sh"
|
||||
echo " PC: open PowerShell as administrator and paste irm http://$(ipconfig getifaddr en0 2>/dev/null || hostname):8020/join.ps1 | iex"
|
||||
echo " Mac: open Terminal and paste curl -fsSL http://$ME:8020/join | sh"
|
||||
echo " (or send it to all of them at once in Apple Remote Desktop: Send UNIX Command, as root)"
|
||||
echo " PC: open PowerShell as administrator and paste irm http://$ME:8020/join.ps1 | iex"
|
||||
""" % {"name": name, "base": shq(base), "key": shq(key), "cid": cid, "qname": shq(name)}
|
||||
|
||||
|
||||
@@ -464,8 +497,17 @@ def join_mac(cfg, base):
|
||||
return """#!/bin/sh
|
||||
# Joins this Mac to %(ingest)s's status panel: lets it log in with its key (no password) and says this Mac is here.
|
||||
KEY=%(key)s
|
||||
mkdir -p "$HOME/.ssh" && touch "$HOME/.ssh/authorized_keys" && chmod 700 "$HOME/.ssh" && chmod 600 "$HOME/.ssh/authorized_keys"
|
||||
grep -qF "$KEY" "$HOME/.ssh/authorized_keys" || echo "$KEY" >> "$HOME/.ssh/authorized_keys"
|
||||
# Run as root (Apple Remote Desktop > Send UNIX Command): it is for whoever is logged in on this Mac.
|
||||
U=$(id -un); H="$HOME"
|
||||
if [ "$(id -u)" = 0 ]; then
|
||||
U=$(stat -f%%Su /dev/console)
|
||||
[ "$U" = root ] && { echo "Nobody is logged in on $(scutil --get ComputerName): log in, then send this again."; exit 1; }
|
||||
H=$(dscl . -read "/Users/$U" NFSHomeDirectory | awk '{print $2}')
|
||||
fi
|
||||
mkdir -p "$H/.ssh" && touch "$H/.ssh/authorized_keys" && chmod 700 "$H/.ssh" && chmod 600 "$H/.ssh/authorized_keys"
|
||||
grep -qF "$KEY" "$H/.ssh/authorized_keys" || echo "$KEY" >> "$H/.ssh/authorized_keys"
|
||||
[ "$(id -u)" = 0 ] && chown -R "$U:staff" "$H/.ssh"
|
||||
[ "$(id -u)" = 0 ] && { /usr/sbin/systemsetup -setremotelogin on >/dev/null 2>&1 || /bin/launchctl load -w /System/Library/LaunchDaemons/ssh.plist >/dev/null 2>&1; }
|
||||
if ! /usr/bin/nc -z -G 2 127.0.0.1 22 >/dev/null 2>&1; then
|
||||
echo "Remote Login is off. Turning it on (it asks for this Mac's administrator password):"
|
||||
if ! sudo /usr/sbin/systemsetup -setremotelogin on >/dev/null 2>&1; then
|
||||
@@ -476,7 +518,7 @@ if ! /usr/bin/nc -z -G 2 127.0.0.1 22 >/dev/null 2>&1; then
|
||||
fi
|
||||
esc() { printf '%%s' "$1" | sed 's/[\\\\"]//g'; }
|
||||
IPS=$(/sbin/ifconfig | awk '/inet /{print $2}' | grep -v '^127\\.' | sed 's/.*/"&"/' | paste -sd, -)
|
||||
BODY="{\\"user\\":\\"$(esc "$(id -un)")\\",\\"name\\":\\"$(esc "$(scutil --get ComputerName)")\\",\\"hostname\\":\\"$(esc "$(scutil --get LocalHostName).local")\\",\\"os\\":\\"mac\\",\\"ips\\":[$IPS]}"
|
||||
BODY="{\\"user\\":\\"$(esc "$U")\\",\\"name\\":\\"$(esc "$(scutil --get ComputerName)")\\",\\"hostname\\":\\"$(esc "$(scutil --get LocalHostName).local")\\",\\"os\\":\\"mac\\",\\"ips\\":[$IPS]}"
|
||||
if /usr/bin/curl -fsS -X POST -H 'Content-Type: application/json' -d "$BODY" %(hello)s >/dev/null; then
|
||||
echo "Joined. %(ingest)s sets this Mac up in about a minute: watch its status page."
|
||||
else
|
||||
@@ -521,11 +563,12 @@ def main(argv=None):
|
||||
ap.add_argument("--name")
|
||||
ap.add_argument("--data-dir", default=PARENT)
|
||||
ap.add_argument("--home", help="the settings page this campus was installed from (the campus list lives there)")
|
||||
ap.add_argument("--pages", help="rebuild onto these Status,Restart pages (19,20 on every campus)")
|
||||
a = ap.parse_args(argv)
|
||||
if a.what == "setup":
|
||||
setup(a.data_dir, a.id, a.name, home=a.home)
|
||||
elif a.what == "rebuild":
|
||||
rebuild(a.data_dir)
|
||||
rebuild(a.data_dir, pages=tuple(int(p) for p in a.pages.split(",")) if a.pages else None)
|
||||
elif a.what == "upgrade-companion":
|
||||
upgrade_companion(a.home or (load_campuses_home(a.data_dir) or "http://10.1.1.1:8020"))
|
||||
elif a.what == "look":
|
||||
|
||||
Reference in New Issue
Block a user