tailscale: add to PATH; add script to switch tailnets
- ID
f8a0c12- date
2026-05-15 12:50:52+00:00- author
Alex Chan <alexc@tailscale.com>- parent
dd014bb- message
tailscale: add to PATH; add script to switch tailnets- changed files
3 files, 36 additions, 1 deletion
Changed files
config.fish (6688) → config.fish (6730)
diff --git a/config.fish b/config.fish
index 20a352c..eaecfd1 100644
--- a/config.fish
+++ b/config.fish
@@ -56,6 +56,7 @@ prepend_to_path ~/repos/scripts/images
prepend_to_path ~/repos/scripts/installers
prepend_to_path ~/repos/scripts/macos
prepend_to_path ~/repos/scripts/python
+prepend_to_path ~/repos/scripts/tailscale
prepend_to_path ~/repos/scripts/terraform
prepend_to_path ~/repos/scripts/text
prepend_to_path ~/repos/scripts/web
tailscale/README.md (1894) → tailscale/README.md (2307)
diff --git a/tailscale/README.md b/tailscale/README.md
index 566f689..bcc20ac 100644
--- a/tailscale/README.md
+++ b/tailscale/README.md
@@ -18,6 +18,10 @@ folder_name = "tailscale"
scripts = [
{
+ "usage": "ensure_on_tailnet.sh TAILNET_NAME",
+ "description": "ensure I'm connected to a particular tailnet on my work computer"
+ },
+ {
"usage": "gostress PACKAGE TEST_NAME",
"description": "run a test with Go’s stress utility",
},
@@ -40,6 +44,15 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
]]]-->
<dl>
<dt>
+ <a href="https://github.com/alexwlchan/scripts/blob/main/tailscale/ensure_on_tailnet.sh">
+ <code>ensure_on_tailnet.sh TAILNET_NAME</code>
+ </a>
+ </dt>
+ <dd>
+ ensure I'm connected to a particular tailnet on my work computer
+ </dd>
+
+ <dt>
<a href="https://github.com/alexwlchan/scripts/blob/main/tailscale/gostress">
<code>gostress PACKAGE TEST_NAME</code>
</a>
@@ -75,4 +88,4 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
run a CLi command on a local instance of tailscaled
</dd>
</dl>
-<!-- [[[end]]] (sum: Bnz6W8Jdcg) -->
\ No newline at end of file
+<!-- [[[end]]] (sum: 4hnXIiewO2) -->
\ No newline at end of file
tailscale/ensure_on_tailnet.sh (0) → tailscale/ensure_on_tailnet.sh (431)
diff --git a/tailscale/ensure_on_tailnet.sh b/tailscale/ensure_on_tailnet.sh
new file mode 100755
index 0000000..9354ce7
--- /dev/null
+++ b/tailscale/ensure_on_tailnet.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+
+if (( $# == 0 )); then
+ echo "Usage: $0 TAILNET" >&2
+ exit 1
+fi
+
+if [[ $(hostname) != "Alexs-MacBook-Pro.local" ]]; then
+ exit 0
+fi
+
+target_tailnet="$1"
+current_tailnet="$(tailscale status --json | jq -r .CurrentTailnet.Name)"
+
+if [[ "$current_tailnet" != "$target_tailnet" ]]; then
+ print_info "-> tailscale switch '$target_tailnet'"
+ tailscale switch "$target_tailnet"
+fi