Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
echo "Usage: $0 'Generate timestamp' 'Submit timestamp'" 1>&2
fi
echo "Usage: $0 'Generate timestamp' 'Submit timestamp'" 1>&2
fi
+FILELIST=`cat Manifest`
+
# illsupport@bclibrary.ca goes to Mari.Martin@gov.bc.ca and Bob.Yuan@gov.bc.ca
cat <<EOF
Date: $(date -uR)
# illsupport@bclibrary.ca goes to Mari.Martin@gov.bc.ca and Bob.Yuan@gov.bc.ca
cat <<EOF
Date: $(date -uR)
(none, this was automated)
Directory for uploads:
(none, this was automated)
Directory for uploads:
Submission timestamp:
$(date -uR -d "$t2")
Submission timestamp:
$(date -uR -d "$t2")
$(date -uR -d "$t1")
Submission method:
$(date -uR -d "$t1")
Submission method:
Compressed sizes in bytes:
$(head -n2 *stats | awk '/.marc.bz2$/{print $9,$5}')
Compressed sizes in bytes:
$(head -n2 *stats | awk '/.marc.bz2$/{print $9,$5}')
Number of records submitted:
$(grep -h Filename -A5 $i *stats | awk '/.marc$/{print $3,$1}')
Number of records submitted:
$(grep -h Filename -A5 $i *stats | awk '/.marc$/{print $3,$1}')
+Files uploaded:
+$FILELIST
+
SHA1 checksums:
$(egrep '^[a-f0-9]{32}' *stats -h |sort -k +2)
$(sha1sum *.csv)
SHA1 checksums:
$(egrep '^[a-f0-9]{32}' *stats -h |sort -k +2)
$(sha1sum *.csv)
-psql -Upostgres -U evergreen evergreen -h db1.sitka.bclibraries.ca -o shortcodes.csv \
+SHORTCODES=$1
+if [ -z "${SHORTCODES}" ]; then
+ SHORTCODES="shortcodes.csv"
+fi
+psql -Upostgres -U evergreen evergreen -h prod-pg94-db2-sitka.sitka.bclibraries.ca -o $SHORTCODES \
-c "COPY (
SELECT
a.shortname,a.name,b.shortname AS parent
-c "COPY (
SELECT
a.shortname,a.name,b.shortname AS parent
# Add new 852 fields
add_bib_holdings($bib, $r);
# Check that at least one 852 was added
# Add new 852 fields
add_bib_holdings($bib, $r);
# Check that at least one 852 was added
- @marc852 = $r->field('852');
- @marc856 = $r->field('856');
+ my @marc852 = $r->field('852');
+ my @marc856 = $r->field('856');
# If not, we should NOT add this item to the export
# ... but we may still want the record if it has an 856
return unless ( @marc852 || ($with_ebooks && @marc856) );
} else {
# If not, we should NOT add this item to the export
# ... but we may still want the record if it has an 856
return unless ( @marc852 || ($with_ebooks && @marc856) );
} else {
- add_bib_holdings($bib, $r);
+ add_bib_holdings($bib, $r) if ($holdings);
[ -z "${OUTDIR}" ] && export OUTDIR=$(mktemp --tmpdir -d ${NAME}_export.$T.XXXXXXX)
cd $OUTDIR
echo Prep $(date -uR)/@$(date +%s)
[ -z "${OUTDIR}" ] && export OUTDIR=$(mktemp --tmpdir -d ${NAME}_export.$T.XXXXXXX)
cd $OUTDIR
echo Prep $(date -uR)/@$(date +%s)
-$DIR/fetch-shortcodes.sh
+$DIR/fetch-shortcodes.sh shortcodes.csv
cd $DIR
echo Exporting $(date -uR)/@$(date +%s)
export PERLOPT=-X
cd $DIR
echo Exporting $(date -uR)/@$(date +%s)
export PERLOPT=-X
--- /dev/null
+#!/bin/bash
+# Upload a file to Auto-Graphics ShareFile system using WebDAV/curl
+# Usage: ./outlook-curl.sh <file> <username> <password>
+FILE=$1
+USERNAME=$2
+PASSWORD=$3
+LOG="outlook-curl.log"
+curl -k -u $USERNAME:$PASSWORD -T $FILE https://agcloud.auto-graphics.com/public.php/webdav/sitka/$FILE 2> $LOG
#!/bin/bash
# This is meant to be fire-and-forget
# Only use it if you trust the output!
#!/bin/bash
# This is meant to be fire-and-forget
# Only use it if you trust the output!
+
+CURL_USERNAME=$1
+CURL_PASSWORD=$2
+
export DIR=$(readlink -f $(dirname $0))
NAME=outlook
if [ -z "${MAKEOPTS}" ]; then
export DIR=$(readlink -f $(dirname $0))
NAME=outlook
if [ -z "${MAKEOPTS}" ]; then
[ -z "${OUTDIR}" ] && export OUTDIR=$(mktemp --tmpdir -d ${NAME}_export.$T.XXXXXXX)
cd $OUTDIR
echo Prep $(date -uR)/@$(date +%s)
[ -z "${OUTDIR}" ] && export OUTDIR=$(mktemp --tmpdir -d ${NAME}_export.$T.XXXXXXX)
cd $OUTDIR
echo Prep $(date -uR)/@$(date +%s)
-$DIR/fetch-shortcodes.sh
+$DIR/fetch-shortcodes.sh shortcodes-$T.csv
cd $DIR
echo Exporting $(date -uR)/@$(date +%s)
export PERLOPT=-X
cd $DIR
echo Exporting $(date -uR)/@$(date +%s)
export PERLOPT=-X
cat *stats 1>&2
exit 1
fi
cat *stats 1>&2
exit 1
fi
-echo FTP $(date -uR)/@$(date +%s)
-# Two passes with mget, so the stats and csv are always there first
-# they are small and serve to show we might be uploading more, and they have
-# checksums so AutoGraphics can check the upload
-FTPSITE=ftp://ftpbcuc:bcv15c@ftp.auto-graphics.com/
-FTPDIR=sitka/$T
-cat >lftp.cmd <<EOF
-open $FTPSITE
-mkdir -p $FTPDIR
-cd $FTPDIR
-mput *csv *stats
-mput *bz2
-rels -l
-EOF
-lftp -f lftp.cmd
-echo Email $(date -uR)/@$(date +%s)
+
+# upload fails if curl username/password not provided
+if [ -z "${CURL_PASSWORD}" ]; then
+ echo "Missing curl auth parameter(s), cannot upload to Outlook" 1>&2
+ exit 1
+fi
+
+# individually upload all required output files with curl
+for CURL_FILE in `ls $OUTDIR | egrep '(.bz2|.stats|.csv)$' | grep -v script.log.bz2` ; do
+ $DIR/outlook-curl.sh $CURL_FILE $CURL_USERNAME $CURL_PASSWORD
+ echo $CURL_FILE >> $OUTDIR/Manifest
+done
+
cp $DIR/email-template-${NAME}.sh $OUTDIR/
chmod +x email-template-${NAME}.sh
./email-template-${NAME}.sh "$T" "@$(date +%s)" >email.txt
cp $DIR/email-template-${NAME}.sh $OUTDIR/
chmod +x email-template-${NAME}.sh
./email-template-${NAME}.sh "$T" "@$(date +%s)" >email.txt