mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-19 15:33:56 +00:00
Add jail_<jname>_exec_afterstart<N> rc.conf variable, where <N> is
1,2 and so on. It specifies the command to be run as Nth after jail startup. sh(1)-fu by: Dario Freni PR: conf/97697 MFC after: 2 weeks Reviewed by: ru@ (man page)
This commit is contained in:
parent
200ea54812
commit
ce5c66f0b2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=159072
@ -546,6 +546,9 @@ jail_sysvipc_allow="NO" # Allow SystemV IPC use from within a jail
|
||||
#jail_example_ip="192.168.0.10" # Jail's IP number
|
||||
#jail_example_interface="" # Interface to create the IP alias on
|
||||
#jail_example_exec_start="/bin/sh /etc/rc" # command to execute in jail for starting
|
||||
#jail_example_exec_afterstart0="/bin/sh command" # command to execute after the one for
|
||||
# starting the jail. More than one can be
|
||||
# specified using a trailing number
|
||||
#jail_example_exec_stop="/bin/sh /etc/rc.shutdown" # command to execute in jail for stopping
|
||||
#jail_example_devfs_enable="NO" # mount devfs in the jail
|
||||
#jail_example_fdescfs_enable="NO" # mount fdescfs in the jail
|
||||
|
@ -36,6 +36,14 @@ init_variables()
|
||||
eval _interface=\"\${jail_${_j}_interface:-${jail_interface}}\"
|
||||
eval _exec=\"\$jail_${_j}_exec\"
|
||||
eval _exec_start=\"\${jail_${_j}_exec_start:-${jail_exec_start}}\"
|
||||
|
||||
i=1
|
||||
while [ true ]; do
|
||||
eval _exec_afterstart${i}=\"\${jail_${_j}_exec_afterstart${i}:-\${jail_exec_afterstart${i}}}\"
|
||||
[ -z "$(eval echo \"\$_exec_afterstart${i}\")" ] && break
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
eval _exec_stop=\"\${jail_${_j}_exec_stop:-${jail_exec_stop}}\"
|
||||
if [ -n "${_exec}" ]; then
|
||||
# simple/backward-compatible execution
|
||||
@ -84,6 +92,19 @@ init_variables()
|
||||
debug "$_j ruleset: $_ruleset"
|
||||
debug "$_j fstab: $_fstab"
|
||||
debug "$_j exec start: $_exec_start"
|
||||
|
||||
i=1
|
||||
while [ true ]; do
|
||||
eval out=\"\${_exec_afterstart${i}:-''}\"
|
||||
|
||||
if [ -z "$out" ]; then
|
||||
break;
|
||||
fi
|
||||
|
||||
debug "$_j exec after start #${i}: ${out}"
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
debug "$_j exec stop: $_exec_stop"
|
||||
debug "$_j flags: $_flags"
|
||||
|
||||
@ -221,9 +242,22 @@ jail_start()
|
||||
_tmp_jail=${_tmp_dir}/jail.$$
|
||||
eval jail ${_flags} -i ${_rootdir} ${_hostname} \
|
||||
${_ip} ${_exec_start} > ${_tmp_jail} 2>&1
|
||||
|
||||
if [ "$?" -eq 0 ] ; then
|
||||
echo -n " $_hostname"
|
||||
_jail_id=$(head -1 ${_tmp_jail})
|
||||
i=1
|
||||
while [ true ]; do
|
||||
eval out=\"\${_exec_afterstart${i}:-''}\"
|
||||
|
||||
if [ -z "$out" ]; then
|
||||
break;
|
||||
fi
|
||||
|
||||
jexec "${_jail_id}" ${out}
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
echo -n " $_hostname"
|
||||
tail +2 ${_tmp_jail} >${_rootdir}/var/log/console.log
|
||||
echo ${_jail_id} > /var/run/jail_${_jail}.id
|
||||
else
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd May 18, 2006
|
||||
.Dd May 29, 2006
|
||||
.Dt RC.CONF 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -3085,6 +3085,13 @@ When set, use as default value for
|
||||
.Va jail_ Ns Ao Ar jname Ac Ns Va _exec_start
|
||||
for every jail in
|
||||
.Va jail_list .
|
||||
.It Va jail_exec_afterstart Ns Aq Ar N
|
||||
.Pq Vt str
|
||||
Unset by default.
|
||||
When set, use as default value for
|
||||
.Va jail_ Ns Ao Ar jname Ac Ns Va _exec_afterstart Ns Aq Ar N
|
||||
for every jail in
|
||||
.Va jail_list .
|
||||
.It Va jail_exec_stop
|
||||
Unset by default.
|
||||
When set, use as default value for
|
||||
@ -3176,6 +3183,15 @@ Set to
|
||||
.Dq Li /bin/sh /etc/rc
|
||||
by default.
|
||||
This is the command executed at jail startup.
|
||||
.It Va jail_ Ns Ao Ar jname Ac Ns Va _exec_afterstart Ns Aq Ar N
|
||||
.Pq Vt str
|
||||
Unset by default.
|
||||
This is the command run as
|
||||
.Ar N Ns
|
||||
th command
|
||||
after jail startup, where
|
||||
.Ar N
|
||||
is 1, 2, and so on.
|
||||
.It Va jail_ Ns Ao Ar jname Ac Ns Va _exec_stop
|
||||
.Pq Vt str
|
||||
Set to
|
||||
|
Loading…
Reference in New Issue
Block a user