mirror of https://github.com/hak5/shark-files.git
31 lines
577 B
Bash
Executable File
31 lines
577 B
Bash
Executable File
#!/bin/sh
|
|
|
|
OFFSET=480
|
|
|
|
GPIO0=$(($OFFSET))
|
|
GPIO2=$((2 + $OFFSET))
|
|
|
|
setup() {
|
|
echo "${1}" > /sys/class/gpio/export
|
|
echo in > "/sys/class/gpio/gpio${1}/direction"
|
|
}
|
|
|
|
check_gpio() {
|
|
if [ ! -d "/sys/class/gpio/gpio${1}" ]; then
|
|
setup "${1}"
|
|
fi
|
|
state=$(cat "/sys/class/gpio/gpio${1}/value")
|
|
echo "${state}"
|
|
}
|
|
|
|
gpio0=$(check_gpio $GPIO0)
|
|
gpio2=$(check_gpio $GPIO2)
|
|
|
|
if [ "${gpio0}" -eq "0" ] && [ "${gpio2}" -eq "0" ]; then
|
|
echo "switch1"
|
|
elif [ "${gpio0}" -eq "0" ]; then
|
|
echo "switch3"
|
|
elif [ "${gpio2}" -eq "0" ]; then
|
|
echo "switch2"
|
|
fi
|