Correct typo in syntax, and check for pid file before using it.
[freeradius.git] / scripts / rc.radiusd.in
1 #!/bin/sh
2 #
3 # radiusd       Start the radius daemon.
4 #
5 #    This program is free software; you can redistribute it and/or modify
6 #    it under the terms of the GNU General Public License as published by
7 #    the Free Software Foundation; either version 2 of the License, or
8 #    (at your option) any later version.
9 #
10 #    This program is distributed in the hope that it will be useful,
11 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #    GNU General Public License for more details.
14 #
15 #    You should have received a copy of the GNU General Public License
16 #    along with this program; if not, write to the Free Software
17 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 #
19 #    Copyright (C) 2001-2002 The FreeRADIUS Project http://www.freeradius.org
20
21 prefix=@prefix@
22 exec_prefix=@exec_prefix@
23 sbindir=@sbindir@
24 localstatedir=@localstatedir@
25 logdir=@logdir@
26 rundir=${localstatedir}/run/radiusd
27
28 RADIUSD=$sbindir/radiusd
29 RADDBDIR=@raddbdir@
30 DESC="FreeRADIUS"
31
32 #
33 #  See 'man radiusd' for details on command-line options.
34 #
35 ARGS=""
36
37 test -f $RADIUSD || exit 0
38 test -f $RADDBDIR/radiusd.conf || exit 0
39
40 case "$1" in
41   start)
42         echo -n "Starting $DESC:"
43         $RADIUSD $ARGS
44         echo "radiusd"
45         ;;
46   stop)
47         [ -z "$2" ] && echo -n "Stopping $DESC: "
48         [ -f $rundir/radiusd.pid ] && kill -TERM `cat $rundir/radiusd.pid`
49         [ -z "$2" ] && echo "radiusd."
50         ;;
51   reload|force-reload)
52         echo "Reloading $DESC configuration files."
53         [ -f $rundir/radiusd.pid ] && kill -HUP `cat $rundir/radiusd.pid`
54         ;;
55   restart)
56         sh $0 stop quiet
57         sleep 3
58         sh $0 start
59         ;;
60   *)
61         echo "Usage: /etc/init.d/$RADIUS {start|stop|reload|restart}"
62         exit 1
63 esac
64
65 exit 0