Improve error checking before export actually triggers the FTP upload.
authorRobin H. Johnson <rjohnson@sitka.bclibraries.ca>
Mon, 2 Dec 2013 16:57:34 +0000 (08:57 -0800)
committerRobin H. Johnson <rjohnson@sitka.bclibraries.ca>
Mon, 2 Dec 2013 16:57:34 +0000 (08:57 -0800)
Signed-off-by: Robin H. Johnson <rjohnson@sitka.bclibraries.ca>
marc_export_custom/Makefile-marc_export
marc_export_custom/sitka-full-export-parallel-outlook-wrapper.sh
marc_export_custom/sitka-full-export-parallel.sh

index 1f8825a..6b9bd7f 100644 (file)
@@ -4,6 +4,7 @@ MARC_STATS=./stats-distribution.pl
        @echo '   ' MARC $(notdir $@); \
        $(MARC_EXPORT_BIN) $(MARC_PARAMS) <$< --output-file $@.tmp 2>&1 | tee $@.log \
        && mv $@.tmp $@
+       grep -vsq -e 'router@private-router.localdomain' -e 'OpenSRF::' $@.log
 %.marc-stats.csv: %.marc
        @echo '   ' MARCSTATS $(notdir $<); \
        $(MARC_STATS) $< >$@.tmp && mv $@.tmp $@
index b5a5dc5..b484ba5 100755 (executable)
@@ -14,12 +14,20 @@ cd $OUTDIR
 $DIR/fetch-shortcodes.sh
 cd $DIR
 time ./sitka-full-export-parallel.sh
+rc=$?
 cd $OUTDIR
 mkdir split
 mv *split* split/
 pbzip2 -9nvk -p4 *{marc,log}
 pbzip2 -9nv -p4 split/*{marc,log}
 $DIR/stats.sh
+egrep -sq '^([[:space:]]*0){2}' *stats
+grep_result=$?
+if [ $rc -ne 0 -o $grep_result -ne 0 ]; then
+       echo "Failed to run export! Human needed! export=$rc grep=$rc" 1>&2
+       cat *stats 1>&2
+       exit 1
+fi
 cp $DIR/email-template-outlook.sh $OUTDIR/
 cat >lftp.cmd <<EOF
 open ftp://ftpbcuc:bcv15c@ftp.auto-graphics.com/
index 0f60ca9..16b0737 100755 (executable)
@@ -37,10 +37,12 @@ process_batch() {
        MARC_EXPORT_BIN="${MARC_EXPORT_BIN}" \
        MARC_PARAMS="$MARC_PARAMS --exclusion_ini ${f}.ini" \
        $(<${OUTDIR}/${f}.id.targets)
+       make_rc=$?
 
        find ${OUTDIR} -name "${f}-${T}-split*.marc" \
        -exec cat \{} \; \
        >${OUTDIR}/${f}-${T}.marc
+       return $make_rc
 }
 
 split_suffix() {
@@ -53,13 +55,19 @@ split_suffix() {
 export SPLIT_COUNT=10000
 F=bc_eln_media SQL="$POSTSEC_QUERY"
 process_batch "$F" "${SQL}" $SPLIT_COUNT
+rc1=$?
 
 # serials for BC ELN post-secondary libraries
 export SPLIT_COUNT=10000
 F=bc_eln_serials SQL="$POSTSEC_QUERY"
 process_batch "$F" "${SQL}" $SPLIT_COUNT
+rc2=$?
 
 export SPLIT_COUNT=100000
 # full dump for outlook public libraries
 F=sitka_full_outlook SQL="$FULL_QUERY"
 process_batch "$F" "${SQL}" $SPLIT_COUNT
+rc3=$?
+
+rc=$(($rc1+$rc2+$rc3))
+exit $rc