aboutsummarylogtreecommitdiffstats
path: root/initcpio-hooks-tailscale
blob: b623551699afe699f8cbe24ec9f369257bef840a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash

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

  # Launch tailscale agent in the background
  /usr/sbin/tailscaled --cleanup
  /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
  /usr/sbin/tailscaled --cleanup
  pid=$(cat /run/tailscaled.pid 2>/dev/null)
  [[ -z $pid ]] || kill "$pid"
}