[RFC PATCH v3 2/2] fff-support: Update PoE passthrough code
Adrian Schmutzler
freifunk at adrianschmutzler.de
Fr Jul 14 11:38:12 CEST 2017
This implements an upgrade safe solution for the PoE passthrough
supporting both the CPE210 and the Nanostation M2.
Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
.../ar71xx/usr/lib/fff-support/activate_poe_passthrough.sh | 10 ++++++++++
.../usr/lib/fff-support/cpe210_activate_poe_passthrough.sh | 5 -----
.../ar71xx/usr/lib/fff-support/disable_poe_passthrough.sh | 13 +++++++++++++
.../ar71xx/usr/lib/fff-support/permanent_poe_passthrough.sh | 9 +++++++++
.../fff/fff-sysupgrade/files/usr/sbin/configurefffinit | 5 +++++
5 files changed, 37 insertions(+), 5 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-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..f52bc2c
--- /dev/null
+++ b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/activate_poe_passthrough.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+# This enables PoE passthrough so it is persistent through reboots,
+# but reset after firmware upgrade
+
+used_device="$(cat /var/sysinfo/model)"
+
+if [ "$used_device" = "TP-Link CPE210 v1.1" ] || [ "$used_device" = "Ubiquiti NanoStation M2" ] ; 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..138a60b
--- /dev/null
+++ b/src/packages/fff/fff-support/ar71xx/usr/lib/fff-support/disable_poe_passthrough.sh
@@ -0,0 +1,13 @@
+#!/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
+
+used_device="$(cat /var/sysinfo/model)"
+
+if [ "$used_device" = "TP-Link CPE210 v1.1" ] || [ "$used_device" = "Ubiquiti NanoStation M2" ] ; 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
diff --git a/src/packages/fff/fff-sysupgrade/files/usr/sbin/configurefffinit b/src/packages/fff/fff-sysupgrade/files/usr/sbin/configurefffinit
index 20d738c..d10f923 100755
--- a/src/packages/fff/fff-sysupgrade/files/usr/sbin/configurefffinit
+++ b/src/packages/fff/fff-sysupgrade/files/usr/sbin/configurefffinit
@@ -21,4 +21,9 @@ uci -q set "simple-tc.example.limit_egress=${traffic_out}"
uci -q commit
+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
--
2.7.4
Mehr Informationen über die Mailingliste franken-dev