#!/usr/bin/env bash # 6-remove-agent-stacks.sh — remove ALL boot-time screen/crush stack relaunchers. # Target state: no screen/crush sessions auto-start on reboot, any account. # - reachableceo-agent-stack.service (boot respawn RCEO-PMO/RCEO-Work + prompt injection) # - tsg-supervisor.timer/.service (5-min self-heal respawning TSG PMO/Work screens) # - tsg-agent-stacks.service (dead unit: ExecStart script already missing) # - launcher scripts moved to backup so nothing re-triggers them by accident # Everything is backed up to removed-agent-stacks/ in this repo; rollback = # restore files + systemctl enable. Also quits the leftover ROOT screen # 'ukrrs-gateway-final' (perf-pass leftover). Does NOT touch screen 'boot' # (may host the live crush session; it dies at the multiqueue bounce anyway). # Self-elevating. Run from the guest: ~/projects/ultix/6-remove-agent-stacks.sh set -euo pipefail [ "$EUID" -eq 0 ] || exec sudo bash "$0" OUT=/home/reachableceo/projects/ultix/6-remove-agent-stacks.out exec > >(tee "$OUT") 2>&1 echo "== remove agent stacks $(date -Is) ==" BK=/home/reachableceo/projects/ultix/removed-agent-stacks mkdir -p "$BK" systemctl disable --now tsg-supervisor.timer 2>&1 || true systemctl disable --now tsg-supervisor.service tsg-agent-stacks.service \ reachableceo-agent-stack.service 2>&1 || true for u in tsg-supervisor.timer tsg-supervisor.service tsg-agent-stacks.service \ reachableceo-agent-stack.service; do if [ -e "/etc/systemd/system/$u" ]; then cp -a "/etc/systemd/system/$u" "$BK/" rm -f "/etc/systemd/system/$u" echo "removed unit: $u" fi find /etc/systemd/system -maxdepth 2 -lname "*/$u" -print -delete 2>/dev/null || true done systemctl daemon-reload systemctl reset-failed 2>/dev/null || true for f in /usr/local/sbin/launch-rceo-stack.sh \ /usr/local/sbin/setup-rceo-stack.sh \ /home/reachableceo/launch-all-tsg-stacks.sh; do if [ -e "$f" ]; then mv "$f" "$BK/" && echo "moved launcher: $f"; fi done screen -S ukrrs-gateway-final -X quit 2>/dev/null \ && echo "quit leftover root screen: ukrrs-gateway-final" \ || echo "root screen ukrrs-gateway-final: not present" echo "-- cron cross-check (expect clean) --" crontab -l 2>/dev/null | grep -Ei 'supervisor|stack|screen|pmo' || echo "root crontab: clean" grep -rEl 'supervisor\.sh|launch-rceo|launch-all-tsg' /etc/cron* 2>/dev/null || echo "cron dirs: clean" echo "-- verify: units gone, timer list, remaining screens --" ls /etc/systemd/system/ | grep -Ei 'stack|supervisor' || echo "no stack/supervisor units remain" screen -ls 2>/dev/null || true echo "== done $(date -Is) — rollback: restore $BK + re-enable units =="