#!/bin/sh

# Only start the sprinklers if it has not rained too much
# over the last few days.

RAINFILE="/home/daniel/sprinklers/enough-rain"
CONTROL="/home/daniel/sprinklers/sprinkler-control"

if [ "$2" = "on" ];
then
	if [ ! -e "$RAINFILE" ];
	then
		$CONTROL $1 $2
	else
		RAINQTY=`cat "$RAINFILE"`
		echo "Not turning on sprinklers - seen $RAINQTY mm in last few days"
	fi
else
	$CONTROL $1 $2
fi
