extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/release/mkdirs-template.sh

Code
Comments
Other
Rev Date Author Line
5193 14 Dec 18 nicklas 1 #!/bin/sh
5193 14 Dec 18 nicklas 2
5193 14 Dec 18 nicklas 3 # Usage: ./mkdirs.sh [RELEASEPATH] [BASEPATH]
5193 14 Dec 18 nicklas 4 # Creates the release directory structure in the RELEASEPATH directory.
5193 14 Dec 18 nicklas 5 # The current directory is used by default.
5193 14 Dec 18 nicklas 6 # If BASEPATH is specified only directories that have a corresponding
5193 14 Dec 18 nicklas 7 # match in BASEPATH are created
5193 14 Dec 18 nicklas 8
5193 14 Dec 18 nicklas 9 <<RELEASEINFO>>
5193 14 Dec 18 nicklas 10
5193 14 Dec 18 nicklas 11 RELEASEPATH=${1-.}
5193 14 Dec 18 nicklas 12 BASEPATH=${2}
5193 14 Dec 18 nicklas 13
5193 14 Dec 18 nicklas 14 NUMPATHS=<<NUMPATHS>>
5193 14 Dec 18 nicklas 15 NCREATED=0
5248 18 Jan 19 nicklas 16 NCHECKED=0
5193 14 Dec 18 nicklas 17
5193 14 Dec 18 nicklas 18 if [ -z "${BASEPATH}" ]; then
5193 14 Dec 18 nicklas 19   # BASEPATH was not set -- A full release is created in RELEASEPATH
5193 14 Dec 18 nicklas 20   echo "Creating ${NUMPATHS} paths in '${RELEASEPATH}'"
5193 14 Dec 18 nicklas 21 else
5193 14 Dec 18 nicklas 22   echo "Creating up to ${NUMPATHS} paths in '${RELEASEPATH}' if they exist in '${BASEPATH}'"
5193 14 Dec 18 nicklas 23 fi
5193 14 Dec 18 nicklas 24
5193 14 Dec 18 nicklas 25 # Creates a path in RELEASEPATH
5193 14 Dec 18 nicklas 26 # $1 = The path to create (for example, /S000001/l.r.m.c.lib.g)
5193 14 Dec 18 nicklas 27 function createPath {
5248 18 Jan 19 nicklas 28   NCHECKED=$(( ${NCHECKED} + 1 ))
5193 14 Dec 18 nicklas 29   if [[ -z "${BASEPATH}" || -d "${BASEPATH}${1}" ]]; then
5248 18 Jan 19 nicklas 30     echo "[${NCHECKED}/${NUMPATHS}] ${RELEASEPATH}${1}"
5193 14 Dec 18 nicklas 31     mkdir -p ${RELEASEPATH}${1}
5193 14 Dec 18 nicklas 32     NCREATED=$(( ${NCREATED} + 1 ))
5193 14 Dec 18 nicklas 33   fi
5193 14 Dec 18 nicklas 34 }
5193 14 Dec 18 nicklas 35
5193 14 Dec 18 nicklas 36 <<SCRIPT>>
5193 14 Dec 18 nicklas 37
5193 14 Dec 18 nicklas 38 echo Done: ${NCREATED} paths created
5193 14 Dec 18 nicklas 39