#!/bin/sh
#
# $NetBSD: mediatomb.sh,v 1.4 2021/08/30 21:49:00 khorben Exp $
#
# PROVIDE: mediatomb
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# You will need to set some variables in /usr/pkg/etc/mediatomb/rc.conf to start mediatomb:
#
# mediatomb=YES

if [ -f /etc/rc.subr ]; then
	. /etc/rc.subr
	load_rc_config_var mediatomb_username mediatomb_username
	load_rc_config_var mediatomb_groupname mediatomb_groupname
fi

name="mediatomb"
rcvar=$name
command="/usr/pkg/bin/mediatomb"
logfile="/var/log/${name}.log"
pidfile="/var/mediatomb/${name}.pid"
command_args="-d -u ${mediatomb_username:-mediatomb} -g ${mediatomb_groupname:-mediatomb} -m /var/mediatomb -P ${pidfile} -l ${logfile} -c /usr/pkg/etc/mediatomb/config.xml"
extra_commands="reload"

if [ -f /etc/rc.subr ]; then
	load_rc_config $name
	run_rc_command "$1"
else
	echo -n "${name}"
	${command} ${mediatomb_flags} ${command_args}
fi
