#!/sbin/runscript
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

depend() {
	need net
}

checkconfig() {
	if [ ! -e /var/lib/ntop/ntop_pw.db ]; then
		eerror "You need to set a password first by running"
		eerror "ntop --set-admin-password"
		return 1
	fi
}

start() {
	checkconfig || return 1
	ebegin "Starting ntop"
	start-stop-daemon --start --exec /usr/bin/ntop -- -d -L ${NTOP_OPTS}
	eend $?
}

stop() {
	ebegin "Stopping ntop"
	start-stop-daemon --stop --retry 5 --pidfile /var/lib/ntop/ntop.pid
	eend $?
}
