pcp
[Top] [All Lists]

Re: PMDA Install/Remove vs cwd

To: Nathan Scott <nathans@xxxxxxxxxx>
Subject: Re: PMDA Install/Remove vs cwd
From: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Date: Mon, 12 Jul 2010 18:08:40 +1000
Cc: pcp <pcp@xxxxxxxxxxx>
In-reply-to: <945185264.779571278671888772.JavaMail.root@xxxxxxxxxxxxxxxxxx>
References: <945185264.779571278671888772.JavaMail.root@xxxxxxxxxxxxxxxxxx>
Reply-to: kenj@xxxxxxxxxxxxxxxx
I don't have any strong objection to this.

I have a minor objection to scripts that silently (and, worse,
conditionally) cd off someplace and then continue their execution.

I think I'd prefer to see the test along these lines ...

_check_directory()
{
    case `pwd`
    in
        */pmdas/$iam)
                ;;
        *)
                echo "Error: expect current directory to be .../pmdas/$iam, not 
`pwd`"
                exit 1
                ;;
    esac
}

So this forces the sysadmin to cd to the right place first, rather than
silently doing a cd.  It also works out of a source tree.


On Fri, 2010-07-09 at 20:38 +1000, Nathan Scott wrote:
> Hi,
> 
> I'm tossing up whether/not to merge something like the patch below.
> Can you see any downsides (or potential breakage) in this?
> 
> Obviously, it removes the requirement to explictly cd to the PMDAs
> directory before running the script.  Makes life easier when doing
> remote installs, etc.
> 
> diff --git a/src/pmcd/pmdaproc.sh b/src/pmcd/pmdaproc.sh
> index 0ad5afd..39816a7 100644
> --- a/src/pmcd/pmdaproc.sh
> +++ b/src/pmcd/pmdaproc.sh
> @@ -812,9 +812,8 @@ _setup()
>      dso_entry=${iam}_init
>      pmda_dir=`__strip_pcp_dir "${PCP_PMDAS_DIR}/${iam}"`
>  
> -    # check the user is root 
> -    #
>      _check_userroot
> +    _check_directory
>  
>      # automatically generate files for those lazy Perl programmers
>      #
> @@ -1235,6 +1234,13 @@ _check_userroot()
>      fi
>  }
>  
> +_check_directory()
> +{
> +    __pmdadir="${PCP_PMDAS_DIR}/${iam}"
> +    test -d "$__pmdadir" && cd "$__pmdadir"
> +    __here=`pwd`
> +}
> +
>  # preferred public interfaces
>  #
>  pmdaSetup()
> 


<Prev in Thread] Current Thread [Next in Thread>