gustavopaes
2/27/2016 - 1:11 PM

Shell script to start irrigation using Omega Hardware and Relay Expansion

Shell script to start irrigation using Omega Hardware and Relay Expansion

#!/bin/sh

## Usage example, starts and irrigates for 30 seconds:
## start-irrigation.sh 30

APP_PATH="/app"

relay-exp -i

force_stop() {
	relay-exp 0 0;
	echo  "FAIL" $(date) >> "$APP_PATH/irrigacao.log"
	
	exit 1
}

trap force_stop SIGHUP SIGINT SIGTERM

relay-exp 0 1
sleep $1
relay-exp 0 0

echo  " OK " $(date) >> "$APP_PATH/irrigation.log"
wget --post-data="" http://secret-domain.com/irrigacao/add/1 -O /dev/null -q

exit 0