Skip to main content

Add all my Tailscale scripts

ID
a6eab9a
date
2026-02-14 20:43:51+00:00
author
Alex Chan <alexc@tailscale.com>
parent
cc8db14
message
Add all my Tailscale scripts
changed files
7 files, 171 additions, 1 deletion

Changed files

tailscale/README.md (0) → tailscale/README.md (1894)

diff --git a/tailscale/README.md b/tailscale/README.md
new file mode 100644
index 0000000..566f689
--- /dev/null
+++ b/tailscale/README.md
@@ -0,0 +1,78 @@
+# tailscale
+
+Scripts specific to my work at Tailscale.
+
+## The individual scripts
+
+<!-- [[[cog
+
+# This adds the root of the repo to the PATH, which has cog_helpers.py
+from os.path import abspath, dirname
+import sys
+
+sys.path.append(abspath(dirname(dirname("."))))
+
+import cog_helpers
+
+folder_name = "tailscale"
+
+scripts = [
+    {
+        "usage": "gostress PACKAGE TEST_NAME",
+        "description": "run a test with Go’s stress utility",
+    },
+    {
+        "usage": "start_local_tailscaled.sh NAME",
+        "description": "start a local instance of tailscaled",
+    },
+    {
+        "usage": "login_local_tailscale.sh NAME",
+        "description": "log a local instance of tailscaled into a running version of devcontrol"
+    },
+    {
+        "usage": "lts NAME",
+        "description": "run a CLi command on a local instance of tailscaled"
+    },
+]
+
+cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
+
+]]]-->
+<dl>
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/tailscale/gostress">
+      <code>gostress PACKAGE TEST_NAME</code>
+    </a>
+  </dt>
+  <dd>
+    run a test with Go’s stress utility
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/tailscale/start_local_tailscaled.sh">
+      <code>start_local_tailscaled.sh NAME</code>
+    </a>
+  </dt>
+  <dd>
+    start a local instance of tailscaled
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/tailscale/login_local_tailscale.sh">
+      <code>login_local_tailscale.sh NAME</code>
+    </a>
+  </dt>
+  <dd>
+    log a local instance of tailscaled into a running version of devcontrol
+  </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/tailscale/lts">
+      <code>lts NAME</code>
+    </a>
+  </dt>
+  <dd>
+    run a CLi command on a local instance of tailscaled
+  </dd>
+</dl>
+<!-- [[[end]]] (sum: Bnz6W8Jdcg) -->
\ No newline at end of file

tailscale/gostress (0) → tailscale/gostress (444)

diff --git a/tailscale/gostress b/tailscale/gostress
new file mode 100755
index 0000000..eb1d357
--- /dev/null
+++ b/tailscale/gostress
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+# Shortcut for running the Go stress command.
+#
+# [1]: https://pkg.go.dev/golang.org/x/tools/cmd/stress
+
+set -o errexit
+set -o nounset
+set -o verbose
+
+rm -f /tmp/q.txt
+rm -rf /tmp/q/*
+rm -f stop.txt
+rm -f test.o
+
+set +o errexit
+./tool/go test -race -o test.o "$1" -run=$2 -timeout=60s
+set -o errexit
+
+if [[ -f test.o ]]
+then
+    echo test.o >> .git/info/exclude
+    stress ./test.o -test.run=$2 -test.timeout=60s -test.v
+fi

tailscale/login_local_tailscale.sh (0) → tailscale/login_local_tailscale.sh (195)

diff --git a/tailscale/login_local_tailscale.sh b/tailscale/login_local_tailscale.sh
new file mode 100755
index 0000000..6779c66
--- /dev/null
+++ b/tailscale/login_local_tailscale.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+set -o xtrace
+
+NAME="$1"
+
+bash ~/repos/scripts/tailscale/lts "$NAME" \
+  up \
+  --hostname="$NAME" \
+  --login-server="http://localhost:31544/"

tailscale/lts (0) → tailscale/lts (227)

diff --git a/tailscale/lts b/tailscale/lts
new file mode 100755
index 0000000..f5e8a8d
--- /dev/null
+++ b/tailscale/lts
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+# Run a command on a locally running instance of tailscaled.
+
+set -o errexit
+set -o nounset
+set -o xtrace
+
+NAME="$1"
+
+cd ~/repos/oss
+
+./tool/go run ./cmd/tailscale \
+  --socket=/tmp/ts/$NAME/ts.sock "${@:2}"
\ No newline at end of file

tailscale/start_local_tailscaled.sh (0) → tailscale/start_local_tailscaled.sh (531)

diff --git a/tailscale/start_local_tailscaled.sh b/tailscale/start_local_tailscaled.sh
new file mode 100755
index 0000000..6ca2e34
--- /dev/null
+++ b/tailscale/start_local_tailscaled.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+
+NAME="$1"
+
+print_info "socket: /tmp/ts/$NAME/ts.sock"
+
+source ~/repos/scripts/.venv/bin/activate
+
+python3 ~/repos/scripts/macos/set_iterm_tab_title.py "$NAME (tailscaled)"
+
+cd ~/repos/oss
+
+if [[ "${2:-}" != "--persist" ]]
+then
+    trap "rm -rf /tmp/ts/$NAME" EXIT
+fi
+
+TS_DEBUGSYSPOLICY_ADVERTISE_EXIT_NODE=user-decides ./tool/go run ./cmd/tailscaled \
+  --socket=/tmp/ts/$NAME/ts.sock \
+  --state=/tmp/ts/$NAME/ts.state \
+  --statedir=/tmp/ts/$NAME \
+  --tun=userspace-networking
\ No newline at end of file

text/README.md (6505) → text/README.md (6786)

diff --git a/text/README.md b/text/README.md
index 5b5581e..acce74d 100644
--- a/text/README.md
+++ b/text/README.md
@@ -90,6 +90,10 @@ scripts = [
         "usage": "tally < [PATH]",
         "description": "prints a tally of lines in the given text.",
     },
+    {
+        "usage": "vs [PATH]",
+        "description": "open a path in Visual Studio Code",
+    },
 ]
 
 cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
@@ -225,5 +229,14 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
   <dd>
     prints a tally of lines in the given text.
   </dd>
+
+  <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/text/vs">
+      <code>vs [PATH]</code>
+    </a>
+  </dt>
+  <dd>
+    open a path in Visual Studio Code
+  </dd>
 </dl>
-<!-- [[[end]]] (sum: FyzA8+tT8Q) -->
\ No newline at end of file
+<!-- [[[end]]] (sum: 78MC1MmStd) -->
\ No newline at end of file

text/vs (0) → text/vs (85)

diff --git a/text/vs b/text/vs
new file mode 100755
index 0000000..43a97c1
--- /dev/null
+++ b/text/vs
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+
+set -o errexit
+set -o nounset
+
+open -a "Visual Studio Code" "$@"
\ No newline at end of file