| 1 | #!/bin/bash |
| 2 | # Starts ext-mantikafasi headless. Softnet leaves the guest only Snow Globe's tailnet address, which carries its WireGuard tunnel. |
| 3 | # `revive` (the LaunchAgent) starts it only when its runner is gone and nothing stopped it on purpose. |
| 4 | set -euo pipefail |
| 5 | ROOT="/Volumes/Documents/VM/macOS Code Sandbox" |
| 6 | STOPPED="$ROOT/private/ext-mantikafasi/stopped" |
| 7 | LOG="$ROOT/private/ext-mantikafasi/run.log" |
| 8 | if [ "${1:-}" = revive ] && [ -e "$STOPPED" ]; then exit 0; fi |
| 9 | if pgrep -f "tart run ext-mantikafasi" >/dev/null; then exit 0; fi |
| 10 | if [ "${1:-}" = revive ]; then echo "$(date): ext-mantikafasi is down, starting"; fi |
| 11 | rm -f "$STOPPED" |
| 12 | : > "$LOG" |
| 13 | chmod 600 "$LOG" |
| 14 | # Closing an agent session kills its children, so sshd must own the VM. The loopback-only key works while the screen is locked. |
| 15 | ssh -F /dev/null -i "$HOME/.ssh/vm-localhost" -o IdentitiesOnly=yes -o BatchMode=yes -o ConnectTimeout=10 localhost "nohup /usr/bin/env PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin TART_HOME='$ROOT/state' /usr/bin/caffeinate -i '$ROOT/runtime/tart.app/Contents/MacOS/tart' run ext-mantikafasi --no-graphics --no-audio --no-usb-accessories --no-clipboard --suspendable --net-softnet --net-softnet-block=0.0.0.0/0 --net-softnet-allow=100.64.0.1/32 >'$LOG' 2>&1 </dev/null &" |