#! /bin/bash # # Download the beam summary data from repo.nd280.org/nd280beam using # wget. This is run without arguments. # The location of the input files. if [ ${BEAMFILES}x == x ]; then BEAMFILES=http://repo.nd280.org/nd280beam/ fi # This directory should ALWAYS exist, but check anyway. BEAMDATABSD=${ENV_BSD_BSD} BEAMDATASPD=${ENV_BSD_SPD} BEAMDATAVER=${ENV_BSD_VER} if [ ! -d ${OABEAMDATAROOT} ]; then echo comet-get-beam: oaBeamData directory is missing! echo where is: ${OABEAMDATAROOT} exit 1 fi cd ${OABEAMDATAROOT} # This directory won't exist when the package is checkout the first time. if [ ! -d ${OABEAMDATAROOT}/../${BEAMDATABSD} ]; then mkdir ../${BEAMDATABSD} fi if [ ! -d ${OABEAMDATAROOT}/${BEAMDATABSD} ]; then ln -s ${OABEAMDATAROOT}/../${BEAMDATABSD} ${OABEAMDATAROOT}/${BEAMDATABSD} fi if [ ! -d ${OABEAMDATAROOT}/${BEAMDATABSD}/${ENV_BSD_VER} ]; then mkdir ${BEAMDATABSD}/${ENV_BSD_VER} fi if [ ! -d ${OABEAMDATAROOT}/../${BEAMDATASPD} ]; then mkdir ${OABEAMDATAROOT}/../${BEAMDATASPD} fi if [ ! -d ${OABEAMDATAROOT}/${BEAMDATASPD} ]; then ln -s ${OABEAMDATAROOT}/../${BEAMDATASPD} ${OABEAMDATAROOT}/${BEAMDATASPD} fi cd ${OABEAMDATAROOT}/${BEAMDATABSD} # Get an index of beam files. wget -q -S -N --http-user=cometbeam --http-passwd=cometbeam ${BEAMFILES}/${BEAMDATABSD}/ -o /dev/null if [ ! -f index.html ]; then echo "comet-get-beam: Cannot check for new beam summary data. Error:Index Part" exit 1 fi # Build a list of the files download. cat index.html | \ egrep "bsd_${BEAMDATAVER}_[0-9]{8}_[[:xdigit:]]{32}" | \ sed 's/.*]*>'// | \ sed 's/<.*//' | \ cat > beam.index # Get the files. for file in `cat beam.index`; do #wget -S -N -c --http-user=cometbeam --http-passwd=cometbeam ${BEAMFILES}/${BEAMDATABSD}/${file} wget -nv -S -N -c --http-user=cometbeam --http-passwd=cometbeam ${BEAMFILES}/${BEAMDATABSD}/${file} 2>&1 if [ $? -eq 0 ]; then case "$file" in *\.tar.gz) tar tf ${file}> ${file}.filelist for bsdfile in `cat ${file}.filelist`; do if [ ! -f $bsdfile ]; then echo "$bsdfile in ${file} is not exits! ... starting extraction ${file}" tar xzvf ${file} break fi done echo "$file processed!" rm ${file}.filelist esac else echo comet-get-beam: Cannot check for new beam summary data. : Main beam data part exit 1 fi done : <<'#__COMMENT_OUT__' case "$file" in *\.sha1) #echo "Found .hash suffix" sha1sum --check ${file} if [ ! $? -eq 0 ]; then tar xzvf ${file%.sha1} fi ;; *) #echo "Not a .hash suffix" ;; esac #__COMMENT_OUT__ # Remove the index. rm index.html rm beam.index cd ${OABEAMDATAROOT}/${BEAMDATASPD} # Get an index of spill database. #wget -q -S -N --http-user=cometbeam --http-passwd=cometbeam ${BEAMFILES}/${BEAMDATASPD}/ -o /dev/null wget -q -S -N --http-user=cometbeam --http-passwd=cometbeam ${BEAMFILES}/${BEAMDATASPD}/ if [ ! -f index.html ]; then echo comet-get-beam: Cannot check for new spill database. : Spill Database Index part exit 1 fi # Build a list of the files download. cat index.html | \ egrep "run[0-9]{7}${BEAMDATAVER}.db" | \ sed 's/.*]*>'// | \ sed 's/<.*//' | \ cat > spilldb.index # Get the files. for file in `cat spilldb.index`; do wget -nv -S -N -c --http-user=cometbeam --http-passwd=cometbeam ${BEAMFILES}/${BEAMDATASPD}/${file} #wget -nv -S -N -c --http-user=cometbeam --http-passwd=cometbeam ${BEAMFILES}/${BEAMDATASPD}/${file} 2>&1 | grep URL if [ ! $? -eq 0 ]; then echo comet-get-beam: Cannot check for new beam summary data. : SpillDataBase part exit 1 fi done # Remove the index. rm index.html rm spilldb.index # Get the beam context map. #wget -nv -S -N -c ${BEAMFILES}/BEAM.LIST -o /dev/null echo BeamFile up to date