#!/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 "" ) > $3.mxml rm -rf $TMPF $TMPD