Last active
February 27, 2016 13:13
-
-
Save gustavopaes/376487c6154999af879b to your computer and use it in GitHub Desktop.
Shell script to start irrigation using Omega Hardware and Relay Expansion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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