summaryrefslogtreecommitdiffstats
path: root/suse/rcradiusd
blob: cb736148d52f77b6ff34865aed40b7cd1252828f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#! /bin/sh
# Copyright (c) 2001       SuSE GmbH Nuernberg, Germany.
#               2002, 2003 SuSE Linux AG, Nuernberg, Germany.
#
# Author: Wolfgang Rosenauer, 2000-2003
#
# /etc/init.d/radiusd
#
#   and symbolic its link
#
# /usr/bin/rcradiusd
#
### BEGIN INIT INFO
# Provides:          radiusd
# Required-Start:    $network $syslog $remotefs
# Should-Start:      $time ypbind smtp
# Required-Stop:     $syslog $remote_fs
# Should-Stop:       ypbind smtp
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: RADIUS-Server
# Description:       Remote Authentication Dialin User Server
### END INIT INFO

. /etc/init.d/functions

prog=radiusd

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog

exec=${exec:=/usr/sbin/$prog}
config_dir=${config_dir:=/etc/raddb}

test -x "$exec" || { echo "$exec not installed"; \
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

configtest() {
    echo -n "Checking $prog configuration "
    out=`$exec -Cxl stdout -d $config_dir`; retval=$?
    out=`echo "${out}" | tail -n 1 | sed 's/^\s*ERROR:\s*\(.*\)\s*$/\1/'`

    [ $retval -ne 0 ] &&  echo "$out" 1>&2

    return $retval
}

rc_reset
case "$1" in
    start)
        configtest || { rc_failed 150; rc_exit; }
        echo -n "Starting RADIUS daemon "
        startproc $exec >/dev/null
        rc_status -v
        ;;

    stop)
        echo -n "Shutting down RADIUS daemon "
        killproc -TERM $exec
        rc_status -v
        ;;

    try-restart|condrestart)
        # If first returns OK call the second, if first or second command fails, set echo return value.
        if test "$1" = "condrestart"; then
            echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
        fi
        $0 status
        if [ $? = 0 ] ; then
                $0 restart
        else
                rc_reset        # Not running is not a failure.
        fi
        rc_status
        ;;

    restart)
        # Stop the service and regardless of whether it was running or not, start it again.
        configtest || { rc_failed 150; rc_exit; }
        $0 stop
        $0 start
        rc_status
        ;;

    force-reload)
        # Signal the daemon to reload its config. Most daemons o this on signal 1 (SIGHUP).
        # If it does not support it, restart.
        configtest || { rc_failed 150; rc_exit; }
        echo -n "Reload RADIUS daemon "
        killproc -HUP $exec
        rc_status -v
        ;;

    reload)
        # Like force-reload, but if daemon does not support signalling, do nothing (!)
        configtest || { rc_failed 150; rc_exit; }
        echo -n "Reload RADIUS daemon "
        killproc -HUP $exec
        rc_status -v
        ;;

    status)
        echo -n "Checking for service radiusd "
        checkproc $exec
        rc_status -v
        ;;

    configtest|testconfig)
        configtest
        rc_status -v
        ;;

    debug)
        $0 status
        if [ $? -eq 0 ]; then
            echo -n "$prog already running; for live debugging see raddebug(8)"
            exit 151
        fi
        $exec -X -d "$config_dir" || exit $?
        exit 0
        ;;

    debug-threaded)
        $0 status
        if [ $? -eq 0 ]; then
            echo -n "$prog already running; for live debugging see raddebug(8)"
            exit 151
        fi
        $exec -f -xx -l stdout -d "$config_dir" || exit $?
        exit 0
        ;;

    *)
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|configtest|debug|debug-threaded}"
        exit 1
        ;;
esac
rc_exit