#! /bin/sh

# This file checks to see if the .run file has been touched recently
# If not, it starts up runfactor.  You should make sure that your environment
# contains correct settings for all the variables in environ, and that
# FACTORPATH is set correctly.

if test -z "${FPATH+yes}"
then
  FPATH=/bin:/usr/bin:/usr/ucb:/etc:${FACTORPATH-.}; export FPATH 
fi
PATH=$FPATH; export PATH

. environ

TICKS=`expr 90 '*' $TICKLEN`

run=$OUTDIR/.run.${MACH=`hostname`}
lock=$OUTDIR/.lockfile.$MACH

oldval="`ls -l $run 2> /dev/null`"
sleep $TICKS
acquire $lock
newval="`ls -l $run 2> /dev/null`"
if test "$oldval" = "$newval"
then
  touch $run
  runfactor &
fi
rm -f $lock
