move tailscale to own configure step

This commit is contained in:
2026-10-27 05:53:49 -06:00
parent 488b085713
commit 1d2d4dc7f1
4 changed files with 57 additions and 25 deletions
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
TITLE="Tailscale"
DESCRIPTION="Join your Core's Tailscale network"
CORE_CONF="$HOME/.config/coredesktop/core.conf"
TAILSCALE_CONF="$HOME/.config/coredesktop/tailscale.conf"
[ -f "$CORE_CONF" ] && source "$CORE_CONF"
[ -f "$TAILSCALE_CONF" ] && source "$TAILSCALE_CONF"
is_installed() {
command -v tailscale
}
# Tailscale has no status field naming its login server, so tailscale.conf
# records which Core it was set up for
is_configured() {
[ -n "$CORE_DOMAIN" ] && [ "$TAILSCALE_DOMAIN" = "$CORE_DOMAIN" ] \
&& tailscale status --json 2> /dev/null | jq -e '.BackendState == "Running"' > /dev/null
}
run_configure() {
if [ -z "$CORE_DOMAIN" ]; then
echo "This joins your Core's Tailscale network, so set up your Core first: configure core"
return 1
fi
# --reset and --force-reauth move the machine from any other tailnet;
# --operator lets you, and the Tailscale GNOME extension, use it without sudo
if ! systemctl is-active -q tailscaled; then
sudo systemctl enable --now tailscaled || return 1
fi
echo "Open the link below to sign in to your Core's Tailscale network (headscale.$CORE_DOMAIN)."
sudo tailscale up --reset --force-reauth --login-server "https://headscale.$CORE_DOMAIN" \
--accept-routes --operator="$USER" || return 1
mkdir -p "$(dirname "$TAILSCALE_CONF")"
printf 'TAILSCALE_DOMAIN=%q\n' "$CORE_DOMAIN" > "$TAILSCALE_CONF"
echo "This computer is on your Core's Tailscale network."
}