install-eg.sh: specify PATH on configure
[sitka/sitka-tools.git] / marc_export_custom / mucn-full-export-parallel-ebsco-wrapper.sh
CommitLineData
e11c7cc6
RJ
1#!/bin/bash
2# This is meant to be fire-and-forget
3# Only use it if you trust the output!
4export DIR=$(readlink -f $(dirname $0))
5if [ -z "${MAKEOPTS}" ]; then
6 echo "MAKEOPTS env variable is not set"
7 echo "If you really want this to be serialized, export MAKEOPTS=-j1"
8 echo "Otherwise set it about 1.5x your number of CPUs!"
9 exit 1
10fi
11[ -z "${T}" ] && export T=$(date -u +%Y%m%dT%H%M%SZ)
d1bc237c 12[ -z "${OUTDIR}" ] && export OUTDIR=$(mktemp --tmpdir -d ebsco_export.$T.XXXXXXX)
e11c7cc6 13cd $OUTDIR
5e85b8ab 14echo Prep $(date -uR)/@$(date +%s)
e11c7cc6
RJ
15$DIR/fetch-shortcodes.sh
16cd $DIR
5e85b8ab 17echo Exporting $(date -uR)/@$(date +%s)
e270fa90 18export PERLOPT=-X
e11c7cc6
RJ
19time ./mucn-ebsco-full-export-parallel.sh
20cd $OUTDIR
21mkdir split
22mv *split* split/
5e85b8ab 23echo Compressing $(date -uR)/@$(date +%s)
2ec1922a
RJ
24pbzip2 -9nk -p4 *{marc,log}
25pbzip2 -9n -p4 split/*{marc,log}
5e85b8ab 26echo Stats $(date -uR)/@$(date +%s)
8dad87fc 27DELETE=0 $DIR/stats.sh
2ec1922a 28# Look for zeros in the output marc
5e85b8ab 29echo Sanity $(date -uR)/@$(date +%s)
2ec1922a
RJ
30egrep -vsq '^([[:space:]]*0){2}.*marc$' *stats
31grep_result=$?
32# halt if found
33if [ $rc -ne 0 -o $grep_result -ne 0 ]; then
34 echo "Failed to run export! Human needed! export=$rc grep_sanity=$grep_result" 1>&2
35 cat *stats 1>&2
36 exit 1
37fi
5e85b8ab 38echo FTP $(date -uR)/@$(date +%s)
2ec1922a
RJ
39# Two passes with mget, so the stats and csv are always there first
40# they are small and serve to show we might be uploading more, and they have
41# checksums so AutoGraphics can check the upload
8dad87fc 42FTPDIR=full/mucn/$T
e11c7cc6
RJ
43cat >lftp.cmd <<EOF
44open ftp://cat00975a:neJUJ4ez@ftp.epnet.com/
8dad87fc
RJ
45mkdir -p $FTPDIR
46cd $FTPDIR
e11c7cc6 47mput *csv *stats
8dad87fc 48mput *bz2 *marc
e11c7cc6
RJ
49rels -l
50EOF
51lftp -f lftp.cmd
5e85b8ab 52echo Email $(date -uR)/@$(date +%s)
2ec1922a 53cp $DIR/email-template-ebsco.sh $OUTDIR/
e11c7cc6
RJ
54chmod +x email-template-ebsco.sh
55./email-template-ebsco.sh "$T" "@$(date +%s)" >email.txt
2620278f 56/usr/lib/sendmail -t -f rjohnson@sitka.bclibraries.ca <email.txt