Source

GEIA_regrid / uber_driver.sh

Full commit
#!/usr/bin/env bash

# This script clones and runs code either from
# * the `git` repository @
# https://bitbucket.org/tlroche/geia_regrid
#   You probably wanna check its README before running this.

# * the current folder (for code you haven't committed).

# If you decide to run this, you should first

# * un/comment var=ACCESS to reflect your available/desired file-transfer protocol
# * if using ACCESS='file', edit FILE_LIST below
# * edit var=USERNAME to reflect yours on bitbucket
# * edit var=REPO_ROOT to state where to create your repo clone
# * remember to enable netCDF-4 on your system, e.g.
# > module add netcdf-4.1.2 # on terrae (a cluster on which I work)

ACCESS='file'       # use uncommitted code in current directory
# ACCESS='git/ssh'    # outgoing ssh works (preferred if available)
# ACCESS='http+cert'  # outgoing ssh blocked, but you have certificates
# ACCESS='http-cert'  # (terrae) outgoing ssh blocked, no certs installed

REPO_ROOT='/tmp' # or location of your choice: repo/workspace created in subdir
PROJECT_NAME='geia_regrid'
# what actually does the work
DRIVER_FN='GEIA_driver.sh'

# if [[ "${ACCESS}" == 'file' ]], you'll need
FILE_LIST="./${DRIVER_FN} \
    ./bash_utilities.sh \
    ./check_conservation.ncl \
    ./plotLayersForTimestep.r \
    ./reformat_GEIA_to_netCDF.r \
    ./regrid_global_to_AQMEII.r \
    ./retemp_reunit.ncl"

REPO_DIR="${REPO_ROOT}/${PROJECT_NAME}"
if [[ -d "${REPO_DIR}" ]] ; then
  echo -e "ERROR? repo dir='${REPO_DIR}' exists: move or delete it before running this script"
  exit 1
fi

### USER BEWARE: following `if`s should probably be a `case`

if [[ "${ACCESS}" == 'file' ]] ; then
  if [[ ! -x "./${DRIVER_FN}" ]] ; then
    echo -e "ERROR: ACCESS==file, but driver=='${DRIVER_FN}' not executable"
    exit 2
  else
    for CMD in \
      "mkdir -p ${REPO_DIR}" \
      "cp ${FILE_LIST} ${REPO_DIR}/ " \
    ; do
      echo -e "$ ${CMD}"
      eval "${CMD}"
    done
  fi
fi

if [[ "${ACCESS}" == 'git/ssh' ]] ; then
  pushd ${REPO_ROOT}
  REPO_URI="git@bitbucket.org:tlroche/${PROJECT_NAME}.git"
  git clone ${REPO_URI}
  popd
fi

if [[ "${ACCESS}" == 'http+cert' ]] ; then
  pushd ${REPO_ROOT}
#  REPO_URI="https://${USERNAME}@bitbucket.org/tlroche/${PROJECT_NAME}.git"
  REPO_URI="https://tlroche@bitbucket.org/tlroche/${PROJECT_NAME}.git"
  git clone ${REPO_URI}
  popd
fi

if [[ "${ACCESS}" == 'http-cert' ]] ; then
  pushd ${REPO_ROOT}
#  REPO_URI="https://${USERNAME}@bitbucket.org/tlroche/${PROJECT_NAME}.git"
  REPO_URI="https://tlroche@bitbucket.org/tlroche/${PROJECT_NAME}.git"
  env GIT_SSL_NO_VERIFY=true git clone ${REPO_URI}
  popd
fi

pushd ${REPO_DIR}
./${DRIVER_FN}