#!/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" VALID_SEND_IDS="" print_gpio_state() { GPIOVALUE=$(cat "${GPIOPATH}${1}/value") if [ "$GPIOVALUE" = "1" ]; then echo "ON" else echo "Off" fi } gpio_is_on() { GPIOVALUE=$(cat "${GPIOPATH}${1}/value") [ "$GPIOVALUE" = "1" ] } 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 "