rc.subr: Support loading environmental variables from a file
The current support for setting environment via foo_env="" in rc.conf is not scalable and does not handle envs with spaces in the value. It seems a common pattern for some newer software is to skip configuration files altogether and rely on the env. This is well supported in systemd unit files and may be the inspiration for this trend. MFH: 1 week Differential Revision: https://reviews.freebsd.org/D14453
This commit is contained in:
parent
13ee81bed5
commit
75a315f6d2
11
etc/rc.subr
11
etc/rc.subr
@ -754,6 +754,8 @@ check_startmsgs()
|
||||
#
|
||||
# ${name}_env n Environment variables to run ${command} with.
|
||||
#
|
||||
# ${name}_env_file n File to source variables to run ${command} with.
|
||||
#
|
||||
# ${name}_fib n Routing table number to run ${command} with.
|
||||
#
|
||||
# ${name}_nice n Nice level to run ${command} at.
|
||||
@ -954,7 +956,14 @@ run_rc_command()
|
||||
_group=\$${name}_group _groups=\$${name}_groups \
|
||||
_fib=\$${name}_fib _env=\$${name}_env \
|
||||
_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
|
||||
|
||||
if [ -n "$_env_file" ] && [ -r "${_env_file}" ]; then # load env from file
|
||||
set -a
|
||||
. $_env_file
|
||||
set +a
|
||||
fi
|
||||
|
||||
if [ -n "$_user" ]; then # unset $_user if running as that user
|
||||
if [ "$_user" = "$(eval $IDCMD)" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user