aboutsummaryrefslogtreecommitdiffstats
path: root/main/freeradius/freeradius.initd
diff options
context:
space:
mode:
authorLeonardo Arena <rnalrd@gmail.com>2010-10-25 12:29:17 +0000
committerLeonardo Arena <rnalrd@gmail.com>2010-10-25 12:29:44 +0000
commit7901aaada9de9473336772ba54f4a37734f76b6d (patch)
tree3b5189489f9ee02b834b77eb026e1609d4427b54 /main/freeradius/freeradius.initd
parent45a3bc8ebaa875b88786682ea94c4fb7f152b1f9 (diff)
downloadaports-7901aaada9de9473336772ba54f4a37734f76b6d.tar.bz2
aports-7901aaada9de9473336772ba54f4a37734f76b6d.tar.xz
testing/freeradius: move to main
Diffstat (limited to 'main/freeradius/freeradius.initd')
-rw-r--r--main/freeradius/freeradius.initd70
1 files changed, 70 insertions, 0 deletions
diff --git a/main/freeradius/freeradius.initd b/main/freeradius/freeradius.initd
new file mode 100644
index 0000000000..2386a9fcc4
--- /dev/null
+++ b/main/freeradius/freeradius.initd
@@ -0,0 +1,70 @@
+#!/sbin/runscript
+
+opts="${opts} reload"
+
+depend() {
+ need net
+ after firewall
+ use dns
+}
+
+checkconfig() {
+ #set the location of log files, including startup.log created by check-radiusd-config
+ if ! cd /var/log/radius ; then
+ eerror "Failed to change current directory to /var/log/radius"
+ return 1
+ fi
+
+ if [ ! -d /var/run/radiusd ] && ! mkdir /var/run/radiusd ; then
+ eerror "Failed to create /var/run/radiusd"
+ return 1
+ fi
+
+ if [ ! -f /etc/raddb/radiusd.conf ] ; then
+ eerror "No /etc/raddb/radiusd.conf file exists!"
+ return 1
+ fi
+
+ if [ "`/usr/sbin/radiusd -C >/dev/null 2>&1; echo $?`" != "0" ] ; then
+ eerror "Config not ok! (try /usr/sbin/radiusd -C )"
+ return 1
+ fi
+
+ RADIUSD_USER=`grep '^ *user *=' /etc/raddb/radiusd.conf | cut -d ' ' -f 3`
+ RADIUSD_GROUP=`grep '^ *group *=' /etc/raddb/radiusd.conf | cut -d ' ' -f 3`
+ if [ -n "${RADIUSD_USER}" ] && ! getent passwd ${RADIUSD_USER} > /dev/null ; then
+ eerror "${RADIUSD_USER} user missing!"
+ return 1
+ fi
+ if [ -n "${RADIUSD_GROUP}" ] && ! getent group ${RADIUSD_GROUP} > /dev/null ; then
+ eerror "${RADIUSD_GROUP} group missing!"
+ return 1
+ fi
+
+ #radius.log is created before privileges drop; we need to set proper permissions on it
+ [ -f radius.log ] || touch radius.log || return 1
+
+ chown -R "${RADIUSD_USER:-root}:${RADIUSD_GROUP:-root}" . /var/run/radiusd && \
+ chmod -R u+rwX,g+rX . /var/run/radiusd || return 1
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting radiusd"
+ start-stop-daemon --start --quiet --exec /usr/sbin/radiusd -- ${RADIUSD_OPTS} >/dev/null
+ eend $?
+}
+
+stop () {
+ ebegin "Stopping radiusd"
+ start-stop-daemon --stop --quiet --pidfile=/var/run/radiusd/radiusd.pid
+ eend $?
+}
+
+reload () {
+ ebegin "Reloading radiusd"
+ kill -HUP `</var/run/radiusd/radiusd.pid`
+ eend $?
+}
+