Commit | Line | Data |
---|---|---|
e404bb37 RJ |
1 | #!/bin/bash |
2 | # This is meant to be fire-and-forget | |
3 | # Only use it if you trust the output! | |
e38e56a8 | 4 | export DIR=$(readlink -f $(dirname $0)) |
55318b37 RJ |
5 | if [ -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 | |
10 | fi | |
e404bb37 | 11 | [ -z "${T}" ] && export T=$(date -u +%Y%m%dT%H%M%SZ) |
d1bc237c | 12 | [ -z "${OUTDIR}" ] && export OUTDIR=$(mktemp --tmpdir -d outlook_export.$T.XXXXXXX) |
e404bb37 RJ |
13 | cd $OUTDIR |
14 | $DIR/fetch-shortcodes.sh | |
15 | cd $DIR | |
16 | time ./sitka-full-export-parallel.sh | |
368b2926 | 17 | rc=$? |
e404bb37 RJ |
18 | cd $OUTDIR |
19 | mkdir split | |
20 | mv *split* split/ | |
21 | pbzip2 -9nvk -p4 *{marc,log} | |
22 | pbzip2 -9nv -p4 split/*{marc,log} | |
23 | $DIR/stats.sh | |
368b2926 RJ |
24 | egrep -sq '^([[:space:]]*0){2}' *stats |
25 | grep_result=$? | |
26 | if [ $rc -ne 0 -o $grep_result -ne 0 ]; then | |
27 | echo "Failed to run export! Human needed! export=$rc grep=$rc" 1>&2 | |
28 | cat *stats 1>&2 | |
29 | exit 1 | |
30 | fi | |
d8966f59 | 31 | cp $DIR/email-template-outlook.sh $OUTDIR/ |
e404bb37 RJ |
32 | cat >lftp.cmd <<EOF |
33 | open ftp://ftpbcuc:bcv15c@ftp.auto-graphics.com/ | |
34 | mkdir -p sitka/$T | |
35 | cd sitka/$T | |
36 | mput *csv *stats | |
37 | mput *bz2 | |
38 | rels -l | |
39 | EOF | |
40 | lftp -f lftp.cmd | |
d8966f59 RJ |
41 | chmod +x email-template-outlook.sh |
42 | ./email-template-outlook.sh "$T" "@$(date +%s)" >email.txt | |
d1bc237c | 43 | /usr/lib/sendmail -f rjohnson@sitka.bclibraries.ca <email.txt |