Files

29 lines
1.0 KiB
Python

#!/usr/bin/env python3
"""Install the isolated spectator service; public Funnel setup is a separate step."""
from pathlib import Path
import shutil
import subprocess
repo = Path(__file__).resolve().parents[2]
python = shutil.which('python3')
assert python
units = Path.home() / '.config/systemd/user'
units.mkdir(parents=True, exist_ok=True)
(units / 'azerothai-spectator.service').write_text(f'''[Unit]
Description=AzerothAI read-only spectator monitor
After=network-online.target azerothai-runtime.service
[Service]
WorkingDirectory={repo}
ExecStart={python} {repo}/scripts/spectator-server.py
Restart=always
RestartSec=5
NoNewPrivileges=true
UMask=0077
[Install]
WantedBy=default.target
''')
subprocess.run(['systemctl', '--user', 'daemon-reload'], check=True)
subprocess.run(['systemctl', '--user', 'enable', '--now', 'azerothai-spectator.service'], check=True)
print('Spectator ready on loopback port 8790. Public sharing:')
print('sudo tailscale funnel --bg --https=8443 http://127.0.0.1:8790')
print('Keep the existing private dashboard on port 443.')