Lame hack to get the rc script to kill radiusd, and not just radwatcher.
[freeradius.git] / scripts / rc.radiusd.in
1 #!/bin/sh
2 #
3 # radiusd       Start the radius daemon.
4 #
5 #               This is a script suitable for the Debian Linux distribution.
6 #               Copy it to /etc/init.d/radiusd, make it executable, and
7 #               execute "update-rc.d radiusd defaults 50".
8 #
9
10 prefix=@prefix@
11 exec_prefix=@exec_prefix@
12 sbindir=@sbindir@
13 localstatedir=@localstatedir@
14 logdir=@logdir@
15 rundir=${localstatedir}/run
16
17 RADIUSD=$sbindir/radiusd
18 WATCHER=$sbindir/radwatch
19 DESC="Freeradius server"
20 NAME1=radiusd
21 NAME2=radwatch
22
23 ARGS="-y"
24
25 test -f $RADIUSD || exit 0
26
27 case "$1" in
28   start)
29         if [ ! -f $logdir/radutmp ]
30         then
31                 >$logdir/radutmp
32         fi
33         echo -n "Starting $DESC:"
34         if [ -x $WATCHER ]
35         then
36                 echo -n " radwatch"
37                 start-stop-daemon --start --quiet --startas $WATCHER \
38                         --pidfile $rundir/$NAME2.pid --exec $RADIUSD -- $ARGS
39                 # and the watcher starts radiusd.
40                 echo -n " radiusd"
41         else
42                 echo -n " radiusd"
43                 start-stop-daemon --start --quiet \
44                         --pidfile $rundir/$NAME1.pid --exec $RADIUSD -- $ARGS
45         fi
46         echo "."
47         ;;
48   stop)
49         [ -z "$2" ] && echo -n "Stopping $DESC: "
50         if [ -x $WATCHER ]
51         then
52                 [ -z "$2" ] && echo -n "radwatch "
53                 start-stop-daemon --stop --quiet \
54                         --pidfile $rundir/$NAME2.pid -- exec $RADWATCH
55                 # but we have to stop radiusd manually.
56                 killall radiusd 2>/dev/null
57         else
58                 start-stop-daemon --stop --quiet \
59                         --pidfile $rundir/$NAME1.pid --exec $RADIUSD
60         fi
61         [ -z "$2" ] && echo "radiusd."
62         ;;
63   reload|force-reload)
64         echo "Reloading $DESC configuration files."
65         start-stop-daemon --stop --signal 1 --quiet --pidfile \
66                 $rundir/$NAME1.pid --exec $RADIUSD
67         ;;
68   restart)
69         sh /etc/init.d/radiusd stop quiet
70         sleep 3
71         /etc/init.d/radiusd start
72         ;;
73   *)
74         echo "Usage: /etc/init.d/$NAME1 {start|stop|reload|restart}"
75         exit 1
76 esac
77
78 exit 0