#!/bin/sh
#
# radiator      This shell script takes care of starting and stopping \
#               Radiator (radius daemon).
#
# chkconfig: 2345 90 15
# description: radiator is the radius daemon required for RAS AAA.
# processname: /usr/bin/radiusd
#
# Startup script for Radiator on Linux. Install this as 
# /etc/init.d/radiator. If you have chkconfig, you can use
# chkconfig -add radiator
# to generate the required start asnd stop entries in /etc/rc[2345].d/
# Otherwise, you need to add symlinks to /etc/rc[2345].d/
#
# config: /etc/radiator/radius.cfg
#
# Author: Marc Liyanage <mliyanage@futurelab.ch>,
#         based on goodies/linux-radiator.init by
#         Mike McCauley (Open System Consultants)
#
# Copyright (C) 2002 futureLAB AG
# Copyright (C) 2000 Open System Consultants
#
# $Id: radiator-tornado.init,v 1.1 2002/08/09 16:12:26 mliyanage Exp $

# Source 'em up
. /etc/init.d/functions

RESTARTWRAPPER=/usr/bin/restartWrapper
RADIUSD=/usr/bin/radiusd
RADIATOR_CONFIG=/etc/radiator/radius.cfg
RADIATOR_ARGS=

# Source additional OPTIONS if we have them.
if [ -f /etc/sysconfig/radiator ] ; then
	. /etc/sysconfig/radiator
fi

if [ ! -x $RADIUSD ]; then
	exit 0
fi

start() {

    # don't do squat if we don't have the config file
    #
    if [ -f $RADIATOR_CONFIG ]; then
	echo -n "Starting Radiator: "
	$RESTARTWRAPPER -mail radius-admin@xyz.ch $RADIUSD "'-config_file'"  $RADIATOR_CONFIG $RADIATOR_ARGS &
	RETVAL=$?
	echo
    else
	echo Unable to find config file $RADIATOR_CONFIG!
    fi
    return $RETVAL
}

stop() {
    echo -n "Shutting down Radiator: "
    killproc restartWrapper
    killproc radiusd
    RETVAL=$?
    echo
    return $RETVAL
}

case "$1" in
  start)
       start
    ;;
  stop)
       stop
    ;;
  restart|reload)
        stop
        start
	RETVAL=$?
    ;;
  status)
        status radiusd
	RETVAL=$?
    ;;

  *)
	echo "Usage: $0 {start|stop|restart|status}"
	exit 1
esac

exit $RETVAL

