File rcntop of Package ntop

#! /bin/sh
# Copyright (c) 1995-2005 SUSE Linux Products GmbH
#
# Author: Remo Behn <ray@suse.de>
#
# /etc/init.d/ntop
#
### BEGIN INIT INFO
# Provides: ntop
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: ntop Network Monitor
# Description: Tool for monitoring the network usage.
### END INIT INFO
PROGRAM=/usr/bin/ntop
CONFFILE="/etc/sysconfig/ntop"

. /etc/rc.status
if [ -f $CONFFILE ]; then
	. $CONFFILE
else
	echo "Config file $CONFFILE not found. "
	rc_status -s
	exit 6
fi

function setup_options()
{
	# use default options
	NTOP_OPTIONS="-P /var/lib/ntop"
	# define the NTOP_IFACE
	if [ -n "$NTOPD_IFACE" ]; then
		NTOP_OPTIONS="$NTOP_OPTIONS -i $NTOPD_IFACE"
	else
		rc_failed 6
		rc_status -v
		exit 6
	fi
	# setup the user to run ntop
	if [ -n "$NTOP_USER" ]; then
		NTOP_OPTIONS="$NTOP_OPTIONS -u $NTOP_USER"
	else
		rc_failed 6
		rc_status -v
		exit 6
	fi
	# setup port
	if [ -n "$NTOPD_PORT" -o -n "$NTOPD_SSL_PORT" ]; then
		if [ -n "$NTOPD_PORT" ]; then
			NTOP_OPTIONS="$NTOP_OPTIONS -w $NTOPD_PORT"
		fi
		if [ -n "$NTOPD_SSL_PORT" ]; then
			NTOP_OPTIONS="$NTOP_OPTIONS -W $NTOPD_SSL_PORT"
		fi
	else
                rc_failed 6
                rc_status -v
                exit 6
        fi
	# use optional
	test -n "${NTOP_ARGS}" && NTOP_OPTIONS="${NTOP_OPTIONS} ${NTOP_ARGS}"
}



# The echo return value for success (defined in /etc/rc.config).
return=$rc_done
case "$1" in
    start)
	echo -n "Starting service ntop "
	##
	if checkproc /usr/bin/ntop; then
		echo -e -n "\nntop is already running."
		rc_status -s
		exit
	fi
	## Start daemon with startproc(8). If this fails
	## the echo return value is set appropriate.
	if ! /usr/sbin/passcheck ; then
		echo -e -n "\nntop admin password is not yet set. " 
		echo -e -n "Run \n\t\033[1mntop -A -u $NTOP_USER\033[m\nmanually "
		rc_status -u
		exit
	else
		if [ -z $NTOP_OPTIONS ]; then
			setup_options
		fi
		startproc -q $PROGRAM $NTOP_OPTIONS
	fi

	rc_status -v
	;;
    stop)
	echo -n "Shutting down service ntop "
	## Stop daemon with killproc(8) and if this fails
	## set echo the echo return value.

	killproc -TERM $PROGRAM

	rc_status -v
	;;
    try-restart)
	$0 status
	if test $? = 0; then
	    $0 restart
	else
	    rc_reset
	fi
	rc_status
	;;
    restart)
	$0 stop
	$0 start
	rc_status
	;;
    reload|force-reload)
	echo -n "Reload service ntop "
	killproc -HUP $PROGRAM
	rc_status -v
	;;
    status)
	echo -n "Checking for service ntop: "
	## Check status with checkproc(8), if process is running
	## checkproc will return with exit status 0.

	checkproc $PROGRAM
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|restart|reload|force-reload|status|try-restart}"
	exit 1
	;;
esac
rc_exit

openSUSE Build Service is sponsored by