summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authormatteo <matteo@FreeBSD.org>2006-05-30 16:20:48 +0000
committermatteo <matteo@FreeBSD.org>2006-05-30 16:20:48 +0000
commit54eed11bfc5d6960c75863372b9dfa9816e93edc (patch)
tree7871a254cc3a27d68c6b3a20268770175423cb4a /etc
parentbb69a4c72359a0776867cb699e6d3f3de51373a5 (diff)
downloadFreeBSD-src-54eed11bfc5d6960c75863372b9dfa9816e93edc.zip
FreeBSD-src-54eed11bfc5d6960c75863372b9dfa9816e93edc.tar.gz
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)
Diffstat (limited to 'etc')
-rw-r--r--etc/defaults/rc.conf3
-rw-r--r--etc/rc.d/jail36
2 files changed, 38 insertions, 1 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index 9698137..8a5f436 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -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
diff --git a/etc/rc.d/jail b/etc/rc.d/jail
index c2636b5..2e01fd8 100644
--- a/etc/rc.d/jail
+++ b/etc/rc.d/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
OpenPOWER on IntegriCloud