diff options
Diffstat (limited to 'meta-networking/recipes-connectivity/tailscale/files/tailscaled.init')
-rw-r--r-- | meta-networking/recipes-connectivity/tailscale/files/tailscaled.init | 68 |
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 | |||
12 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | ||
13 | DAEMON=/usr/sbin/tailscaled | ||
14 | PIDFILE=/var/run/tailscaled.pid | ||
15 | NAME=tailscaled | ||
16 | DESC="Tailscale node agent" | ||
17 | |||
18 | test -x $DAEMON || exit 0 | ||
19 | |||
20 | set -e | ||
21 | |||
22 | . /etc/init.d/functions | ||
23 | |||
24 | if [ -f /etc/default/tailscaled ] ; then | ||
25 | . /etc/default/tailscaled | ||
26 | fi | ||
27 | |||
28 | delay_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 | |||
42 | case "$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 | ;; | ||
66 | esac | ||
67 | |||
68 | exit 0 | ||