summaryrefslogtreecommitdiffstats
path: root/etc/rc.subr
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2014-10-11 23:49:27 +0000
committerhrs <hrs@FreeBSD.org>2014-10-11 23:49:27 +0000
commit77616d41a2ce3744b35e68b8a3c12e562283a322 (patch)
tree1e45e42ee8d99023b0f6c457b00dc7c6585aec31 /etc/rc.subr
parentfde7fd8dbcdd9c7f5d0a8afeee07de8f2ecf4921 (diff)
downloadFreeBSD-src-77616d41a2ce3744b35e68b8a3c12e562283a322.zip
FreeBSD-src-77616d41a2ce3744b35e68b8a3c12e562283a322.tar.gz
Add ${name}_env and ${name}_prepend. ${name}_env is an argument list which
will be passed to env(1). ${name}_prepend is simply prepended to the command line for $command.
Diffstat (limited to 'etc/rc.subr')
-rw-r--r--etc/rc.subr12
1 files changed, 11 insertions, 1 deletions
diff --git a/etc/rc.subr b/etc/rc.subr
index 4b3fddf..387b909 100644
--- a/etc/rc.subr
+++ b/etc/rc.subr
@@ -749,6 +749,8 @@ check_startmsgs()
# NOTE: $flags from the parent environment
# can be used to override this.
#
+# ${name}_env n Environment variables to run ${command} with.
+#
# ${name}_fib n Routing table number to run ${command} with.
#
# ${name}_nice n Nice level to run ${command} at.
@@ -764,6 +766,8 @@ check_startmsgs()
# to run the chrooted ${command} with.
# Requires /usr to be mounted.
#
+# ${name}_prepend n Command added before ${command}.
+#
# ${rc_arg}_cmd n If set, use this as the method when invoked;
# Otherwise, use default command (see below)
#
@@ -937,7 +941,8 @@ run_rc_command()
eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \
_nice=\$${name}_nice _user=\$${name}_user \
_group=\$${name}_group _groups=\$${name}_groups \
- _fib=\$${name}_fib
+ _fib=\$${name}_fib _env=\$${name}_env \
+ _prepend=\$${name}_prepend
if [ -n "$_user" ]; then # unset $_user if running as that user
if [ "$_user" = "$(eval $IDCMD)" ]; then
@@ -1022,12 +1027,14 @@ run_rc_command()
_doit="\
${_nice:+nice -n $_nice }\
${_fib:+setfib -F $_fib }\
+${_env:+env $_env }\
chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
$_chroot $command $rc_flags $command_args"
else
_doit="\
${_chdir:+cd $_chdir && }\
${_fib:+setfib -F $_fib }\
+${_env:+env $_env }\
$command $rc_flags $command_args"
if [ -n "$_user" ]; then
_doit="su -m $_user -c 'sh -c \"$_doit\"'"
@@ -1038,6 +1045,9 @@ $command $rc_flags $command_args"
fi
_doit="nice -n $_nice $_doit"
fi
+ if [ -n "$_prepend" ]; then
+ _doit="$_prepend $_doit"
+ fi
fi
# run the full command
OpenPOWER on IntegriCloud