#!/bin/bash function die() { echo $* exit 1 } URL=$1 CERT=$2 DIR=$3 TMPF=`mktemp` wget --no-check-certificate -O$TMPF $URL || die "Unable to download $URL: $?" samlsign -c $CERT -f $TMPF || die "Unable to verify $URL with $CERT: $?" TMPD=`mktemp -d` xsltproc --stringparam output $TMPD xslt/import-metadata.xsl $TMPF || die "Unable to import metadata from $URL: $?" rsync -avz $TMPD/ $DIR ( echo '?xml version="1.0"?>' echo "" for md in $3/*.xml; do echo "" done echo "" ) > $DIR.mxml git add $DIR.mxml $DIR git commit -m "$URL into $DIR" $DIR.mxml $DIR rm -rf $TMPF $TMPD