75 lines
1.7 KiB
Bash
75 lines
1.7 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
|
|
# PROVIDE: fastd
|
|
# REQUIRE: DAEMON
|
|
# KEYWORD: shutdown
|
|
|
|
# -----------------------------------------------------------------------------
|
|
#
|
|
# This script supports running multiple instances of fastd.
|
|
# To run additional instances link this script to something like
|
|
# % ln -s fastd fastd_foo
|
|
# and define additional fastd_foo_* variables in one of
|
|
# /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/fastd_foo
|
|
#
|
|
# Below NAME should be substituted with the name of this script. By default
|
|
# it is fastd, so read as fastd_enable. If you linked the script to
|
|
# fastd_foo, then read as fastd_foo_enable etc.
|
|
#
|
|
# The following variables are supported (defaults are shown).
|
|
# You can place them in any of
|
|
# /etc/rc.conf, /etc/rc.conf.local or /etc/rc.conf.d/NAME
|
|
#
|
|
# NAME_enable="NO" # set to YES to enable fastd
|
|
#
|
|
# # optional:
|
|
# NAME_configfile="%%PREFIX%%/etc/fastd/NAME.conf" # --config file
|
|
#
|
|
|
|
. /etc/rc.subr
|
|
|
|
case "$0" in
|
|
/etc/rc*)
|
|
# during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
|
|
# so get the name of the script from $_file
|
|
name="$_file"
|
|
;;
|
|
*)
|
|
name="$0"
|
|
;;
|
|
esac
|
|
|
|
name="${name##*/}"
|
|
rcvar=${name}_enable
|
|
|
|
clean_pidfile()
|
|
{
|
|
rm -f "$pidfile" || warn "Could not remove $pidfile."
|
|
}
|
|
|
|
# reload: support SIGHUP to reload peer directories
|
|
extra_commands="reload"
|
|
|
|
# pidfile
|
|
pidfile="/var/run/${name}.pid"
|
|
|
|
# run this last
|
|
start_precmd="clean_pidfile"
|
|
stop_postcmd="clean_pidfile"
|
|
|
|
load_rc_config ${name}
|
|
|
|
eval ": \${${name}_enable:=\"NO\"}"
|
|
eval ": \${${name}_configfile:=\"%%PREFIX%%/etc/fastd/${name}.conf\"}"
|
|
|
|
configfile="$(eval echo \${${name}_configfile})"
|
|
|
|
required_files=${configfile}
|
|
|
|
# command and arguments
|
|
command="%%PREFIX%%/bin/fastd"
|
|
command_args="--daemon --config ${configfile} --pid-file ${pidfile}"
|
|
|
|
run_rc_command "$1"
|