forked from FreeRADIUS/freeradius-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
radsniff.init
executable file
·90 lines (69 loc) · 2.28 KB
/
radsniff.init
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
#!/bin/sh
# Start/stop the FreeRADIUS daemon.
### BEGIN INIT INFO
# Provides: radsniff
# Required-Start: $network $syslog
# Should-Start: $time collectd
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Radius Daemon
# Description: RADIUS packet monitor
### END INIT INFO
PROG=$(basename $0) # This allows multiple instances of radsniff
# to be used by symlinking the init script.
PROGRAM="radsniff"
PIDFILE="/var/run/$PROG.pid"
DESCR="radsniff daemon"
set -e
. /lib/lsb/init-functions
if [ -r /etc/default/$PROG ]; then
. /etc/default/$PROG
fi
test -f $PROGRAM || exit 0
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
ret=0
# These defaults should work for simple installations
RADSNIFF_OPTIONS=${RADSNIFF_OPTIONS:-'-q -W 10 -O /var/run/collectd-unixsock'}
case "$1" in
start)
log_daemon_msg "Starting $DESCR" "$PROG"
# eval allows quoted arguments (filters for example) to be passed in $RADSNIFF_OPTIONS
eval "start_daemon -p '$PIDFILE' '$PROGRAM' -P '$PIDFILE' -N '$PROG' $RADSNIFF_OPTIONS" || ret=$?
log_end_msg $ret
;;
stop)
log_daemon_msg "Stopping $DESCR" "$PROG"
if [ -f "$PIDFILE" ]; then
pid=`cat $PIDFILE`
killproc -p "$PIDFILE" || ret=$?
# radsniff shuts down everything gracefully which may take a little time
# we need to delay returning from stop because the pid file is unlinked
# last (as it should be), and if start_daemon finds it, it declines to
# start radsniff again.
if [ $pid != '' ] && ps $pid > /dev/null; then
for i in {5..0}; do
if ! ps $pid > /dev/null; then break; fi;
sleep 0.5
done
if [ $i -eq 0 ]; then
ret=1
fi
fi
fi
restart|force-reload)
$0 stop
$0 start
;;
debug)
$PROGRAM -xxx -N "$PROG" $RADSNIFF_OPTIONS
;;
status)
status_of_proc -p "$PIDFILE" "$PROGRAM" "$PROG" || ret=$?
;;
*)
echo "Usage: $0 start|stop|restart|force-reload|debug|status"
exit 1
;;
esac
exit $ret