File: rc.radiusd

package info (click to toggle)
xtradius 1.2.1-beta2-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,256 kB
  • ctags: 921
  • sloc: ansic: 10,183; perl: 733; sh: 267; makefile: 148; sql: 21
file content (96 lines) | stat: -rw-r--r-- 2,349 bytes parent folder | download
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
#!/bin/sh
#
# radiusd	Start the radius daemon.
#
#		This is a script suitable for the Debian Linux distribution.
#		Copy it to /etc/init.d/radiusd, make it executable, and
#		execute "update-rc.d radiusd defaults 50".
#

RADIUSD=/usr/local/sbin/radiusd
RADRELAY=/usr/local/sbin/radrelay
DESC="Cistron radius server"
NAME1=radiusd
NAME2=radrelay

# These are the defaults.
RADIUS_ARGS="-y"

# This is useful if you want to replicate accounting packets
# to another radius server - see README.radrelay
#RADIUS_ARGS="-y -w -F %N/detail -F detail.rep"
#RADRELAY_ARGS="-a /var/log/radacct XX.SERVER.HERE.XX detail.rep"

test -f $RADIUSD || exit 0

case "$1" in
  start)
	if [ ! -f /var/log/radutmp ]
	then
		:>/var/log/radutmp
	fi
	echo -n "Starting $DESC:"
	if [ -x "$RADRELAY" ] &&[ -n "$RADRELAY_ARGS" ]
	then
		echo -n " radrelay"
		start-stop-daemon --start --quiet \
			--pidfile /var/run/$NAME2.pid \
			--exec $RADRELAY -- $RADRELAY_ARGS
	fi
	echo -n " radiusd"
	start-stop-daemon --start --quiet \
		--pidfile /var/run/$NAME1.pid \
		--exec $RADIUSD -- $RADIUS_ARGS
	echo "."
	;;
  stop)
	[ -z "$2" ] && echo -n "Stopping $DESC:"
	if [ -x "$RADRELAY" ] &&[ -n "$RADRELAY_ARGS" ]
	then
		[ -z "$2" ] && echo -n " radrelay"
		pid=$(cat /var/run/$NAME2.pid 2> /dev/null)
		if [ "$pid" -gt 0 ]; then
			count=10
			while [ $count -gt 0 ] && kill -0 "$pid" 2> /dev/null ; do
				start-stop-daemon --stop --quiet \
					--pidfile /var/run/$NAME2.pid --exec $RADRELAY
				count=$(( $count - 1 ))
				sleep 1
			done
			if kill -0 "$pid" 2> /dev/null; then
				kill -9 "$pid"
			fi
		fi
	fi
	[ -z "$2" ] && echo -n " radiusd"
	pid=$(cat /var/run/$NAME1.pid 2> /dev/null)
	if [ "$pid" -gt 0 ]; then
		count=10
		while [ $count -gt 0 ] && kill -0 "$pid" 2> /dev/null ; do
			start-stop-daemon --stop --quiet \
				--pidfile /var/run/$NAME1.pid --exec $RADIUSD
			count=$(( $count - 1 ))
			sleep 1
		done
		if kill -0 "$pid" 2> /dev/null; then
			kill -9 "$pid"
		fi
	fi
	[ -z "$2" ] && echo "."
	;;
  reload|force-reload)
	echo "Reloading $DESC configuration files."
	start-stop-daemon --stop --signal 1 --quiet --pidfile \
		/var/run/$NAME1.pid --exec $RADIUSD
	;;
  restart)
	sh /etc/init.d/radiusd stop quiet
	sleep 3
	/etc/init.d/radiusd start
	;;
  *)
        echo "Usage: /etc/init.d/$NAME1 {start|stop|reload|restart}"
        exit 1
esac

exit 0