Changeset View
Changeset View
Standalone View
Standalone View
libexec/rc/rc.subr
Show First 20 Lines • Show All 798 Lines • ▼ Show 20 Lines | |||||
# Requires /usr to be mounted. | # Requires /usr to be mounted. | ||||
# | # | ||||
# ${name}_groups n Comma separated list of supplementary groups | # ${name}_groups n Comma separated list of supplementary groups | ||||
# to run the chrooted ${command} with. | # to run the chrooted ${command} with. | ||||
# Requires /usr to be mounted. | # Requires /usr to be mounted. | ||||
# | # | ||||
# ${name}_prepend n Command added before ${command}. | # ${name}_prepend n Command added before ${command}. | ||||
# | # | ||||
# ${name}_setup n Command executed before ${command}. | |||||
# | |||||
# ${name}_login_class n Login class to use, else "daemon". | # ${name}_login_class n Login class to use, else "daemon". | ||||
# | # | ||||
# ${name}_limits n limits(1) to apply to ${command}. | # ${name}_limits n limits(1) to apply to ${command}. | ||||
# | # | ||||
# ${rc_arg}_cmd n If set, use this as the method when invoked; | # ${rc_arg}_cmd n If set, use this as the method when invoked; | ||||
# Otherwise, use default command (see below) | # Otherwise, use default command (see below) | ||||
# | # | ||||
# ${rc_arg}_precmd n If set, run just before performing the | # ${rc_arg}_precmd n If set, run just before performing the | ||||
▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | run_rc_command() | ||||
else | else | ||||
eval rc_flags=\$${name}_flags | eval rc_flags=\$${name}_flags | ||||
fi | fi | ||||
eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \ | eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \ | ||||
_nice=\$${name}_nice _user=\$${name}_user \ | _nice=\$${name}_nice _user=\$${name}_user \ | ||||
_group=\$${name}_group _groups=\$${name}_groups \ | _group=\$${name}_group _groups=\$${name}_groups \ | ||||
_fib=\$${name}_fib _env=\$${name}_env \ | _fib=\$${name}_fib _env=\$${name}_env \ | ||||
_prepend=\$${name}_prepend _login_class=\${${name}_login_class:-daemon} \ | _prepend=\$${name}_prepend _login_class=\${${name}_login_class:-daemon} \ | ||||
_limits=\$${name}_limits _oomprotect=\$${name}_oomprotect \ | _limits=\$${name}_limits _oomprotect=\$${name}_oomprotect \ | ||||
_env_file=\$${name}_env_file | _setup=\$${name}_setup _env_file=\$${name}_env_file | ||||
if [ -n "$_env_file" ] && [ -r "${_env_file}" ]; then # load env from file | if [ -n "$_env_file" ] && [ -r "${_env_file}" ]; then # load env from file | ||||
set -a | set -a | ||||
. $_env_file | . $_env_file | ||||
set +a | set +a | ||||
fi | fi | ||||
if [ -n "$_user" ]; then # unset $_user if running as that user | if [ -n "$_user" ]; then # unset $_user if running as that user | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | $command $rc_flags $command_args" | ||||
fi | fi | ||||
_doit="nice -n $_nice $_doit" | _doit="nice -n $_nice $_doit" | ||||
fi | fi | ||||
if [ -n "$_prepend" ]; then | if [ -n "$_prepend" ]; then | ||||
_doit="$_prepend $_doit" | _doit="$_prepend $_doit" | ||||
fi | fi | ||||
fi | fi | ||||
if [ -n "$_setup" ]; then | |||||
if ! _run_rc_doit "$_setup"; then | |||||
warn "failed to setup ${name}" | |||||
jlduran_gmail.com: I wonder if `check_startmsgs && warn...` should be prepended. | |||||
franco_opnsense.orgAuthorUnsubmitted Done Inline ActionsDoesn't seem to be a practice with "warn". Only for raw echo in non-error condition. Wouldn't want to start that trend also for risk of hiding relevant information in some cases. franco_opnsense.org: Doesn't seem to be a practice with "warn". Only for raw echo in non-error condition. Wouldn't… | |||||
fi | |||||
fi | |||||
# Prepend default limits | # Prepend default limits | ||||
_doit="$_cd limits -C $_login_class $_limits $_doit" | _doit="$_cd limits -C $_login_class $_limits $_doit" | ||||
# run the full command | # run the full command | ||||
# | # | ||||
if ! _run_rc_doit "$_doit"; then | if ! _run_rc_doit "$_doit"; then | ||||
warn "failed to start ${name}" | warn "failed to start ${name}" | ||||
return 1 | return 1 | ||||
▲ Show 20 Lines • Show All 1,022 Lines • ▼ Show 20 Lines | else | ||||
eval _rc_cache_kern_features_$1=1 | eval _rc_cache_kern_features_$1=1 | ||||
return 1 | return 1 | ||||
fi | fi | ||||
} | } | ||||
# check_namevarlist var | # check_namevarlist var | ||||
# Return "0" if ${name}_var is reserved in rc.subr. | # Return "0" if ${name}_var is reserved in rc.subr. | ||||
_rc_namevarlist="program chroot chdir env flags fib nice user group groups prepend" | _rc_namevarlist="program chroot chdir env flags fib nice user group groups prepend setup" | ||||
check_namevarlist() | check_namevarlist() | ||||
{ | { | ||||
local _v | local _v | ||||
for _v in $_rc_namevarlist; do | for _v in $_rc_namevarlist; do | ||||
case $1 in | case $1 in | ||||
$_v) return 0 ;; | $_v) return 0 ;; | ||||
esac | esac | ||||
Show All 35 Lines |
I wonder if check_startmsgs && warn... should be prepended.