summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-connectivity/tailscale/files/tailscaled.init
diff options
context:
space:
mode:
Diffstat (limited to 'meta-networking/recipes-connectivity/tailscale/files/tailscaled.init')
-rw-r--r--meta-networking/recipes-connectivity/tailscale/files/tailscaled.init68
1 files changed, 68 insertions, 0 deletions
diff --git a/meta-networking/recipes-connectivity/tailscale/files/tailscaled.init b/meta-networking/recipes-connectivity/tailscale/files/tailscaled.init
new file mode 100644
index 0000000000..8b7552543c
--- /dev/null
+++ b/meta-networking/recipes-connectivity/tailscale/files/tailscaled.init
@@ -0,0 +1,68 @@
1#!/bin/sh
2### BEGIN INIT INFO
3# Provides: tailscaled
4# Required-Start: $network $local_fs
5# Required-Stop: $network $local_fs
6# Default-Start: 3 4 5
7# Default-Stop: 0 1 2 6
8# Short-Description: Tailscale node agent
9# Description: Start the Tailscale daemon.
10### END INIT INFO
11
12PATH=/sbin:/usr/sbin:/bin:/usr/bin
13DAEMON=/usr/sbin/tailscaled
14PIDFILE=/var/run/tailscaled.pid
15NAME=tailscaled
16DESC="Tailscale node agent"
17
18test -x $DAEMON || exit 0
19
20set -e
21
22. /etc/init.d/functions
23
24if [ -f /etc/default/tailscaled ] ; then
25 . /etc/default/tailscaled
26fi
27
28delay_stop() {
29 count=0
30 while [ $count -lt 9 ] ; do
31 if pidof $DAEMON >/dev/null; then
32 sleep 1
33 else
34 return 0
35 fi
36 count=$(expr $count + 1)
37 done
38 echo "Failed to stop $DESC."
39 return 1
40}
41
42case "$1" in
43 start)
44 echo -n "starting $DESC: $NAME... "
45 start-stop-daemon --start --background --make-pidfile --pidfile $PIDFILE \
46 --exec $DAEMON -- $ARGS
47 echo "done."
48 ;;
49 stop)
50 echo -n "stopping $DESC: $NAME... "
51 start-stop-daemon --stop --pidfile $PIDFILE
52 echo "done."
53 ;;
54 restart)
55 $0 stop
56 delay_stop && $0 start
57 ;;
58 status)
59 status $DAEMON
60 exit $?
61 ;;
62 *)
63 echo "Usage: $0 {start|stop|restart|status}"
64 exit 1
65 ;;
66esac
67
68exit 0