/wait4tailscale

Monitor Tailscale connection status

Primary LanguageGoMIT LicenseMIT

wait4tailscale

Basically a rich man's version of this poor man's bash script:

while ! tailscale status --json | jq --exit-status '.Self.Online' >/dev/null
  sleep 1
done

Usage

Block until tailscale reaches an online or offline state. Returns immediately if its already in its desired state.

$ wait4tailscale --online
$ wait4tailscale --offline

Or watch a log of all changes

$ wait4tailscale --watch
online
offline
online

Will automatically detect the default socket location, but otherwise a socket can be explicitly given.

$ wait4tailscale --socket /var/run/tailscale/tailscaled.sock

systemd Integration

The package includes systemd units that provide a tailscale-online.target similar to network-online.target. Other services can depend on this target to wait for Tailscale connectivity:

[Unit]
After=tailscale-online.target
Wants=tailscale-online.target

Nix

Packaged under josh/nurpkgs flake. Use the systemd units in your NixOS config with something like this:

systemd.packages = [ pkgs.nur.repos.josh.wait4tailscale ];