#!/bin/ksh
#
# $OpenBSD: thttpd.rc,v 1.2 2018/01/11 19:27:12 rpe Exp $

daemon="/usr/local/sbin/thttpd"

. /etc/rc.d/rc.subr

# The /var/www root directory will be overridden by any -d flag the user
# supplies. This addresses the awkward fact that thttpd defaults to the
# current working directory.
rc_start() {
	${rcexec} "cd /var/www; ${daemon} ${daemon_flags}"
}

# SIGUSR1 allows all existing connections to terminate before exiting.
rc_stop() {
	pkill -USR1 -xf "^${pexp}"
}

rc_cmd $1
