aboutsummaryrefslogtreecommitdiffstats
path: root/main/freeradius/freeradius.initd
diff options
context:
space:
mode:
authorLeonardo Arena <rnalrd@alpinelinux.org>2015-05-14 09:54:19 +0000
committerLeonardo Arena <rnalrd@alpinelinux.org>2015-05-14 09:54:19 +0000
commit3a4970a7977f234a3cd37b7fe926735f09d546d1 (patch)
treed7e7333fd49839edc972d10fdcb35e6cc7def409 /main/freeradius/freeradius.initd
parentb2944c548dfed2a611d26e4c45b5454efc413854 (diff)
downloadaports-3a4970a7977f234a3cd37b7fe926735f09d546d1.tar.bz2
aports-3a4970a7977f234a3cd37b7fe926735f09d546d1.tar.xz
main/freeradius: nuke freeradius2 and replace it with new stable branch freeradius 3.0.x
Diffstat (limited to 'main/freeradius/freeradius.initd')
-rw-r--r--main/freeradius/freeradius.initd67
1 files changed, 12 insertions, 55 deletions
diff --git a/main/freeradius/freeradius.initd b/main/freeradius/freeradius.initd
index d8c91c1061..5412d2b31c 100644
--- a/main/freeradius/freeradius.initd
+++ b/main/freeradius/freeradius.initd
@@ -1,6 +1,14 @@
#!/sbin/openrc-run
extra_started_commands="reload"
+run_dir="/var/run/radiusd"
+command="/usr/sbin/radiusd"
+command_args="$RADIUSD_OPTS"
+pidfile="$run_dir/radiusd.pid"
+name="Freeradius"
+conf="/etc/raddb/radiusd.conf"
+user="$(grep -v '#' $conf | grep 'user =' | awk -F " = " '{ print $2 }')"
+group="$(grep -v '#' $conf |grep 'group =' | awk -F " = " '{ print $2 }')"
depend() {
need net
@@ -8,63 +16,12 @@ depend() {
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/radius ] && ! mkdir /var/run/radius ; then
- eerror "Failed to create /var/run/radius"
- 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/radius && \
- chmod -R u+rwX,g+rX . /var/run/radius || 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/radius/radiusd.pid
- eend $?
+start_pre() {
+ checkpath --directory --owner ${user}:${group} --mode 0775 ${run_dir}
}
reload () {
- ebegin "Reloading radiusd"
- kill -HUP `cat /var/run/radius/radiusd.pid`
+ ebegin "Reloading $name"
+ kill -HUP `cat $pidfile`
eend $?
}
-