Skip to main content

tailscale/ensure_on_tailnet.sh

1#!/usr/bin/env bash
3set -o errexit
4set -o nounset
6if (( $# == 0 )); then
7 echo "Usage: $0 TAILNET" >&2
8 exit 1
9fi
11target_tailnet="$1"
12current_tailnet="$(tailscale status --json | jq -r .CurrentTailnet.Name)"
14if [[ "$current_tailnet" != "$target_tailnet" ]]; then
15 print_info "-> tailscale switch '$target_tailnet'"
16 tailscale switch "$target_tailnet"
17 echo ""
18fi