#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-servers/mini_httpd/files/mini_httpd.init,v 1.2 2007/08/26 21:20:21 bangert Exp $

pidfile=/var/run/mini_httpd/${SVCNAME}.pid

depend() {
	need net
	after firewall
}

start() {
	local logfile=$(awk -F= '$1 == "logfile" { print $2 }' /etc/mini_httpd/${SVCNAME}.conf 2>/dev/null)
	: ${logfile:=/var/log/mini_httpd/${SVCNAME}.log}
	checkpath -d ${pidfile%/*}
	checkpath -d ${logfile%/*}
	ebegin "Starting $SVCNAME"
	start-stop-daemon --quiet --start --exec /usr/sbin/mini_httpd \
		--pidfile $pidfile -- -i $pidfile \
		${MINI_HTTPD_OPTS:--C /etc/mini_httpd/${SVCNAME}.conf -l ${logfile}}
	eend $?
}

stop() {
	ebegin "Stopping $SVCNAME"
	start-stop-daemon --quiet --stop --pidfile $pidfile
	eend $?
}

