#!/usr/bin/env python3 """Fix home tunnel config + install cloudflared-home systemd unit on CT148.""" import io, subprocess # 1. backup + fix hydros ingress subprocess.run(["cp", "/root/.cloudflared/config.yml", "/root/.cloudflared/config.yml.bak-20260813"]) cfg = io.open("/root/.cloudflared/config.yml", encoding="utf-8").read() cfg = cfg.replace("http://10.30.20.24:5000", "http://10.30.20.11:3000") io.open("/root/.cloudflared/config.yml", "w", encoding="utf-8").write(cfg) print("CONFIG FIXED (hydros -> .11:3000)") # 2. systemd unit unit = """[Unit] Description=Cloudflare Home Tunnel (games/trustgram/hydros) After=network-online.target Wants=network-online.target [Service] ExecStart=/usr/bin/cloudflared tunnel --no-autoupdate --config /root/.cloudflared/config.yml run Restart=always RestartSec=5 [Install] WantedBy=multi-user.target """ io.open("/etc/systemd/system/cloudflared-home.service", "w", encoding="utf-8").write(unit) subprocess.run(["systemctl", "daemon-reload"]) subprocess.run(["systemctl", "enable", "cloudflared-home"]) r = subprocess.run(["systemctl", "restart", "cloudflared-home"], capture_output=True, text=True) print("SERVICE STARTED" if r.returncode == 0 else f"START FAILED: {r.stderr[:300]}")