diff options
author | mtm <mtm@FreeBSD.org> | 2004-02-02 13:25:28 +0000 |
---|---|---|
committer | mtm <mtm@FreeBSD.org> | 2004-02-02 13:25:28 +0000 |
commit | 2d058bdea83e4855ab7023858637c1ab4d7642c2 (patch) | |
tree | 4021e6b5641adc014b4f2366664c44ab72403fa4 /etc | |
parent | 62a971f78f44ce84f95ca8fab82c9282c0177157 (diff) | |
download | FreeBSD-src-2d058bdea83e4855ab7023858637c1ab4d7642c2.zip FreeBSD-src-2d058bdea83e4855ab7023858637c1ab4d7642c2.tar.gz |
Support starting/stoping of jails individually.
This commit also removes the support for the sysutils/jailer port. This
is inline with the general policy to keep ports related knobs out
of the base system's configuration mechanism.
Submitted by: Juergen Unger <j.unger@addict.de>
Diffstat (limited to 'etc')
-rw-r--r-- | etc/defaults/rc.conf | 2 | ||||
-rw-r--r-- | etc/rc.d/jail | 37 |
2 files changed, 25 insertions, 14 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index dd60fe3..c1b9b7c 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -455,8 +455,6 @@ jail_list="" # Space separated list of names of jails jail_set_hostname_allow="YES" # Allow root user in a jail to change its hostname jail_socket_unixiproute_only="YES" # Route only TCP/IP within a jail jail_sysvipc_allow="NO" # Allow SystemV IPC use from within a jail -jail_stop_jailer="NO" # Only stop jailer. Requires jail_*_exec be set - # to use sysutils/jailer port to start the jail. # # To use rc's built-in jail infrastructure create entries for diff --git a/etc/rc.d/jail b/etc/rc.d/jail index 019e148..6de0071 100644 --- a/etc/rc.d/jail +++ b/etc/rc.d/jail @@ -124,25 +124,37 @@ jail_start() mount -t procfs proc "${jail_procdir}" fi fi - jail 1>${jail_rootdir}/var/log/console.log 2>&1 \ - ${jail_rootdir} ${jail_hostname} ${jail_ip} ${jail_exec} + _tmp_jail=/tmp/jail.$$ + jail -i ${jail_rootdir} ${jail_hostname} \ + ${jail_ip} ${jail_exec} > ${_tmp_jail} 2>&1 [ "$?" -eq 0 ] && echo -n " $jail_hostname" + _jail_id=$(head -1 ${_tmp_jail}) + tail +2 ${_tmp_jail} >${jail_rootdir}/var/log/console.log + rm -f ${_tmp_jail} + echo ${_jail_id} > /var/run/jail_${_jail}.id done echo '.' } jail_stop() { - echo 'Stopping all jails.' - if checkyesno jail_stop_jailer; then - rc_pid=$(ps aux | grep "jailer" | awk '$8 ~ /.*J/ {print $2};') - else - rc_pid=$(ps aux | awk '$8 ~ /.*J/ {print $2};') - fi - if [ -n "${rc_pid}" ]; then - kill -TERM $rc_pid - wait_for_pids $rc_pid - fi + echo 'Stopping jails.' + for _jail in ${jail_list} + do + if [ -f /var/run/jail_${_jail}.id ]; then + _jail_id=$(cat /var/run/jail_${_jail}.id) + if [ ! -z ${_jail_id} ]; then + killall -j ${_jail_id} -TERM > /dev/null 2>&1 + fi + rm /var/run/jail_${_jail}.id + else + echo "cannot stop jail ${_jail}. no jail id saved in /var/run" + jail_list=$(echo ${jail_list} | \ + tr ' ' '\n' | \ + grep -v "^${_jail}$" | \ + tr '\n' ' ') + fi + done for _jail in ${jail_list} do init_variables $_jail @@ -165,5 +177,6 @@ jail_stop() } +[ -n "$2" ] && jail_list="$2" load_rc_config $name run_rc_command "$1" |