From 1e2ac884c05c41ea0143eeba8fb90009cd350f7e Mon Sep 17 00:00:00 2001 From: j Date: Sat, 21 Mar 2026 11:26:41 +1300 Subject: [PATCH] Auto-detect Tailscale search domain during install --- infmap/config/service.env | 3 +++ infmap/install.sh | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/infmap/config/service.env b/infmap/config/service.env index d1edce0..baf1e82 100644 --- a/infmap/config/service.env +++ b/infmap/config/service.env @@ -11,3 +11,6 @@ SSH_KEY_PATH=/root/.ssh/id_ed25519 # Collection settings COLLECTION_INTERVAL=300 MAX_CONCURRENT_SSH=5 + +# Tailscale search domain (auto-detected during install if tailscale is available) +# TAILNET_DOMAIN= diff --git a/infmap/install.sh b/infmap/install.sh index ff061c0..03fcad8 100755 --- a/infmap/install.sh +++ b/infmap/install.sh @@ -14,6 +14,20 @@ _check_docker_installed || _die "Docker test failed" docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || _die "Failed to pull image" +# Auto-detect Tailscale search domain if not already configured +if [ -z "${TAILNET_DOMAIN:-}" ] && command -v tailscale &>/dev/null; then + ts_domain=$(tailscale status --json 2>/dev/null | grep -oP '"MagicDNSSuffix":"\K[^"]+' || true) + if [ -n "$ts_domain" ]; then + export TAILNET_DOMAIN="$ts_domain" + echo "Auto-detected Tailscale domain: $ts_domain" + # Persist to service.env so it survives restarts + if ! grep -q '^TAILNET_DOMAIN=' "${SERVICE_ENV}" 2>/dev/null; then + echo "" >> "${SERVICE_ENV}" + echo "TAILNET_DOMAIN=$ts_domain" >> "${SERVICE_ENV}" + fi + fi +fi + # Create data volume docker volume create "${DATA_VOLUME}" 2>/dev/null || true