Add scripts to automatically generate test certificates.
[freeradius.git] / scripts / check-radiusd-config.in
1 #!/bin/sh
2 #
3 #  Check the RADIUS server configuration files.
4 #
5 #  If everything is OK, this script exits without an error.
6 #  
7 #  If there was an error parsing the configuration files, this script
8 #  prints the errors to the screen, and exits with an error.
9 #
10 #  This process presumes, of course, that there weren't any DNS
11 #  problems causing the server to wait forever on startup.
12 #
13 #  AUTHOR: Alan DeKok <aland@ox.org>
14 #          Wed Apr 12 15:21:51 EDT 2000
15 #
16
17 prefix=@prefix@
18 exec_prefix=@exec_prefix@
19 sbindir=@sbindir@
20 sysconfdir=@sysconfdir@
21 raddbdir=@raddbdir@
22
23 if [ "$1" = "-h" ]; then
24     echo
25     echo Usage: check-radiusd-config
26     echo
27     echo  Checks the radius daemon server configuration for errors.
28     exit 0
29 fi
30
31 #
32 #  Run the server as a background process, picking a high port
33 #  that (we hope) no one else is using.
34 #
35 #  Note that you might have to add a '-d raddb' to the command line
36 #  options, if your database is somewhere other than /etc/raddb
37 #
38 $sbindir/radiusd -X -p 32768 > startup.log 2>&1 &
39
40 #
41 #  Remember what it's process ID was.
42 #
43 RADIUSD_PID=$!
44
45 #
46 #  The server will run in the background until it's killed, so
47 #  we need another background job to kill it, after it's read
48 #  the configuration files, and is (possibly) running in debug mode.
49 #
50 (sleep 2 && kill -9 $RADIUSD_PID) > /dev/null 2>&1 &
51
52 #
53 #  Wait for it to exit with an error (1), or from being killed (137)
54 #
55 wait $RADIUSD_PID
56 RADIUSD_STATUS=$?
57
58 #
59 #  If the server died with an error, then show the startup error log.
60 #
61 if test "$RADIUSD_STATUS" = "1"; then
62   cat startup.log
63   exit 1
64 fi
65 echo Radius server configuration looks OK.
66 exit 0