55 lines
986 B
Bash
55 lines
986 B
Bash
#!/bin/sh
|
|
|
|
# $FreeBSD$
|
|
#
|
|
# PROVIDE: hfm
|
|
# REQUIRE: LOGIN
|
|
# KEYWORD: shutdown
|
|
#
|
|
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
|
|
# to enable this service:
|
|
#
|
|
# hfm_enable (bool): Set to NO by default.
|
|
# Set it to YES to enable hfm.
|
|
#
|
|
# hfm_flags (bool): Check the sources of hfm for flags
|
|
#
|
|
|
|
. /etc/rc.subr
|
|
|
|
name="hfm"
|
|
rcvar="hfm_enable"
|
|
|
|
command="%%PREFIX%%/bin/${name}"
|
|
|
|
hfm_user="_hfm"
|
|
hfm_flags="${hfm_flags:-"-config %%ETCDIR%%/${name}.conf -facility local0 -log syslog"}"
|
|
|
|
pidfile="/var/run/${name}.pid"
|
|
|
|
required_files="%%ETCDIR%%/${name}.conf"
|
|
|
|
start_cmd="hfm_start"
|
|
restart_precmd="hfm_checkconfig"
|
|
configtest_cmd="hfm_checkconfig"
|
|
stop_postcmd="hfm_postcmd"
|
|
|
|
hfm_checkconfig() {
|
|
eval ${command} ${hfm_flags} -n
|
|
}
|
|
|
|
hfm_start() {
|
|
echo "Staring ${name}."
|
|
|
|
/usr/sbin/daemon -cf -u ${hfm_user} -p ${pidfile} ${command} ${hfm_flags}
|
|
}
|
|
|
|
hfm_postcmd() {
|
|
[ -f ${pidfile} ] && rm ${pidfile}
|
|
}
|
|
|
|
extra_commands="configtest"
|
|
load_rc_config "${name}"
|
|
run_rc_command "$1"
|
|
|