[PATCH v3 05/14] fff-config: Split uci-defaults script into early and late part

Adrian Schmutzler freifunk at adrianschmutzler.de
Mo Apr 22 14:35:28 CEST 2019


So far, the 98-configure-fff script did both the setup of the
/etc/config/fff file (if it is was not there) and the application
of settings from it.

In this script, the setup part is moved to a much earlier stage,
so /etc/config/fff is initialized when we need it in other scripts.

While at it, remove error suppression for uci set commands and
refine uci commit entries.

Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
Reviewed-by: Christian Dresel <fff at chrisi01.de>

---

Changes in v2:
- Removed ui.portsetup: Should be added in subsequent patch
- Change package release number

Changes in v3:
none
---
 src/packages/fff/fff-config/Makefile                |  3 +--
 .../fff-config/files/etc/uci-defaults/10-setup-fff  | 14 ++++++++++++++
 .../files/etc/uci-defaults/98-configure-fff         | 21 +++++++++------------
 3 files changed, 24 insertions(+), 14 deletions(-)
 create mode 100644 src/packages/fff/fff-config/files/etc/uci-defaults/10-setup-fff

diff --git a/src/packages/fff/fff-config/Makefile b/src/packages/fff/fff-config/Makefile
index 89bdc93d..0ea4a798 100644
--- a/src/packages/fff/fff-config/Makefile
+++ b/src/packages/fff/fff-config/Makefile
@@ -1,8 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=fff-config
-PKG_VERSION:=1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
 
diff --git a/src/packages/fff/fff-config/files/etc/uci-defaults/10-setup-fff b/src/packages/fff/fff-config/files/etc/uci-defaults/10-setup-fff
new file mode 100644
index 00000000..3014f50d
--- /dev/null
+++ b/src/packages/fff/fff-config/files/etc/uci-defaults/10-setup-fff
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright 2017 Adrian Schmutzler
+# License GPLv3
+
+# Set default values in /etc/config/fff
+
+touch /etc/config/fff
+
+if ! uci -q get fff.system > /dev/null ; then
+	uci set fff.system=fff
+	uci set "fff.system.hostname=FFF"
+fi
+
+uci commit fff
diff --git a/src/packages/fff/fff-config/files/etc/uci-defaults/98-configure-fff b/src/packages/fff/fff-config/files/etc/uci-defaults/98-configure-fff
index aa6ac425..4d1748d4 100644
--- a/src/packages/fff/fff-config/files/etc/uci-defaults/98-configure-fff
+++ b/src/packages/fff/fff-config/files/etc/uci-defaults/98-configure-fff
@@ -2,27 +2,24 @@
 # Copyright 2017 Adrian Schmutzler
 # License GPLv3
 
-touch /etc/config/fff
-
-if ! uci -q get fff.system > /dev/null ; then
-	uci -q set fff.system=fff
-	uci -q set "fff.system.hostname=FFF"
-fi
+# Apply configuration
 
 FFF_hostname=$(uci -q get "fff.system.hostname")
-test -n "${FFF_hostname}" && uci -q set "system. at system[0].hostname=${FFF_hostname}"
+test -n "${FFF_hostname}" && uci set "system. at system[0].hostname=${FFF_hostname}"
 test -n "${FFF_hostname}" && echo "${FFF_hostname}" > /proc/sys/kernel/hostname
 
+uci commit system
+
 traffic_enabled=$(uci -q get "fff.trafficcontrol.enabled")
 traffic_in=$(uci -q get "fff.trafficcontrol.limit_in")
 traffic_out=$(uci -q get "fff.trafficcontrol.limit_out")
 
-test -n "${traffic_enabled}" && uci -q set "simple-tc.example.enabled=${traffic_enabled}"
-uci -q set "simple-tc.example.ifname=wan"
-uci -q set "simple-tc.example.limit_ingress=${traffic_in}"
-uci -q set "simple-tc.example.limit_egress=${traffic_out}"
+test -n "${traffic_enabled}" && uci set "simple-tc.example.enabled=${traffic_enabled}"
+uci set "simple-tc.example.ifname=wan"
+uci set "simple-tc.example.limit_ingress=${traffic_in}"
+uci set "simple-tc.example.limit_egress=${traffic_out}"
 
-uci -q commit
+uci commit simple-tc
 
 poe_passthrough=$(uci -q get "fff.poe_passthrough.active")
 if [ "$poe_passthrough" = "1" ] && [ -s /usr/lib/fff-support/activate_poe_passthrough.sh ] ; then
-- 
2.11.0



Mehr Informationen über die Mailingliste franken-dev