From owner-svn-src-head@FreeBSD.ORG Fri Oct 18 03:44:16 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id CEB1B39F; Fri, 18 Oct 2013 03:44:16 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id ACC6727D0; Fri, 18 Oct 2013 03:44:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9I3iGmn058423; Fri, 18 Oct 2013 03:44:16 GMT (envelope-from hrs@svn.freebsd.org) Received: (from hrs@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9I3iG3V058422; Fri, 18 Oct 2013 03:44:16 GMT (envelope-from hrs@svn.freebsd.org) Message-Id: <201310180344.r9I3iG3V058422@svn.freebsd.org> From: Hiroki Sato Date: Fri, 18 Oct 2013 03:44:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256716 - head/etc/rc.d X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Oct 2013 03:44:17 -0000 Author: hrs Date: Fri Oct 18 03:44:16 2013 New Revision: 256716 URL: http://svnweb.freebsd.org/changeset/base/256716 Log: - Fix a bug which prevented jails from starting when $jail_conf was used and no jail name was specified. - Display error messages when start/stop fails. Reported by: swills Modified: head/etc/rc.d/jail Modified: head/etc/rc.d/jail ============================================================================== --- head/etc/rc.d/jail Fri Oct 18 02:22:38 2013 (r256715) +++ head/etc/rc.d/jail Fri Oct 18 03:44:16 2013 (r256716) @@ -426,24 +426,26 @@ jail_start() echo -n 'Starting jails:' case $1 in _ALL) - echo -n ' ' command=$jail_program rc_flags=$jail_flags command_args="-f $jail_conf -c" - $jail_jls -nq | while read IN; do - _jn=$(echo $IN | tr " " "\n" | grep name=) - _jid=$(echo $IN | tr " " "\n" | grep jid=) - if $command $rc_flags $command_args ${_jn#name=}; then + _tmp=`mktemp -t jail` || exit 3 + if $command $rc_flags $command_args >> $_tmp 2>&1; then + $jail_jls -nq | while read IN; do + _jn=$(echo $IN | tr " " "\n" | grep ^name=) + _jid=$(echo $IN | tr " " "\n" | grep ^jid=) echo -n " ${_jn#name=}" echo "${_jid#jid=}" \ > /var/run/jail_${_jn#name=}.id - fi - done + done + else + tail -1 $_tmp + fi + rm -f $_tmp echo '.' return ;; esac - _tmp=`mktemp -t jail` || exit 3 for _j in $@; do _j=$(echo $_j | tr /. _) parse_options $_j || continue @@ -455,10 +457,11 @@ jail_start() else command_args="-i -f $_conf -c $_j" fi + _tmp=`mktemp -t jail` || exit 3 if $command $rc_flags $command_args \ >> $_tmp 2>&1 /var/run/jail_${_j}.id else rm -f /var/run/jail_${_j}.id @@ -480,17 +483,21 @@ jail_stop() echo -n 'Stopping jails:' case $1 in _ALL) - echo -n ' ' command=$jail_program rc_flags=$jail_flags command_args="-f $jail_conf -r" $jail_jls -nq | while read IN; do - _jn=$(echo $IN | tr " " "\n" | grep name=) + _jn=$(echo $IN | tr " " "\n" | grep ^name=) echo -n " ${_jn#name=}" - $command $rc_flags $command_args ${_jn#name=} - if ! $jail_jls -j ${_jn#name=} > /dev/null 2>&1; then + _tmp=`mktemp -t jail` || exit 3 + $command $rc_flags $command_args ${_jn#name=} \ + >> $_tmp 2>&1 + if $jail_jls -j ${_jn#name=} > /dev/null 2>&1; then + tail -1 $_tmp + else rm -f /var/run/jail_${_jn#name=}.id fi + rm -f $_tmp done echo '.' return @@ -504,10 +511,14 @@ jail_stop() fi eval command=\${jail_${_j}_program:-$jail_program} echo -n " ${_hostname:-${_j}}" - $command -q -f $_conf -r $_j - if ! $jail_jls -j $_j > /dev/null 2>&1; then + _tmp=`mktemp -t jail` || exit 3 + $command -q -f $_conf -r $_j >> $_tmp 2>&1 + if $jail_jls -j $_j > /dev/null 2>&1; then + tail -1 $_tmp + else rm -f /var/run/jail_${_j}.id fi + rm -f $_tmp done echo '.' }