[Stgt-devel] [PATCH] in tgt-setup-lun: fix check if tgtd daemon is running

Doron Shoham dorons
Tue Apr 1 16:45:47 CEST 2008


Doron Shoham wrote:
> Checking if the tgtd daemon is running should be
> done with pidof

It also exits if tgtd daemon is not running,
instead of loading it.

> 
> Signed-off-by: Doron Shoham <dorons at voltaire.com>
> ---
>  scripts/tgt-setup-lun |   13 ++++++++-----
>  1 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/scripts/tgt-setup-lun b/scripts/tgt-setup-lun
> index 53bb934..cefbec9 100755
> --- a/scripts/tgt-setup-lun
> +++ b/scripts/tgt-setup-lun
> @@ -153,11 +153,14 @@ initiators=$*
>  
>  verify_params
>  
> -# Check if tgtd is running (we should have 2 daemons)
> -tgtd_count=$(ps aux|grep -c tgtd)
> -if [ $tgtd_count -ne 3 ]; then
> -	echo "Starting tgtd"
> -	tgtd
> +
> +# Check if tgtd is running
> +pidof tgtd &>/dev/null
> +ret=$?
> +if [ $ret -ne 0 ]; then
> +        echo "tgtd is not running"
> +        echo "Exiting..."
> +        exit 1
>  fi
>  
>  tgt_name="iqn.2001-04.com.$(hostname -s)-$tgt_name"





More information about the stgt mailing list