Message ID | 20190413232535.9834-6-freifunk@adrianschmutzler.de |
---|---|
State | Superseded |
Headers | show |
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.@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
hi Acked-by: Christian Dresel <fff@chrisi01.de> Sachen inline die ich gerne noch geklärt haben möchte bevor ich ein Review drauf werfe: On 14.04.19 01:25, Adrian Schmutzler wrote: > 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@adrianschmutzler.de> > > --- > > Changes in v2: > - Removed ui.portsetup: Should be added in subsequent patch > - Change package release number > --- > 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.@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 hier fehlt ziemlich sicher reload_config -> root@Testfritz:/rom/etc/uci-defaults# uci set "system.@system[0].hostname=fritz2" root@Testfritz:/rom/etc/uci-defaults# uci commit system root@Testfritz:/rom/etc/uci-defaults# root@Testfritz:/rom/etc/uci-defaults# reload_config root@Testfritz:/rom/etc/uci-defaults# root@fritz2:/rom/etc/uci-defaults# > + > 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 hier vielleicht auch? Ich nutzte kein simple-tc daher keine Ahnung Gruß Christian > > poe_passthrough=$(uci -q get "fff.poe_passthrough.active") > if [ "$poe_passthrough" = "1" ] && [ -s /usr/lib/fff-support/activate_poe_passthrough.sh ] ; then
Hallo Christian, OpenWrt führt reload_config selbst aus, nachdem alle uci-defaults abgearbeitet wurden: https://github.com/openwrt/openwrt/blob/34e22653ac18b6ac7fd368ca47625f665808067f/package/base-files/files/etc/init.d/boot#L50 Da man alle uci-defaults als ein Abarbeiten von zu setzenden configs auffassen kann, muss man da meines Erachtens nicht zwischendrin nochmal reloaden, einmal am Schluss für alle reicht. Zudem läuft zu diesem Zeitpunkt ohnehin noch nichts, der hostname ist also wahrscheinlich der einzige Fall, wo man überhaupt einen Effekt sieht. Das uci-default wird ja dann auch gelöscht, also kann es danach auch niemand aus Versehen ohne reload verwenden. Grüße Adrian > -----Original Message----- > From: Christian Dresel [mailto:fff@chrisi01.de] > Sent: Montag, 22. April 2019 09:45 > To: Adrian Schmutzler <freifunk@adrianschmutzler.de>; franken- > dev@freifunk.net > Subject: Re: [PATCH v2 05/10] fff-config: Split uci-defaults script into early > and late part > > hi > > Acked-by: Christian Dresel <fff@chrisi01.de> > > Sachen inline die ich gerne noch geklärt haben möchte bevor ich ein Review > drauf werfe: > > On 14.04.19 01:25, Adrian Schmutzler wrote: > > 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@adrianschmutzler.de> > > > > --- > > > > Changes in v2: > > - Removed ui.portsetup: Should be added in subsequent patch > > - Change package release number > > --- > > 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.@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 > > > hier fehlt ziemlich sicher reload_config -> root@Testfritz:/rom/etc/uci- > defaults# uci set "system.@system[0].hostname=fritz2" > root@Testfritz:/rom/etc/uci-defaults# uci commit system > root@Testfritz:/rom/etc/uci-defaults# > root@Testfritz:/rom/etc/uci-defaults# reload_config > root@Testfritz:/rom/etc/uci-defaults# > root@fritz2:/rom/etc/uci-defaults# > > > > + > > 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 > > hier vielleicht auch? Ich nutzte kein simple-tc daher keine Ahnung > > Gruß > > Christian > > > > > poe_passthrough=$(uci -q get "fff.poe_passthrough.active") if [ > > "$poe_passthrough" = "1" ] && [ -s /usr/lib/fff- > support/activate_poe_passthrough.sh ] ; then
hi ah ok :) Dann passt es ja. Wunderbar Reviewed-by: Christian Dresel <fff@chrisi01.de> Gruß Christian On 22.04.19 13:36, mail@adrianschmutzler.de wrote: > Hallo Christian, > > OpenWrt führt reload_config selbst aus, nachdem alle uci-defaults abgearbeitet wurden: > > https://github.com/openwrt/openwrt/blob/34e22653ac18b6ac7fd368ca47625f665808067f/package/base-files/files/etc/init.d/boot#L50 > > Da man alle uci-defaults als ein Abarbeiten von zu setzenden configs auffassen kann, muss man da meines Erachtens nicht zwischendrin nochmal reloaden, einmal am Schluss für alle reicht. Zudem läuft zu diesem Zeitpunkt ohnehin noch nichts, der hostname ist also wahrscheinlich der einzige Fall, wo man überhaupt einen Effekt sieht. Das uci-default wird ja dann auch gelöscht, also kann es danach auch niemand aus Versehen ohne reload verwenden. > > Grüße > > Adrian > >> -----Original Message----- >> From: Christian Dresel [mailto:fff@chrisi01.de] >> Sent: Montag, 22. April 2019 09:45 >> To: Adrian Schmutzler <freifunk@adrianschmutzler.de>; franken- >> dev@freifunk.net >> Subject: Re: [PATCH v2 05/10] fff-config: Split uci-defaults script into early >> and late part >> >> hi >> >> Acked-by: Christian Dresel <fff@chrisi01.de> >> >> Sachen inline die ich gerne noch geklärt haben möchte bevor ich ein Review >> drauf werfe: >> >> On 14.04.19 01:25, Adrian Schmutzler wrote: >>> 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@adrianschmutzler.de> >>> >>> --- >>> >>> Changes in v2: >>> - Removed ui.portsetup: Should be added in subsequent patch >>> - Change package release number >>> --- >>> 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.@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 >> >> hier fehlt ziemlich sicher reload_config -> root@Testfritz:/rom/etc/uci- >> defaults# uci set "system.@system[0].hostname=fritz2" >> root@Testfritz:/rom/etc/uci-defaults# uci commit system >> root@Testfritz:/rom/etc/uci-defaults# >> root@Testfritz:/rom/etc/uci-defaults# reload_config >> root@Testfritz:/rom/etc/uci-defaults# >> root@fritz2:/rom/etc/uci-defaults# >> >> >>> + >>> 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 >> hier vielleicht auch? Ich nutzte kein simple-tc daher keine Ahnung >> >> Gruß >> >> Christian >> >>> poe_passthrough=$(uci -q get "fff.poe_passthrough.active") if [ >>> "$poe_passthrough" = "1" ] && [ -s /usr/lib/fff- >> support/activate_poe_passthrough.sh ] ; then
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@adrianschmutzler.de> --- Changes in v2: - Removed ui.portsetup: Should be added in subsequent patch - Change package release number --- 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