#!/bin/sh
#
# chkconfig: 345 56 50
# description: xinetd is a powerful replacement for inetd. \
#              xinetd has access control machanisms, extensive logging \
#              capabilities, the ability to make services available based \
#              on time, and can place limits on the number of servers \
#              that can be started, among other things. 
# probe: true
# processname: xinetd
# pidfile: /var/run/xinetd.pid
# config: /etc/sysconfig/network
# config: /etc/xinetd.conf

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

# Get config.
test -f /etc/sysconfig/network && . /etc/sysconfig/network

# Check that networking is up.
[ -z "$NETWORKING" -o "$NETWORKING" = "no" ] && exit 0

[ -e /usr/sbin/xinetd ] || exit 0
[ -f /etc/xinetd.conf ] || exit 0
RETVAL=0

start(){
    echo -n "Starte Internet-Dmon (xinetd): "
    daemon xinetd -reuse -pidfile /var/run/xinetd.pid
    RETVAL=$?
    echo
    touch /var/lock/subsys/xinetd
    return $RETVAL
}

stop(){
    echo -n "Stoppe Internet-Dmon (xinetd): "
    killproc xinetd
    RETVAL=$?
    echo
    rm -f /var/lock/subsys/xinetd
    return $RETVAL

}

reload(){
    echo -n "Neuladen der Konfiguration (xinetd): "	
    killproc xinetd -USR2
    RETVAL=$?
    echo
    return $RETVAL
}

restart(){
    stop
    start
}

condrestart(){
    [ -z "$DURING_INSTALL" ] && [ -e /var/lock/subsys/xinetd ] && restart
    return 0
}


# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	status xinetd
	;;
 restart)
	restart
	;;
  reload)
	reload
	;;
  condrestart)
	condrestart
	;;
  probe)
	;;
  *)
	echo "Benutzung: xinetd {start|stop|status|restart|condrestart|reload}"
	RETVAL=1
esac

exit $RETVAL

