#!/usr/bin/env bash # Boot-time restore for the reachableceo PMO/Work stack (systemd unit: # reachableceo-agent-stack.service). Self-sufficient at boot: re-preps # /run/screen + screen setuid (tmpfs resets each boot), then respawns any # dead screens via the spawner and injects intro prompts into fresh # spawns only. Idempotent. set -uo pipefail SETUP=/usr/local/sbin/setup-rceo-stack.sh USR=reachableceo PREFIX=RCEO FOUNDER_ACCT=reachableceo SRC_CRUSH=/home/TSGCOO/.local/share/crush mkdir -p /run/screen chmod 755 /run/screen [[ -u /usr/bin/screen ]] || chmod u+s /usr/bin/screen out="$(bash "$SETUP" "$USR" "$FOUNDER_ACCT" "$SRC_CRUSH" "$PREFIX" 2>&1)" || true echo "$out" declare -A SPAWNED for s in "${PREFIX}-PMO" "${PREFIX}-Work"; do [[ "$out" == *"spawned: $s"* ]] && SPAWNED["$s"]=1 done if [[ ${#SPAWNED[@]} -eq 0 ]]; then echo "no sessions needed respawn" exit 0 fi echo "settling 20s before intro injection..." sleep 20 for s in "${!SPAWNED[@]}"; do if [[ "$s" == *-PMO ]]; then intro=INTRO-PMO.md; else intro=INTRO-WORK.md; fi msg="Please read ~/.coordinate/prompts/${intro} and treat it as your introduction from the founder, then follow it."$'\r' runuser -u "$USR" -- env HOME="/home/$USR" TERM=xterm-256color \ screen -S "$s" -X stuff "$msg" \ && echo "injected: $USR/$s ($intro)" \ || echo "INJECT FAILED: $USR/$s" done