#!/bin/bash

set -e

SELF=`echo $0|sed -e 's/\.\///'`
CLOG1=log.$SELF.1
CLOG2=log.$SELF.2

> ${CLOG1}
> ${CLOG2}

main() {
#
DSTART=`date --utc`
printf "\n$0: Started at ${DSTART}"
E1=`date '+%s'`
# require ^releng_, avoid running (your)self explcitly
for s in `ls | grep ^releng_ | grep -v ${SELF} | sort`; do
 if [ -x ${s} ]; then
   set +e
   printf "\n$0: Running ${s}..."
   # -rc -clean are shared options amongst the all releng scripts
   T1=`date '+%s'`
   ./${s} -rc -clean 1>>${CLOG1} 2>>${CLOG2}
   RET=$?
   T2=`date '+%s'`
   let TS="${T2}-${T1}"
   printf "done. ret: $RET; time: ${TS} sec."
   set -e
 fi
done

DEND=`date --utc`
printf "\n$0: Finished at ${DEND}"
E2=`date '+%s'`
let ES="${E2}-${E1}"
printf "\n$0: Total time elapsed ${ES} sec."
printf "\n$0: *** Inspect ${CLOG1} and ${CLOG2} ***\n\n"

exit 0
}

#
main