op-packages/luci-app-cpe/root/usr/bin/set_gpio
github-actions[bot] 32600acc60 🌴 Sync 2026-03-05 23:51:42
2026-03-05 23:51:42 +08:00

18 lines
271 B
Bash
Executable File

#!/bin/sh
PIN=$1
VALUE=$2
PIN_FILE=/sys/class/gpio/gpio$PIN
if [ -z "$PIN" -o -z "$VALUE" ]; then
exit 1
fi
echo $PIN >/sys/class/gpio/export
if [ $(cat $PIN_FILE/direction) = "out" ]; then
echo $VALUE >$PIN_FILE/value
fi
echo $PIN >/sys/class/gpio/unexport