#!/bin/sh # # Author: Martti Kuparinen # # $Id: tester,v 1.1 2005/06/28 10:11:45 martti Exp $ # # Usage: ./tester 13 45 # -> start the kernel compilation at 13:45 hrs # usage() { echo "Usage: `basename $0` HH MM" exit 1 } time2secs() { # $1 = HH # $2 = MM # $3 = SS # return: seconds HH=`expr ${1} \* 3600` RESULT=${HH} MM=`expr ${2} \* 60` RESULT=`expr ${RESULT} + ${MM}` RESULT=`expr ${RESULT} + ${3}` } delta() { # $1: Time 1 # $2: Time 2 # return: seconds RESULT=`expr ${1} - ${2}` } [ $# -ne 2 ] && usage rm -rf /usr/src/sys/arch/i386/compile/GENERIC cd /usr/src/sys/arch/i386/conf config GENERIC time2secs ${1} ${2} 0 TARGET=${RESULT} time2secs `date +%H` `date +%M` `date +%S` NOW=${RESULT} delta ${TARGET} ${NOW} DELTA=${RESULT} if [ ${DELTA} -gt 60 ]; then DELTA=`expr ${DELTA} - 30` echo "Sleeping ${DELTA} seconds" sleep ${DELTA} fi time2secs `date +%H` `date +%M` `date +%S` NOW=${RESULT} delta ${TARGET} ${NOW} DELTA=${RESULT} [ ${DELTA} -gt 0 ] && echo "Waiting ${DELTA} seconds" WAIT=1 while [ ${WAIT} -eq 1 ] do time2secs `date +%H` `date +%M` `date +%S` NOW=${RESULT} delta ${TARGET} ${NOW} DELTA=${RESULT} [ ${DELTA} -lt 2 ] && WAIT=0 sleep 1 done cd /usr/src/sys/arch/i386/compile/GENERIC /usr/bin/time make dependall