extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/release/mklinks-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: ./mklinks.sh [RELEASEPATH] [BASEPATH]
5193 14 Dec 18 nicklas 4 # Create links in the RELEASEPATH directory that points
5193 14 Dec 18 nicklas 5 # to the real file in some other earlier release.
5193 14 Dec 18 nicklas 6 # The current directory is used by default.
5193 14 Dec 18 nicklas 7 # If BASEPATH is specified only links that have a corresponding
5193 14 Dec 18 nicklas 8 # match in BASEPATH are created
5193 14 Dec 18 nicklas 9
5193 14 Dec 18 nicklas 10 <<RELEASEINFO>>
5193 14 Dec 18 nicklas 11
5193 14 Dec 18 nicklas 12 RELEASEPATH=${1-.}
5193 14 Dec 18 nicklas 13 BASEPATH=${2}
5193 14 Dec 18 nicklas 14
5193 14 Dec 18 nicklas 15 NUMLINKS=<<NUMLINKS>>
5193 14 Dec 18 nicklas 16 NCREATED=0
5248 18 Jan 19 nicklas 17 NCHECKED=0
5193 14 Dec 18 nicklas 18
5193 14 Dec 18 nicklas 19 if [ -z "${BASEPATH}" ]; then
5193 14 Dec 18 nicklas 20   # BASEPATH was not set -- A full release is created in RELEASEPATH
5193 14 Dec 18 nicklas 21   echo "Creating ${NUMLINKS} links to existing files"
5193 14 Dec 18 nicklas 22 else
5193 14 Dec 18 nicklas 23   echo "Creating up to ${NUMLINKS} links in '${RELEASEPATH}' if they exist in '${BASEPATH}'"
5193 14 Dec 18 nicklas 24 fi
5193 14 Dec 18 nicklas 25
5193 14 Dec 18 nicklas 26 # Creates a link in RELEASEPATH
5193 14 Dec 18 nicklas 27 # $1 = The link to create (for example, /S000001/l.r.m.c.lib.g/S000001.l.r.m.c.lib.g_R1.fastq.gz)
5193 14 Dec 18 nicklas 28 # $2 = Relative path to reach the actual file 
5193 14 Dec 18 nicklas 29 #      (for example, ../../../1.0/S000001/l.r.m.c.lib.g/S000001.l.r.m.c.lib.g_R1.fastq.gz)
5193 14 Dec 18 nicklas 30 function createLink {
5248 18 Jan 19 nicklas 31   NCHECKED=$(( ${NCHECKED} + 1 ))
5193 14 Dec 18 nicklas 32   if [[ -z "${BASEPATH}" || -f "${BASEPATH}${1}" ]]; then
5248 18 Jan 19 nicklas 33     echo "[${NCHECKED}/${NUMLINKS}] ${RELEASEPATH}${1}"
5193 14 Dec 18 nicklas 34     ln -s $2 ${RELEASEPATH}$1
5193 14 Dec 18 nicklas 35     NCREATED=$(( ${NCREATED} + 1 ))
5193 14 Dec 18 nicklas 36   fi
5193 14 Dec 18 nicklas 37 }
5193 14 Dec 18 nicklas 38
5193 14 Dec 18 nicklas 39 <<SCRIPT>>
5193 14 Dec 18 nicklas 40
5193 14 Dec 18 nicklas 41 echo Done: ${NCREATED} links created
5193 14 Dec 18 nicklas 42