forked from tailscale/codespace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tailscaled
executable file
·59 lines (47 loc) · 1.59 KB
/
tailscaled
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
### BEGIN INIT INFO
# Provides: tailscaled
# Required-Start:
# Required-Stop:
# Default-Start:
# Default-Stop:
# Short-Description: Tailscale Mesh Wireguard VPN
### END INIT INFO
set -e
# /etc/init.d/tailscale: start and stop the Tailscale VPN service
test -x /usr/sbin/tailscaled || exit 0
umask 022
. /lib/lsb/init-functions
# Are we running from init?
run_by_init() {
([ "$previous" ] && [ "$runlevel" ]) || [ "$runlevel" = S ]
}
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
log_daemon_msg "Starting Tailscale VPN" "tailscaled" || true
if start-stop-daemon --start --quiet --oknodo --chuid 0:0 --pidfile /run/tailscaled.pid --background \
--exec /usr/sbin/tailscaled -- --state=/var/lib/tailscale/tailscaled.state \
--socket=/run/tailscale/tailscaled.sock --port 41641; then
tailscale up --authkey=${TAILSCALE_AUTHKEY} --netfilter-mode=off
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
stop)
log_daemon_msg "Stopping Tailscale VPN" "tailscaled" || true
if start-stop-daemon --stop --quiet --oknodo --pidfile /run/tailscaled.pid --exec /usr/sbin/tailscaled; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
status)
status_of_proc -p /run/tailscaled.pid /usr/sbin/tailscaled tailscaled && exit 0 || exit $?
;;
*)
log_action_msg "Usage: /etc/init.d/tailscaled {start|stop|status}" || true
exit 1
esac
exit 0