X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=router_gpio_relay_licht%2Fswitch.cgi;fp=router_gpio_relay_licht%2Fswitch.cgi;h=9f530972fd5c0bc020a47bd20a5c38583b9d4183;hb=d3cd153880388935532949db5c8f4a26731f6964;hp=0000000000000000000000000000000000000000;hpb=ffd55a2bf31c54cb02d2eec8320e9cbe2c51349a;p=svn42.git diff --git a/router_gpio_relay_licht/switch.cgi b/router_gpio_relay_licht/switch.cgi new file mode 100755 index 0000000..9f53097 --- /dev/null +++ b/router_gpio_relay_licht/switch.cgi @@ -0,0 +1,192 @@ +#!/bin/sh + +for QUERY in `echo $QUERY_STRING | tr '&' ' '`; do + for VALUE in `echo $QUERY | tr '=' ' '`; do + if [ "$VALUE" == "id" ]; then + ID='?' + elif [ "$ID" == "?" ]; then + ID=$VALUE + elif [ "$VALUE" == "power" ]; then + POWER='?' + elif [ "$POWER" == "?" ]; then + POWER=$VALUE + elif [ "$VALUE" == "mobile" ]; then + MOBILE='1' + NOFLOAT='1' + elif [ "$VALUE" == "nofloat" ]; then + NOFLOAT='1' + fi + i=$i+1 + done +done + + +GPIOPATH=/sys/class/gpio/gpio +#VALID_ONOFF_IDS="7 18 20 29" +VALID_ONOFF_IDS="7 18 20" + +if [ "$POWER" == "1" -o "$POWER" == "0" ]; then + for CHECKID in $VALID_ONOFF_IDS ; do + if [ "$CHECKID" == "$ID" ]; then + echo "$POWER" > "${GPIOPATH}${ID}/value" + echo "Content-type: text/html" + echo "" + echo "" + echo "
" + echo "