Last active
May 23, 2016 17:09
-
-
Save fhunter/718266cebbd8c4a059e63be9a301eb5f to your computer and use it in GitHub Desktop.
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
while sleep 2;do | |
rm /tmp/state.xml | |
wget -q -O /tmp/state.xml http://192.168.0.101/state.xml | |
test -e /tmp/state.xml || continue | |
INPUTS=`cat /tmp/state.xml|grep -e "^<in>[0-1]*</in>"|sed 's/[><]/\n/g'|grep -v in|sort|tail -n 1` | |
RELAYS=`cat /tmp/state.xml|grep -e "^<rele>[0-1]*</rele>"|sed 's/[><]/\n/g'|grep -v rele|sort|tail -n 1` | |
POWER_NVIDIA=`echo $INPUTS|cut -c 1` | |
POWER_NUC=`echo $INPUTS|cut -c 2` | |
POWER_BTN=`echo $INPUTS|cut -c 6` | |
POWER_IMX6=`echo $RELAYS|cut -c 1` | |
#echo $POWER_NVIDIA $POWER_NUC $POWER_BTN | |
if [ $POWER_BTN = "1" ]; then | |
if [ $POWER_IMX6 = "0" ];then | |
echo power up imx6 | |
wget -q -O - http://192.168.0.101/cmd.cgi?cmd=REL,1,1 | |
fi | |
if [ $POWER_NVIDIA = "0" ];then | |
echo power up nvidia | |
wget -q -O - http://192.168.0.101/cmd.cgi?cmd=OUT,1,1,1, | |
fi | |
if [ $POWER_NUC = "0" ];then | |
echo power up nuc | |
wget -q -O - http://192.168.0.101/cmd.cgi?cmd=OUT,2,1,1, | |
fi | |
else | |
if [ $POWER_IMX6 = "1" ];then | |
echo power down imx6 | |
wget -q -O - http://192.168.0.101/cmd.cgi?cmd=REL,1,0 | |
fi | |
if [ $POWER_NVIDIA = "1" ];then | |
echo power down nvidia | |
wget -q -O - http://192.168.0.101/cmd.cgi?cmd=OUT,1,1,1, | |
fi | |
if [ $POWER_NUC = "1" ];then | |
echo power down nuc | |
wget -q -O - http://192.168.0.101/cmd.cgi?cmd=OUT,2,1,1, | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment