Skip to content

Instantly share code, notes, and snippets.

@gustavopaes
Last active February 27, 2016 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavopaes/376487c6154999af879b to your computer and use it in GitHub Desktop.
Save gustavopaes/376487c6154999af879b to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment