e3c55ed82df740c519632f24d3f22b7ae5819a0d
[tinc] / debian / init.d
1 #! /bin/sh
2 #
3 # System startup script for tinc
4 # $Id: init.d,v 1.14.2.4 2000/12/05 09:03:41 zarq Exp $
5 #
6 # Based on Lubomir Bulej's Redhat init script.
7 #
8 # Create a file $NETSFILE (/etc/tinc/nets.boot), and put all the names of
9 # the networks in there.  These names must be valid directory names under
10 # $TCONF (/etc/tinc).  Lines starting with a # will be ignored in this
11 # file.
12 #
13
14 DAEMON="/usr/sbin/tincd"
15 NAME="tinc"
16 DESC="tinc daemons"
17 TCONF="/etc/tinc"
18 EXTRA=""
19 NETSFILE="$TCONF/nets.boot"
20 NETS=""
21
22 test -f $DAEMON || exit 0
23
24 find_nets () {
25   if [ ! -f $NETSFILE ] ; then
26     echo "Please create $NETSFILE."
27     exit 0
28   fi
29   NETS="`egrep '^[ ]*[a-zA-Z0-9_]+[ ]*$' $NETSFILE`"
30 }
31
32 case "$1" in
33   start)
34     find_nets
35     echo -n "Starting $DESC:"
36     for n in $NETS ; do
37       echo -n " $n"
38       $DAEMON -n $n $EXTRA
39     done
40     echo "."
41   ;;
42   stop)
43     find_nets
44     echo -n "Stopping $DESC:"
45     for n in $NETS ; do
46       echo -n " $n"
47       $DAEMON -n $n $EXTRA -k
48     done
49     echo "."
50   ;;
51   restart|force-reload)
52     find_nets
53     echo -n "Restarting $DESC:"
54     for n in $NETS ; do
55       echo -n " $n"
56       $DAEMON -n $n $EXTRA -k
57       sleep 1
58       $DAEMON -n $n $EXTRA
59     done
60     echo "."
61   ;;
62   *)
63     echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}"
64     exit 1
65   ;;
66 esac