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