From 9a47ff800a4e4ca977f3c239e7a3551a8270f7bf Mon Sep 17 00:00:00 2001 From: dman776 Date: Sat, 27 Oct 2018 11:37:45 -0500 Subject: [PATCH] bugfix: correct poe functions in adv cfg (#250) * bugfix: correct poe functions in adv cfg cleanup shellcheck errors * avoid unnecessary shell --- files/usr/local/bin/poe_passthrough | 9 ++++----- files/www/cgi-bin/advancedconfig | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/files/usr/local/bin/poe_passthrough b/files/usr/local/bin/poe_passthrough index 47aca868..40122356 100755 --- a/files/usr/local/bin/poe_passthrough +++ b/files/usr/local/bin/poe_passthrough @@ -40,16 +40,15 @@ if [ -z "$newval" ]; then exit 2 fi -export pinnum=`cat /etc/board.json|jsonfilter -e '@.gpioswitch.poe_passthrough.pin'` +export pinnum=$(jsonfilter -e '@.gpioswitch.poe_passthrough.pin' < /etc/board.json) if [ -z "$pinnum" ]; then echo "There are NO PoE Passthrough ports defined for this device" exit 1 else - export pin=$(echo "gpio${pinnum}") - if [ ! -d /sys/class/gpio/$pin ]; then - echo ${pinnum} > /sys/class/gpio/export + export pin="gpio${pinnum}" + if [ ! -d "/sys/class/gpio/$pin" ]; then + echo "${pinnum}" > /sys/class/gpio/export fi - echo out > /sys/class/gpio/${pin}/direction echo ${newval} > /sys/class/gpio/${pin}/value exit 0 fi diff --git a/files/www/cgi-bin/advancedconfig b/files/www/cgi-bin/advancedconfig index 481ce5f6..e180bff5 100755 --- a/files/www/cgi-bin/advancedconfig +++ b/files/www/cgi-bin/advancedconfig @@ -81,7 +81,7 @@ push @setting, { # ----- CONDITIONS ---------- sub hasPOE() { - $pin=`cat /etc/board.json|jsonfilter -e '@.gpioswitch.usb_power_switch.pin'`; + $pin=`cat /etc/board.json|jsonfilter -e '@.gpioswitch.poe_passthrough.pin'`; chomp($pin); return $pin ? return 1 : return 0; }