#!/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 usbdisk=$5 echo " "archive data to "$outbasedir"/"$instr" cd "$inbasedir"/"$instr" # echo `pwd` if havefiles $ext then if [ -d "$usbdisk" ]; 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 done } archive_paeri() { inbasedir=$1 outbasedir=$2 instr=$3 usbdisk=$4 echo " "archive data to "$outbasedir"/"$instr" cd "$inbasedir"/"$instr" # echo `pwd` dirs=(`ls | grep AE`) for d in "${dirs[@]}" do if [ -d "$usbdisk" ]; then echo " "archiving data to "$outbasedir"/"$instr" mv "$d" "$outbasedir"/"$instr" else echo " "RAID "$outbasedir" not mounted fi done } 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 "$diskpath"/search archive $HOME/search/work /data/search mwrad csv "$diskpath"/search archive $HOME/search/work /data/search mmcr/mom zip "$diskpath"/search archive $HOME/search/work /data/search mmcr/mom txt "$diskpath"/search archive $HOME/search/work /data/search mmcr/spc zip "$diskpath"/search archive $HOME/search/work /data/search qc/quicklooks png "$diskpath"/search archive $HOME/search/work /data/search qc/summary txt "$diskpath"/search archive_paeri $HOME/search/work /data/search paeri "$diskpath"/search echo " Stop ArchiveData.bash `date -u`"