summaryrefslogtreecommitdiff
path: root/scripts/aggregate.sh
blob: fa108398d0a25e7f7477dfc02c5bf0e094e37804 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh

aggregate_interval_min=60
cmd_timeout_s=600

DIR=`pwd`
ODIR=$1

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
   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