0

The server (Centos 6.8) already has a single instance of Radius running as a service.

I have created a second instance and am able to make it run successfully with:

radiusd -X -d /etc/raddb2

I now need to make this second instance run as a service.

I'm aware of the file /etc/chkserv.d/radiusd which contains

service[radiusd]=x,x,x,/etc/init.d/radiusd restart,radiusd,radiusd

...also in /etc/chkserv.d/chkservd.conf I have radius listed as:

radiusd:1

I have copied the file /etc/init.d/radiusd to /etc/init.d/radiusd2

These are the contents of radius2

#!/bin/sh
#
# radiusd Start/Stop the FreeRADIUS daemon
#
# chkconfig: - 88 10
# description: Extensible, configurable, high performance RADIUS server.

### BEGIN INIT INFO
# Provides: radiusd
# Required-Start: $network
# Required-Stop:
# Default-Start:
# Default-Stop:
# Should-Start: $time $syslog mysql ldap postgresql samba krb5-kdc
# Should-Stop:
# Short-Description: FreeRADIUS server
# Description: Extensible, configurable, high performance RADIUS server.
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

prog=radiusd

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

exec=${exec:=/usr/sbin/$prog}
config_dir=${config_dir:=/etc/raddb2}
config=${config:=$config_dir/radiusd.conf}
pidfile=${pidfile:=/var/run/$prog/$prog.pid}
lockfile=${lockfile:=/var/lock/subsys/radiusd}

start() {
    [ -x $exec ] || exit 5
    [ -f $config ] || exit 6
    echo -n $"Starting $prog: "
    daemon --pidfile $pidfile $exec -d $config_dir
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    killproc -p $pidfile $prog
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

restart() {
    stop
    start
}

reload() {
    # radiusd may not be capable of a 100% configuration reload depending
    # on which loadable modules are in use, if sending the server a
    # HUP is not sufficient then use restart here instead. However, we
    # prefer by default to use HUP since it's what is usually desired.
    #
    # restart

    kill -HUP `pidofproc -p $pidfile $prog`
}

force_reload() {
    restart
}

rh_status() {
    # run checks to determine if the service is running or use generic status
    status -p $pidfile $prog
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}


case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    reload)
        rh_status_q || exit 7
        $1
        ;;
    force-reload)
        force_reload
        ;;
    status)
        rh_status
        ;;
    condrestart|try-restart)
        rh_status_q || exit 0
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
        exit 2
esac
exit $?

...so far the only thing I have changed is the config_dir variable to raddb2 (where the 2nd instance of radius lives)

config_dir=${config_dir:=/etc/raddb2} 

I think I need to change

pidfile=${pidfile:=/var/run/$prog/$prog.pid}

to something like:

pidfile=${pidfile:=/var/run/$prog/$prog2.pid}

I'd be grateful if someone could tell if that is correct and what else I need to do to get this second instance up and running.

Leon
  • 101
  • 2
  • Do you have the two instances set to listen on different ports? If not, this sounds like whichever instance was started second would fail due to the ports being in use. Have you tried the setup you suggest in your question, and if so, could you share any errors you might be seeing? – iwaseatenbyagrue Apr 19 '17 at 16:44
  • @iwaseatenbyagrue Both instances are runnable and set up to run on different ports(#1 on 1812/1813, #2 on 1645/1646) . The problem is how to start the second instance as a service, that's what I'm unclear about. – Leon Apr 20 '17 at 07:08
  • Thanks for the response @Leon - I unfortunately don't really know about chkserv, so can't comment on that part, but the rest seems 'fine' to me (other than the fact you almost certainly want to also change your lockfile location). The only other item that springs to mind is to ensure each instance has its own log file. – iwaseatenbyagrue Apr 20 '17 at 16:18

0 Answers0