#!/bin/sh
#
# chkconfig: - 89 9
# description: Start/Stop the failed login daemon for dialup_admin
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#    Copyright (C) 2001 The FreeRADIUS Project   http://www.freeradius.org
#

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

FAILEDD=/home/dialup_admin/bin/log_badlogins
LOCKF=/var/lock/subsys/log_badlogins
LOGFILE=/var/log/radius/radius.log
CONFIG=/home/dialup_admin/conf/admin.conf
PIDFILE=/var/run/log_badlogins.pid

[ -f $FAILEDD ] || exit 0
[ -f $CONFIG ] || exit 0

RETVAL=0

case "$1" in
  start)
	echo -n $"Starting failed login server: "
	#daemon $FAILEDD $LOGFILE $CONFIG
	$FAILEDD $LOGFILE $CONFIG &
	RETVAL=$?
	if [ $RETVAL -eq 0 ]; then
		echo $! > $PIDFILE
		success "failed logins startup"
		echo
		touch $LOCKF
	else
		echo_failure
	fi
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch $LOCKF
	;;
  stop)
	echo -n $"Stopping failed login server: "
	killproc $FAILEDD
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f $LOCKF
	;;
  status)
	status log_badlogins
	RETVAL=$?
        ;;
  restart)
	$0 stop
	sleep 3
	$0 start
	RETVAL=$?
	;;
  condrestart)
	if [ -f $LOCKF ]; then
		$0 stop
		sleep 3
		$0 start
		RETVAL=$?
	fi
	;;
  *)
	echo $"Usage: $0 {start|stop|status|restart|condrestart}"
	exit 1
esac

exit $RETVAL

