FreeBSD rc(8) service scripts
This commit is contained in:
parent
4c5a795a3b
commit
b66be32e8b
39
packaging/rc.d/albatross_console
Executable file
39
packaging/rc.d/albatross_console
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
|
||||
# $FreeBSD$
|
||||
#
|
||||
# PROVIDE: albatross_console
|
||||
# REQUIRE: LOGIN
|
||||
# KEYWORD: shutdown nojail
|
||||
#
|
||||
# Define these albatross_console_* variables in one of these files
|
||||
# /etc/rc.conf
|
||||
# /etc/rc.conf.local
|
||||
# /etc/rc.conf.d/albatross_console
|
||||
# /usr/local/etc/rc.conf.d/albatross_console
|
||||
#
|
||||
# albatross_console_flags:
|
||||
# Default: ""
|
||||
#
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name=albatross_console
|
||||
rcvar=${name}_enable
|
||||
desc="Albatross console service"
|
||||
load_rc_config $name
|
||||
start_cmd="albatross_console_start"
|
||||
|
||||
: ${albatross_console_enable:="NO"}
|
||||
: ${albatross_console_flags:=""}
|
||||
: ${albatross_console_user:="albatross"}
|
||||
|
||||
pidfile="/var/run/albatross_console.pid"
|
||||
procname="/usr/local/libexec/albatross/vmm_console"
|
||||
|
||||
albatross_console_start () {
|
||||
/usr/sbin/daemon -p "${pidfile}" -u "${albatross_console_user}" -S \
|
||||
"${procname}" "${albatross_console_flags}"
|
||||
}
|
||||
|
||||
run_rc_command "$1"
|
74
packaging/rc.d/albatross_daemon
Executable file
74
packaging/rc.d/albatross_daemon
Executable file
|
@ -0,0 +1,74 @@
|
|||
#!/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 -o "{albatross_daemon_output}" -p "${pidfile}" \
|
||||
"${procname}" "${albatross_daemon_flags}"
|
||||
}
|
||||
|
||||
run_rc_command "$1"
|
47
packaging/rc.d/albatross_log
Executable file
47
packaging/rc.d/albatross_log
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/bin/sh
|
||||
|
||||
# $FreeBSD$
|
||||
#
|
||||
# PROVIDE: albatross_log
|
||||
# REQUIRE: LOGIN
|
||||
# KEYWORD: shutdown nojail
|
||||
#
|
||||
# Define these albatross_log_* variables in one of these files
|
||||
# /etc/rc.conf
|
||||
# /etc/rc.conf.local
|
||||
# /etc/rc.conf.d/albatross_log
|
||||
# /usr/local/etc/rc.conf.d/albatross_log
|
||||
#
|
||||
# albatross_log_flags:
|
||||
# Default: ""
|
||||
#
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name=albatross_log
|
||||
rcvar=${name}_enable
|
||||
desc="Albatross log service"
|
||||
load_rc_config $name
|
||||
start_cmd="albatross_log_start"
|
||||
start_precmd="albatross_log_precmd"
|
||||
|
||||
: ${albatross_log_enable:="NO"}
|
||||
: ${albatross_log_flags:=""}
|
||||
: ${albatross_log_user:="albatross"}
|
||||
|
||||
pidfile="/var/run/albatross_log.pid"
|
||||
procname="/usr/local/libexec/albatross/vmm_log"
|
||||
logfile="/var/log/albatross"
|
||||
|
||||
albatross_log_precmd () {
|
||||
[ -e "${logfile}" ] ||
|
||||
install -g ${albatross_log_user} -o ${albatross_log_user} \
|
||||
-- /dev/null "${logfile}";
|
||||
}
|
||||
|
||||
albatross_log_start () {
|
||||
/usr/sbin/daemon -S -p "${pidfile}" -u "${albatross_log_user}" \
|
||||
"${procname}" "${albatross_log_flags}"
|
||||
}
|
||||
|
||||
run_rc_command "$1"
|
39
packaging/rc.d/albatross_stat
Executable file
39
packaging/rc.d/albatross_stat
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
|
||||
# $FreeBSD$
|
||||
#
|
||||
# PROVIDE: albatross_stat
|
||||
# REQUIRE: LOGIN
|
||||
# KEYWORD: shutdown nojail
|
||||
#
|
||||
# Define these albatross_stat_* variables in one of these files
|
||||
# /etc/rc.conf
|
||||
# /etc/rc.conf.local
|
||||
# /etc/rc.conf.d/albatross_stat
|
||||
# /usr/local/etc/rc.conf.d/albatross_stat
|
||||
#
|
||||
# albatross_stat_flags:
|
||||
# Default: ""
|
||||
#
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name=albatross_stat
|
||||
rcvar=${name}_enable
|
||||
desc="Albatross stat service"
|
||||
load_rc_config $name
|
||||
start_cmd="albatross_stat_start"
|
||||
|
||||
: ${albatross_stat_enable:="NO"}
|
||||
: ${albatross_stat_flags:=""}
|
||||
: ${albatross_stat_user:="albatross"}
|
||||
|
||||
pidfile="/var/run/albatross_stat.pid"
|
||||
procname="/usr/local/libexec/albatross/vmm_stats_lwt"
|
||||
|
||||
albatross_stat_start () {
|
||||
/usr/sbin/daemon -S -p "${pidfile}" -u "${albatross_stat_user}" \
|
||||
"${procname}" "${albatross_stat_flags}"
|
||||
}
|
||||
|
||||
run_rc_command "$1"
|
72
packaging/rc.d/albatross_x
Executable file
72
packaging/rc.d/albatross_x
Executable file
|
@ -0,0 +1,72 @@
|
|||
#!/bin/sh
|
||||
|
||||
# $FreeBSD$
|
||||
#
|
||||
# PROVIDE: albatross_x
|
||||
# REQUIRE: LOGIN albatross_daemon
|
||||
# KEYWORDS: shutdown nojail
|
||||
#
|
||||
# Define these albatross_x_* variables in one of these files
|
||||
# /etc/rc.conf
|
||||
# /etc/rc.conf.local
|
||||
# /etc/rc.conf.d/albatross_x
|
||||
# /usr/local/etc/rc.conf.d/albatross_x
|
||||
#
|
||||
# albatross_x_enable: Set YES to enable the albatross vm start service
|
||||
# Default: NO
|
||||
# albatross_x_vms: list of vms to manage
|
||||
# Default: ""
|
||||
# albatross_x_args_$VM: vm create arguments
|
||||
#
|
||||
#
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name=albatross_x
|
||||
rcvar=${name}_enable
|
||||
desc="Manage Albatross VMs"
|
||||
load_rc_config $name
|
||||
start_cmd="albatross_x_start"
|
||||
stop_cmd="albatross_x_stop"
|
||||
status_cmd="albatross_x_status"
|
||||
extra_commands="status"
|
||||
|
||||
: ${albatross_x_enable:="NO"}
|
||||
: ${albatross_x_vms:=""}
|
||||
|
||||
albatross_x_start () {
|
||||
case $1 in
|
||||
_ALL)
|
||||
for _vm in $albatross_x_vms; do
|
||||
eval _create_args=\"\$albatross_x_args_${_vm}\"
|
||||
/usr/local/sbin/vmmc create $_vm $_create_args
|
||||
done
|
||||
return
|
||||
;;
|
||||
esac
|
||||
for _vm in $@; do
|
||||
eval _create_args=\"\$albatross_x_args_${_vm}\"
|
||||
/usr/local/sbin/vmmc create $_vm $_create_args
|
||||
done
|
||||
}
|
||||
|
||||
albatross_x_stop () {
|
||||
case $1 in
|
||||
ALL)
|
||||
for _vm in $albatross_x_vms
|
||||
do /usr/local/sbin/vmmc destroy $_vm; done
|
||||
return
|
||||
esac
|
||||
for _vm in $@
|
||||
do /usr/local/sbin/vmmc destroy $_vm; done
|
||||
}
|
||||
|
||||
albatross_x_status () {
|
||||
/usr/local/sbin/vmmc info
|
||||
}
|
||||
|
||||
case $# in
|
||||
1) run_rc_command $@ ${albatross_x_list:-_ALL} ;;
|
||||
*) run_rc_command $@ ;;
|
||||
esac
|
||||
|
Loading…
Reference in a new issue