#!/bin/bash # Pride Mac fix (2026-11-25): point the Mac at the NEW VPS, restart NetBird, and open Claude on the Threadripper # automatically at every login as soon as there is internet. VPS=13.140.243.215; OLD=51.81.85.20; TRH=ssh.loveiznothin.com; TRP=2224 say(){ printf '\n\033[1;35m%s\033[0m\n' "$*"; } mkdir -p ~/.ssh ~/bin ~/Library/LaunchAgents; chmod 700 ~/.ssh say "1/5 SSH settings" cp ~/.ssh/config ~/.ssh/config.bak-1125 2>/dev/null ssh-keygen -R "[$OLD]:2224" >/dev/null 2>&1; ssh-keygen -R "[$OLD]:2225" >/dev/null 2>&1; ssh-keygen -R "$OLD" >/dev/null 2>&1 sed -i '' "s/$OLD/$VPS/g" ~/.ssh/config 2>/dev/null grep -q '^Host claude-tr$' ~/.ssh/config 2>/dev/null || cat >> ~/.ssh/config < new VPS (asks for your Mac password)" sudo sh -c " for f in /Library/LaunchDaemons/com.bellz.publicssh.plist /usr/local/bin/sshd-watchdog; do [ -f \$f ] && cp \$f \$f.bak-1125 && sed -i '' 's/$OLD/$VPS/g' \$f done dscacheutil -flushcache; killall -HUP mDNSResponder 2>/dev/null launchctl bootout system /Library/LaunchDaemons/com.bellz.publicssh.plist 2>/dev/null launchctl bootstrap system /Library/LaunchDaemons/com.bellz.publicssh.plist 2>/dev/null " sudo -u "$USER" ssh-keygen -R "$VPS" >/dev/null 2>&1 ssh -o StrictHostKeyChecking=accept-new -o BatchMode=yes -o ConnectTimeout=8 -i ~/.ssh/mac_tunnel ubuntu@$VPS true 2>/dev/null say "3/5 NetBird restart" NB=$(command -v netbird || echo /usr/local/bin/netbird) sudo "$NB" down >/dev/null 2>&1; sleep 2; sudo "$NB" up 2>&1 | tail -1 say "4/5 Claude opens by itself at login" cat > ~/bin/claude-tr.command <<'CMD' #!/bin/bash # waits for internet, then opens Claude on the Threadripper; reconnects by itself when the link drops clear; echo "Waiting for internet..." while true; do until nc -z -G 4 ssh.loveiznothin.com 2224 2>/dev/null; do sleep 3; done ssh -t claude-tr echo; echo "Connection closed - reconnecting in 5 s (close this window to stop)"; sleep 5 done CMD chmod +x ~/bin/claude-tr.command cat > ~/Library/LaunchAgents/com.pride.claude-tr.plist < Labelcom.pride.claude-tr ProgramArguments/usr/bin/open-aTerminal$HOME/bin/claude-tr.command RunAtLoad PL launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/com.pride.claude-tr.plist 2>/dev/null launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.pride.claude-tr.plist 2>/dev/null say "5/5 Report to Claude" { echo "== mac-fix report $(date)"; sw_vers -productVersion; ls ~/.ssh/*.pub; echo "-- mac_tunnel.pub"; cat ~/.ssh/mac_tunnel.pub 2>/dev/null echo "-- netbird"; "$NB" status 2>&1 | head -12; echo "-- tunnel"; sudo launchctl print system/com.bellz.publicssh 2>/dev/null | grep -E "state|last exit" echo "-- agents"; ls ~/Library/LaunchAgents | grep -iE "claude|tr|pride|bellz"; grep -n "ssh\|claude\|tmux" ~/.zshrc ~/.zprofile 2>/dev/null | head -20; } > /tmp/mac-fix-report.txt 2>&1 ssh -o BatchMode=yes -o ConnectTimeout=10 claude-tr 'NO_TMUX=1 cat > /tmp/mac-fix-report.txt' < /tmp/mac-fix-report.txt && echo "Report sent." || echo "Could not send the report yet (that's ok)." say "Done. A Terminal window with Claude should open now."