albatross/packaging/rc.d/albatross_daemon
Stefan Grundmann fb149952de FreeBSD rc scripts: do not quote albatross_*_flags in daemon(8) call
the various /usr/local/libexec/albatross/vmmd* programs are not
happy when called with argv[1] set to an empty string ...
which is what happens if albatross_*_flags is the default value
2018-11-08 07:51:37 +00:00

75 lines
1.9 KiB
Bash
Executable file

#!/bin/sh
# $FreeBSD$
#
# PROVIDE: albatross_daemon
# REQUIRE: LOGIN albatross_console albatross_log albatross_stat
# KEYWORD: shutdown nojail
#
# Define these albatross_daemon_* variables in one of these files
# /etc/rc.conf
# /etc/rc.conf.local
# /etc/rc.conf.d/albatross_daemon
# /usr/local/etc/rc.conf.d/albatross_daemon
#
# albatross_daemon_enable: Set YES to enable the albatross daemon service
# Default: NO
# albatross_daemon_flags:
# Default: ""
#
#
. /etc/rc.subr
name=albatross_daemon
rcvar=${name}_enable
desc="Albatross service"
load_rc_config $name
start_cmd="albatross_daemon_start"
start_precmd="albatross_daemon_precmd"
: ${albatross_daemon_enable:="NO"}
: ${albatross_daemon_flags:=""}
pidfile="/var/run/albatross_daemon.pid"
procname="/usr/local/libexec/albatross/vmmd"
#
# force_depend script [rcvar]
# Force a service to start. Intended for use by services
# to resolve dependency issues.
# $1 - filename of script, in /usr/local/etc/rc.d, to run
# $2 - name of the script's rcvar (minus the _enable)
#
my_force_depend()
{
local _depend _dep_rcvar
_depend="$1"
_dep_rcvar="${2:-$1}_enable"
[ -n "$rc_fast" ] && ! checkyesno always_force_depends &&
checkyesno $_dep_rcvar && return 0
/usr/local/etc/rc.d/${_depend} forcestatus >/dev/null 2>&1 && return 0
info "${name} depends on ${_depend}, which will be forced to start."
if ! /usr/local/etc/rc.d/${_depend} forcestart; then
warn "Unable to force ${_depend}. It may already be running."
return 1
fi
}
albatross_daemon_precmd() {
my_force_depend albatross_console || err 1 "Cannot run albatross_console"
my_force_depend albatross_log || err 1 "Cannot run albatross_log"
my_force_depend albatross_stat || err 1 "Cannot run albatross_stat"
}
albatross_daemon_start () {
/usr/sbin/daemon -S -p "${pidfile}" "${procname}" \
${albatross_daemon_flags}
}
run_rc_command "$1"