#!/usr/bin/env bash
# One-time: Tailscale on this laptop so phone can reach the desk from anywhere.
# Needs your sudo password once. Then: install Tailscale app on phone, login same account.
set -euo pipefail
echo "=== Texano remote access (Tailscale) ==="
if ! command -v tailscale >/dev/null 2>&1; then
  echo "Installing Tailscale (official)…"
  curl -fsSL https://tailscale.com/install.sh | sudo sh
fi
sudo systemctl enable --now tailscaled
echo "Opening login — approve in the browser / phone…"
sudo tailscale up --accept-dns=false
echo
echo "Your Tailscale IPs:"
tailscale ip -4 || true
echo
echo "On phone: install Tailscale → login same account → open:"
echo "  http://$(tailscale ip -4 | head -1):8765/EXEC_DESK_MOCK.html"
echo "Then browser menu → Add to Home screen (PWA)."
echo
echo "Start the desk bridge (LAN + Tailscale):"
echo "  $(dirname "$0")/start_last_click.sh"
