From patchwork Mon Aug 21 16:43:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v7,2/6] fff-support: Update PoE passthrough code From: Adrian Schmutzler X-Patchwork-Id: 439 X-Patchwork-Delegate: freifunk@adrianschmutzler.de Message-Id: <1503333785-5003-2-git-send-email-freifunk@adrianschmutzler.de> To: franken-dev@freifunk.net Date: Mon, 21 Aug 2017 18:43:01 +0200 This implements an upgrade safe solution for the PoE passthrough on multiple devices. Since LEDE already provides the relevant settings, a check whether those are in place enables both identification of affected devices and automatic deactivation if parameters are changed. Signed-off-by: Adrian Schmutzler Tested-by: Adrian Schmutzler --- src/packages/fff/fff-config/files/usr/sbin/configurefffinit | 5 +++++ src/packages/fff/fff-support/Makefile | 2 +- .../ar71xx/usr/lib/fff-support/activate_poe_passthrough.sh | 8 ++++++++ .../usr/lib/fff-support/cpe210_activate_poe_passthrough.sh | 5 ----- .../ar71xx/usr/lib/fff-support/disable_poe_passthrough.sh | 11 +++++++++++ .../ar71xx/usr/lib/fff-support/permanent_poe_passthrough.sh | 9 +++++++++ 6 files changed, 34 insertions(+), 6 deletions(-) create mode 100755 src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/activate_poe_passthrough.sh delete mode 100644 src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_activate_poe_passthrough.sh create mode 100755 src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/disable_poe_passthrough.sh create mode 100755 src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/permanent_poe_passthrough.sh diff --git a/src/packages/fff/fff-config/files/usr/sbin/configurefffinit b/src/packages/fff/fff-config/files/usr/sbin/configurefffinit index 61db6ec..fad734e 100755 --- a/src/packages/fff/fff-config/files/usr/sbin/configurefffinit +++ b/src/packages/fff/fff-config/files/usr/sbin/configurefffinit @@ -24,4 +24,9 @@ uci -q commit /etc/init.d/network restart +poe_passthrough=$(uci -q get "fff.poe_passthrough.enabled") +if [ "$poe_passthrough" = "1" ] && [ -s /usr/lib/fff-support/activate_poe_passthrough.sh ] ; then + /usr/lib/fff-support/activate_poe_passthrough.sh +fi + exit 0 diff --git a/src/packages/fff/fff-support/Makefile b/src/packages/fff/fff-support/Makefile index acb446e..b0e60de 100644 --- a/src/packages/fff/fff-support/Makefile +++ b/src/packages/fff/fff-support/Makefile @@ -13,7 +13,7 @@ define Package/fff-support CATEGORY:=Freifunk TITLE:=Freifunk-Franken Support Scripts URL:=http://www.freifunk-franken.de - DEPENDS:=+@BUSYBOX_CONFIG_ASH + DEPENDS:=+@BUSYBOX_CONFIG_ASH +fff-config endef define Package/fff-support/description diff --git a/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/activate_poe_passthrough.sh b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/activate_poe_passthrough.sh new file mode 100755 index 0000000..b29e351 --- /dev/null +++ b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/activate_poe_passthrough.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# This enables PoE passthrough so it is persistent through reboots, +# but reset after firmware upgrade + +if uci -q get "system.poe_passthrough" > /dev/null ; then + uci -q set "system.poe_passthrough.value=1" + uci -q commit system +fi diff --git a/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_activate_poe_passthrough.sh b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_activate_poe_passthrough.sh deleted file mode 100644 index cb3508f..0000000 --- a/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/cpe210_activate_poe_passthrough.sh +++ /dev/null @@ -1,5 +0,0 @@ -if [ "$(cat /var/sysinfo/model)" = "TP-Link CPE210 v1.1" ] ; then - echo 20 > /sys/class/gpio/export - echo out > /sys/class/gpio/gpio20/direction - echo 1 > /sys/class/gpio/gpio20/value -fi diff --git a/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/disable_poe_passthrough.sh b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/disable_poe_passthrough.sh new file mode 100755 index 0000000..82c84fa --- /dev/null +++ b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/disable_poe_passthrough.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# This disables PoE passthrough permanently + +uci -q set "fff.poe_passthrough=gpio" +uci -q set "fff.poe_passthrough.active=0" +uci -q commit fff + +if uci -q get "system.poe_passthrough" > /dev/null ; then + uci -q set "system.poe_passthrough.value=0" + uci -q commit system +fi diff --git a/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/permanent_poe_passthrough.sh b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/permanent_poe_passthrough.sh new file mode 100755 index 0000000..f9acb88 --- /dev/null +++ b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/permanent_poe_passthrough.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# This enables PoE passthrough permanently, so it is persistent +# during firmware upgrades + +uci -q set "fff.poe_passthrough=gpio" +uci -q set "fff.poe_passthrough.active=1" +uci -q commit fff + +/usr/lib/fff-support/activate_poe_passthrough.sh