* Enabled hardened build flags, thanks Moritz Muehlenhoff (closes: #657846)
[l2tpns.git] / debian / init.d
1 #! /bin/sh
2 ### BEGIN INIT INFO
3 # Provides:          l2tpns
4 # Required-Start:    $remote_fs $syslog
5 # Required-Stop:     $remote_fs $syslog
6 # Default-Start:     2 3 4 5
7 # Default-Stop:      0 1 6
8 ### END INIT INFO
9 #
10 # l2tpns        Based on skeleton example file.
11 #
12 #               Written by Miquel van Smoorenburg <miquels@cistron.nl>.
13 #               Modified for Debian GNU/Linux
14 #               by Ian Murdock <imurdock@gnu.ai.mit.edu>.
15 #
16
17 PATH=/sbin:/bin:/usr/sbin:/usr/bin
18 DAEMON=/usr/sbin/l2tpns
19 NAME=l2tpns
20 DESC=l2tpns
21 ARGS="-d"
22 ACCTDIR=$(grep "set accounting_dir" /etc/l2tpns/startup-config | sed -e 's/.* "//' -e 's/".*//')
23
24 test -f $DAEMON || exit 0
25
26 set -e
27
28 case "$1" in
29   start)
30         echo -n "Starting $DESC: "
31         if [ ! -d "$ACCTDIR" ]; then
32                 mkdir -p "$ACCTDIR"
33         fi
34         start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
35                 --exec $DAEMON -- $ARGS
36         echo "$NAME."
37         ;;
38   stop)
39         echo -n "Stopping $DESC: "
40         start-stop-daemon --oknodo --stop --signal 3 --quiet \
41                 --pidfile /var/run/$NAME.pid --exec $DAEMON -- $ARGS
42         echo "$NAME."
43         ;;
44   reload)
45         #
46         #       If the daemon can reload its config files on the fly
47         #       for example by sending it SIGHUP, do it here.
48         #
49         #       If the daemon responds to changes in its config file
50         #       directly anyway, make this a do-nothing entry.
51         #
52         echo "Reloading $DESC configuration files."
53         start-stop-daemon --stop --signal 1 --quiet --pidfile \
54                 /var/run/$NAME.pid --exec $DAEMON -- $ARGS
55         ;;
56   restart|force-reload)
57         #
58         #       If the "reload" option is implemented, move the "force-reload"
59         #       option to the "reload" entry above. If not, "force-reload" is
60         #       just the same as "restart".
61         #
62         echo -n "Restarting $DESC: "
63         start-stop-daemon --stop --quiet --pidfile \
64                 /var/run/$NAME.pid --exec $DAEMON -- $ARGS
65         sleep 5
66         start-stop-daemon --start --quiet --pidfile \
67                 /var/run/$NAME.pid --exec $DAEMON -- $ARGS
68         echo "$NAME."
69         ;;
70   *)
71         N=/etc/init.d/$NAME
72         # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
73         echo "Usage: $N {start|stop|restart|force-reload}" >&2
74         exit 1
75         ;;
76 esac
77
78 exit 0