From patchwork Wed Apr 10 14:31:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5/8] fff-config: Split uci-defaults script into early and late part From: Adrian Schmutzler X-Patchwork-Id: 1048 Message-Id: <20190410143118.3315-6-freifunk@adrianschmutzler.de> To: franken-dev@freifunk.net Date: Wed, 10 Apr 2019 16:31:15 +0200 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 --- .../fff-config/files/etc/uci-defaults/10-setup-fff | 17 +++++++++++++++++ .../files/etc/uci-defaults/98-configure-fff | 21 +++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 src/packages/fff/fff-config/files/etc/uci-defaults/10-setup-fff 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..a63ff6a9 --- /dev/null +++ b/src/packages/fff/fff-config/files/etc/uci-defaults/10-setup-fff @@ -0,0 +1,17 @@ +#!/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 set fff.ui=fff +uci -q get fff.ui.portsetup > /dev/null || uci set "fff.ui.portsetup=default" + +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.@system[0].hostname=${FFF_hostname}" +test -n "${FFF_hostname}" && uci set "system.@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