Date: Mon, 21 Oct 2013 08:49:47 +0000 (UTC) From: Hiroki Sato <hrs@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256835 - head/etc/rc.d Message-ID: <201310210849.r9L8nlgM052211@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hrs Date: Mon Oct 21 08:49:46 2013 New Revision: 256835 URL: http://svnweb.freebsd.org/changeset/base/256835 Log: - Fix jail_parallel_start="YES". - Fix ip[46].addr when interface parameter is not defined. Spotted by: rpaulo Modified: head/etc/rc.d/jail Modified: head/etc/rc.d/jail ============================================================================== --- head/etc/rc.d/jail Mon Oct 21 08:37:17 2013 (r256834) +++ head/etc/rc.d/jail Mon Oct 21 08:49:46 2013 (r256835) @@ -132,7 +132,9 @@ parse_options() # _confwarn=1 if [ -r "$jail_conf" -o -r "$_jconf" ]; then - warn "$_conf is created and used for jail $_j." + if ! checkyesno jail_parallel_start; then + warn "$_conf is created and used for jail $_j." + fi fi /usr/bin/install -m 0644 -o root -g wheel /dev/null $_conf || return 1 @@ -367,10 +369,10 @@ jail_handle_ips_option() # Append address to list of addresses for the jail command. case $_type in inet) - echo " ip4.addr += \"${_iface}|${_addr}${_mask}\";" + echo " ip4.addr += \"${_iface:+${_iface}|}${_addr}${_mask}\";" ;; inet6) - echo " ip6.addr += \"${_iface}|${_addr}${_mask}\";" + echo " ip6.addr += \"${_iface:+${_iface}|}${_addr}${_mask}\";" need_dad_wait=1 ;; esac @@ -418,7 +420,7 @@ jail_status() jail_start() { - local _j _jid _jn + local _j _jid _jn _jl if [ $# = 0 ]; then return @@ -446,30 +448,62 @@ jail_start() return ;; esac - for _j in $@; do - _j=$(echo $_j | tr /. _) - parse_options $_j || continue - - eval rc_flags=\${jail_${_j}_flags:-$jail_flags} - eval command=\${jail_${_j}_program:-$jail_program} - if checkyesno jail_parallel_start; then - command_args="-i -f $_conf -c $_j &" - else + if checkyesno jail_parallel_start; then + # + # Start jails in parallel and then check jail id when + # jail_parallel_start is YES. + # + _jl= + for _j in $@; do + _j=$(echo $_j | tr /. _) + parse_options $_j || continue + + _jl="$_jl $_j" + eval rc_flags=\${jail_${_j}_flags:-$jail_flags} + eval command=\${jail_${_j}_program:-$jail_program} command_args="-i -f $_conf -c $_j" - fi - _tmp=`mktemp -t jail` || exit 3 - if $command $rc_flags $command_args \ - >> $_tmp 2>&1 </dev/null; then + $command $rc_flags $command_args \ + >/dev/null 2>&1 </dev/null & + done + sleep 1 + for _j in $_jl; do echo -n " ${_hostname:-${_j}}" - _jid=$($jail_jls -n -j $_j | tr " " "\n" | grep ^jid=) - echo "${_jid#jid=}" > /var/run/jail_${_j}.id - else - rm -f /var/run/jail_${_j}.id - echo " cannot start jail \"${_hostname:-${_j}}\": " - cat $_tmp - fi - rm -f $_tmp - done + if _jid=$($jail_jls -n -j $_j | tr " " "\n" | \ + grep ^jid=); then + echo "${_jid#jid=}" > /var/run/jail_${_j}.id + else + rm -f /var/run/jail_${_j}.id + echo " cannot start jail " \ + "\"${_hostname:-${_j}}\": " + fi + done + else + # + # Start jails one-by-one when jail_parallel_start is NO. + # + for _j in $@; do + _j=$(echo $_j | tr /. _) + parse_options $_j || continue + + eval rc_flags=\${jail_${_j}_flags:-$jail_flags} + eval command=\${jail_${_j}_program:-$jail_program} + command_args="-i -f $_conf -c $_j" + _tmp=`mktemp -t jail` || exit 3 + if $command $rc_flags $command_args \ + >> $_tmp 2>&1 </dev/null; then + echo -n " ${_hostname:-${_j}}" + _jid=$($jail_jls -n -j $_j | \ + tr " " "\n" | grep ^jid=) + echo "${_jid#jid=}" > /var/run/jail_${_j}.id + else + rm -f /var/run/jail_${_j}.id + echo " cannot start jail " \ + "\"${_hostname:-${_j}}\": " + cat $_tmp + fi + rm -f $_tmp + done + fi echo '.' }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310210849.r9L8nlgM052211>