#!/bin/bash #This script copies data in the work directory tree to # the USB removable drives. #Then copies the data in the work directory tree into the # search directory tree. # #David Welsh #April 26, 2005 #Set the path export PATH=$HOME/bin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin copy() { inbasedir=$1 outbasedir=$2 instr=$3 ext=$4 cd "$inbasedir"/"$instr" # echo `pwd` if havefiles $ext then if [ -d "$outbasedir" ]; then echo " "copying data to "$outbasedir"/"$instr" for f in *."$ext" do cp -f "$f" "$outbasedir"/"$instr" done else echo " "USB disk "$outbasedir" not mounted fi fi } archive() { inbasedir=$1 outbasedir=$2 instr=$3 ext=$4 echo " "archive data to "$outbasedir"/"$instr" cd "$inbasedir"/"$instr" # echo `pwd` if havefiles $ext then if [ -d "$outbasedir" ]; then echo " "archiving data to "$outbasedir"/"$instr" for f in *."$ext" do mv "$f" "$outbasedir"/"$instr" done else echo " "RAID "$outbasedir" not mounted fi fi } copy_paeri() { inbasedir=$1 outbasedir=$2 instr=$3 cd "$inbasedir"/"$instr" # echo `pwd` dirs=(`ls | grep AE`) for d in "${dirs[@]}" do if [ -d "$outbasedir" ]; then echo " "copying data to "$outbasedir"/"$instr" cp -r "$d" "$outbasedir"/"$instr" else echo " "USB disk "$outbasedir" not mounted fi fi } archive_paeri() { inbasedir=$1 outbasedir=$2 instr=$3 echo " "archive data to "$outbasedir"/"$instr" cd "$inbasedir"/"$instr" # echo `pwd` dirs=(`ls | grep AE`) for d in "${dirs[@]}" do if [ -d "$outbasedir" ]; then echo " "archiving data to "$outbasedir"/"$instr" mv "$d" "$outbasedir"/"$instr" else echo " "RAID "$outbasedir" not mounted fi fi } echo " Start ArchiveData.bash `date -u`" #get the USB disk mount point read diskpath < $HOME/search/diskpath copy $HOME/search/work "$diskpath"/search hsrl nc copy $HOME/search/work "$diskpath"/search mwrad csv copy $HOME/search/work "$diskpath"/search mmcr/mom zip copy $HOME/search/work "$diskpath"/search mmcr/mom txt copy $HOME/search/work "$diskpath"/search mmcr/spc zip copy $HOME/search/work "$diskpath"/search qc/quicklooks png copy $HOME/search/work "$diskpath"/search qc/summary txt copy_paeri $HOME/search/work "$diskpath"/search paeri archive $HOME/search/work /data/search hsrl nc archive $HOME/search/work /data/search mwrad csv archive $HOME/search/work /data/search mmcr/mom zip archive $HOME/search/work /data/search mmcr/mom txt archive $HOME/search/work /data/search mmcr/spc zip archive $HOME/search/work /data/search qc/quicklooks png archive $HOME/search/work /data/search qc/summary txt archive_paeri $HOME/search/work /data/search paeri echo " Stop ArchiveData.bash `date -u`"