aboutsummarylogtreecommitdiffstats
path: root/tailscale_hook
blob: c0529c5165e3118150f9fe2ca29808a56c7066d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env ash

run_hook() (
  echo "Starting Tailscale"
  . /etc/default/tailscaled

  # Launch tailscale agent in the background
  /usr/sbin/tailscaled \
    --state=/var/lib/tailscale/tailscaled.state \
    --socket=/run/tailscale/tailscaled.sock \
    --port="${PORT}" ${FLAGS} &

  echo "$!" >/run/tailscaled.pid
)

run_cleanuphook() {
  local pid=$(cat /run/tailscaled.pid 2>/dev/null)
  [[ -z $pid ]] || kill "$pid"
}