binblog
By: a guest | Oct 4th, 2008 | Syntax:
Bash | Size: 1.79 KB | Hits: 347 | Expires: Never
#!/bin/sh
LED=$1
STATE=$2
UNAME=`uname -s`
case "$UNAME" in
"OpenBSD")
case "$LED" in
"1")
GPIO=6
;;
"2")
GPIO=25
;;
"3")
GPIO=27
;;
*)
echo 'Usage: led <1/2/3> <on/off>'
exit 1
;;
esac
gpioctl -q -c $GPIO out iout
case "$STATE" in
"on")
gpioctl -q $GPIO 1
;;
"off")
gpioctl -q $GPIO 0
;;
*)
echo 'Usage: led <1/2/3> <on/off>'
exit 1
;;
esac
;;
"Linux")
CHECK="x$LED"
if [ $CHECK != "x1" -a $CHECK != "x2" -a $CHECK != "x3" ]
then
echo 'Usage: led <1/2/3> <on/off>'
exit 1
fi
test -d /sys/class/leds/alix\:1
if [ $? -ne 0 ]
then
print "No ALIX LED support here. :-("
exit 1
fi
case "$STATE" in
"on")
echo 1 > /sys/class/leds/alix\:$LED/brightness
;;
"off")
echo 0 > /sys/class/leds/alix\:$LED/brightness
;;
*)
echo 'Usage: led <1/2/3> <on/off>'
exit 1
;;
esac
;;
*)
echo "Plattform $UNAME not supported."
exit 1
;;
esac