diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/aggregate.sh | 31 | ||||
-rwxr-xr-x | scripts/pull-and-verify.sh | 6 | ||||
-rwxr-xr-x | scripts/update.sh | 27 |
3 files changed, 57 insertions, 7 deletions
diff --git a/scripts/aggregate.sh b/scripts/aggregate.sh index 25763dee..fa108398 100755 --- a/scripts/aggregate.sh +++ b/scripts/aggregate.sh @@ -1,14 +1,39 @@ #!/bin/sh +aggregate_interval_min=60 +cmd_timeout_s=600 + DIR=`pwd` ODIR=$1 -rm $ODIR/*.xml +rm -f $ODIR/*.xml + +last_aggregate_ts=$ODIR/last_aggregate.ts + +if find $last_aggregate_ts -mmin -$aggregate_interval_min 2>/dev/null | grep -q . ; then + exit 0 +else + touch $last_aggregate_ts +fi grep -v -e '^#' $ODIR/metadata.lst | (while read url cert; do cfile="" if [ "x$cert" != "x" ]; then cfile=$DIR/certs/$cert fi - $DIR/scripts/pull-and-verify.sh $url $ODIR $cfile -done) + cmd="$DIR/scripts/pull-and-verify.sh $url $ODIR $cfile" + timeout $cmd_timeout_s $cmd 2>&1 + ret=$? + case $ret in + 0) + ;; + 124) + echo "$cmd timed out after $cmd_timeout_s seconds" + exit $ret + ;; + *) + echo "$cmd failed with exit code $ret, output:" + exit $ret + ;; + esac +done) || exit $ret diff --git a/scripts/pull-and-verify.sh b/scripts/pull-and-verify.sh index 7cfda0a8..03992f1e 100755 --- a/scripts/pull-and-verify.sh +++ b/scripts/pull-and-verify.sh @@ -10,7 +10,7 @@ DIR=$2 CERT=$3 TMPF=`mktemp` -wget --no-check-certificate -O$TMPF $URL || die "Unable to download $URL: $?" +wget --timeout 120 --no-check-certificate -O$TMPF $URL || die "Unable to download $URL: $?" if [ "x$CERT" != "x" ]; then samlsign -c $CERT -f $TMPF || die "Unable to verify $URL with $CERT: $?" fi @@ -31,6 +31,6 @@ done rm -f $T echo "</EntitiesDescriptor>" ) > $DIR.mxml -git add $DIR.mxml $DIR -git commit -m "$URL into $DIR" $DIR.mxml $DIR +#git add $DIR.mxml $DIR +#git commit -m "$URL into $DIR" $DIR.mxml $DIR rm -rf $TMPF $TMPD diff --git a/scripts/update.sh b/scripts/update.sh index 3d8441ac..5d1a9a2f 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -1,3 +1,28 @@ #!/bin/sh -cd /opt/swamid-metadata && git pull && make test && make +update() +{ + echo "git pull" + git pull || return $? + echo + + echo "make aggregate" + make aggregate || return $? + echo + + echo "make test" + make test || return $? + echo + + echo "make" + make || return $? + echo +} + +cd /opt/swamid-metadata || exit 1 +output=$(update 2>&1) +ret=$? +if [ "$ret" != "0" ] ; then + echo "$output" + exit $ret +fi |