aboutsummarylogtreecommitdiffstats
path: root/initcpio-hooks-tailscale
blob: 831ba55423e2a7729ee0fd4f8e14e350d90693e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/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() {
  /usr/sbin/tailscaled --cleanup
  local pid=$(cat /run/tailscaled.pid 2>/dev/null)
  [[ -z $pid ]] || kill "$pid"
}