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

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

  mkdir /dev/pts
  mount -t devpts none /dev/pts

  # 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"
}