diff --git a/deploy.sh b/deploy.sh index 7bc85baf93aeb4d04dedd8ad8b11cf7be145d5a8..5429249fc90dc2ffbb3836bdc26fe2a5ce6b8e8a 100755 --- a/deploy.sh +++ b/deploy.sh @@ -15,16 +15,51 @@ thisScript=$(basename $0) defaultDeployDir='/pbs/throng/lsst/software/arc6-client' # -# Target directory to deploy to +# Usage +# +function usage() { + local name=$1 + echo -e "Usage: ${name} [-h] [-d <deploy dir>]\n" + echo -e " e.g. ${name} -d ${defaultDeployDir}" +} + +# +# Parse command line arguments +# +deployDir=${defaultDeployDir} +OPTIND=1 +while getopts "hd:" option; do + case "${option}" in + h|\?) + usage ${thisScript} + exit 0 + ;; + d) + deployDir=$OPTARG + ;; + esac +done +shift $((OPTIND-1)) + +# +# Ensure there are no extra arguments +# +if [[ $# -gt 0 ]]; then + echo "${thisScript}: unexpected argument $1" + usage ${thisScript} + exit 1 +fi + +# +# Check deploy directory exists # -deployDir=${1:-${defaultDeployDir}} if [[ ! -d ${deployDir} ]]; then echo "${thisScript}: could not find deploy directory ${deployDir}" exit 1 fi # -# Pack and copy the relevant files to the target directory +# Pack and copy the relevant files to the deploy directory # tempFile=$(mktemp) trap "rm -f ${tempFile}" EXIT @@ -62,5 +97,5 @@ declare -a arcCommands=( ) cd ${deployDir} for cmd in "${arcCommands[@]}"; do - ln -sf ./run-arc.sh ${cmd} + ln -sf run-arc.sh ${cmd} done \ No newline at end of file diff --git a/run-arc.sh b/run-arc.sh index 9f3f4569e108be718ab1d321b664526474264680..6e123c51cb4233bb0404e2d4a4a9d943101119d6 100755 --- a/run-arc.sh +++ b/run-arc.sh @@ -4,6 +4,7 @@ # Init # thisScript=$(basename $0) +thisDir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" # # Ensure this script is run via an ARC subcommand @@ -24,9 +25,10 @@ if ! voms-proxy-info --file ${X509_USER_PROXY} --exists &> /dev/null; then fi # -# Run the requested command with its arguments inside a Singularity container +# Run the requested command with its arguments inside a Singularity container. The +# container image is expected to be in the same directory as this script. # -singularityImage='nordugrid-arc6-client.sif' +singularityImage="${thisDir}/nordugrid-arc6-client.sif" singularity exec \ --env X509_USER_PROXY=/tmp/x509_user_proxy \ --bind /etc/grid-security \