Changeset View
Changeset View
Standalone View
Standalone View
etc/rc.subr
Show First 20 Lines • Show All 740 Lines • ▼ Show 20 Lines | |||||
# ${command}. | # ${command}. | ||||
# | # | ||||
# ${name}_chroot n Directory to chroot to before running ${command} | # ${name}_chroot n Directory to chroot to before running ${command} | ||||
# Requires /usr to be mounted. | # Requires /usr to be mounted. | ||||
# | # | ||||
# ${name}_chdir n Directory to cd to before running ${command} | # ${name}_chdir n Directory to cd to before running ${command} | ||||
# (if not using ${name}_chroot). | # (if not using ${name}_chroot). | ||||
# | # | ||||
# ${name}_daemon n Arguments to pass to daemon(8) before | |||||
# running ${command}. | |||||
# | |||||
# ${name}_flags n Arguments to call ${command} with. | # ${name}_flags n Arguments to call ${command} with. | ||||
# NOTE: $flags from the parent environment | # NOTE: $flags from the parent environment | ||||
# can be used to override this. | # can be used to override this. | ||||
# | # | ||||
# ${name}_env n Environment variables to run ${command} with. | # ${name}_env n Environment variables to run ${command} with. | ||||
# | # | ||||
# ${name}_fib n Routing table number to run ${command} with. | # ${name}_fib n Routing table number to run ${command} with. | ||||
# | # | ||||
▲ Show 20 Lines • Show All 190 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} \ | ||||
_oomprotect=\$${name}_oomprotect | _oomprotect=\$${name}_oomprotect _daemon=\$${name}_daemon | ||||
if [ -n "$_user" ]; then # unset $_user if running as that user | if [ -n "$_user" ]; then # unset $_user if running as that user | ||||
if [ "$_user" = "$(eval $IDCMD)" ]; then | if [ "$_user" = "$(eval $IDCMD)" ]; then | ||||
unset _user | unset _user | ||||
fi | fi | ||||
fi | fi | ||||
[ -z "$autoboot" ] && eval $_pidcmd # determine the pid if necessary | [ -z "$autoboot" ] && eval $_pidcmd # determine the pid if necessary | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | start) | ||||
if ! _run_rc_precmd; then | if ! _run_rc_precmd; then | ||||
warn "failed precmd routine for ${name}" | warn "failed precmd routine for ${name}" | ||||
return 1 | return 1 | ||||
fi | fi | ||||
# setup the full command to run | # setup the full command to run | ||||
# | # | ||||
check_startmsgs && echo "Starting ${name}." | check_startmsgs && echo "Starting ${name}." | ||||
_doit="$command $rc_flags $command_args" | |||||
if [ -n "$_daemon" ]; then | |||||
_doit="daemon $_daemon $_doit" | |||||
fi | |||||
if [ -n "$_chroot" ]; then | if [ -n "$_chroot" ]; then | ||||
_doit="\ | _doit="\ | ||||
${_nice:+nice -n $_nice }\ | ${_nice:+nice -n $_nice }\ | ||||
${_fib:+setfib -F $_fib }\ | ${_fib:+setfib -F $_fib }\ | ||||
${_env:+env $_env }\ | ${_env:+env $_env }\ | ||||
chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\ | chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\ | ||||
$_chroot $command $rc_flags $command_args" | $_chroot $_doit" | ||||
else | else | ||||
_doit="\ | _doit="\ | ||||
${_chdir:+cd $_chdir && }\ | ${_chdir:+cd $_chdir && }\ | ||||
${_fib:+setfib -F $_fib }\ | ${_fib:+setfib -F $_fib }\ | ||||
${_env:+env $_env }\ | ${_env:+env $_env } $_doit" | ||||
$command $rc_flags $command_args" | |||||
if [ -n "$_user" ]; then | if [ -n "$_user" ]; then | ||||
_doit="su -m $_user -c 'sh -c \"$_doit\"'" | _doit="su -m $_user -c 'sh -c \"$_doit\"'" | ||||
fi | fi | ||||
if [ -n "$_nice" ]; then | if [ -n "$_nice" ]; then | ||||
if [ -z "$_user" ]; then | if [ -z "$_user" ]; then | ||||
_doit="sh -c \"$_doit\"" | _doit="sh -c \"$_doit\"" | ||||
fi | fi | ||||
_doit="nice -n $_nice $_doit" | _doit="nice -n $_nice $_doit" | ||||
▲ Show 20 Lines • Show All 1,103 Lines • Show Last 20 Lines |