From nobody Wed Aug 18 17:19:22 2021 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D4A1B175C159 for ; Wed, 18 Aug 2021 17:19:25 +0000 (UTC) (envelope-from SRS0=eyDw=NJ=quip.cz=000.fbsd@elsa.codelab.cz) Received: from elsa.codelab.cz (elsa.codelab.cz [94.124.105.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4GqZQ54wWtz4nQl for ; Wed, 18 Aug 2021 17:19:25 +0000 (UTC) (envelope-from SRS0=eyDw=NJ=quip.cz=000.fbsd@elsa.codelab.cz) Received: from elsa.codelab.cz (localhost [127.0.0.1]) by elsa.codelab.cz (Postfix) with ESMTP id 143EF28417; Wed, 18 Aug 2021 19:19:24 +0200 (CEST) Received: from illbsd.quip.test (ip-94-113-69-69.net.upcbroadband.cz [94.113.69.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by elsa.codelab.cz (Postfix) with ESMTPSA id AA27F28416; Wed, 18 Aug 2021 19:19:22 +0200 (CEST) Subject: Re: verifying a given jail is running To: Dan Langille , freebsd-hackers@freebsd.org References: <329b32d4-8f8b-d672-21b1-80820d5b318f@langille.org> From: Miroslav Lachman <000.fbsd@quip.cz> Message-ID: <71fb0edd-2b8a-e9ec-ed7e-ca8d6cdfff17@quip.cz> Date: Wed, 18 Aug 2021 19:19:22 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 In-Reply-To: <329b32d4-8f8b-d672-21b1-80820d5b318f@langille.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4GqZQ54wWtz4nQl X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On 18/08/2021 18:21, Dan Langille wrote: > I could use it like this in a shell script. > > jls -j freshports > /dev/null 2>&1 > if [ $? = 0 ] ; then >   echo jail is running > else >   echo jail is not running > fi > > The main reason I need this: Verifying the jail is running before > continuing with a script. You can save one line with this: if jls -j freshports > /dev/null 2>&1 ; then echo "jail is running" else echo "jail is not running" fi Or if you don't need the echoed output and just need to stop script execution: jls -j freshports > /dev/null 2>&1 || exit 5 Miroslav Lachman PS: Use jls -d if dying jail is also accepted as running jail (see man jls)