[2/2] gateway.d: Add configuration script for meta information

Submitted by Fabian Blaese on March 15, 2019, 8:22 p.m.

Details

Message ID 20190315202213.17577-2-fabian@blaese.de
State Superseded
Headers show

Commit Message

Fabian Blaese March 15, 2019, 8:22 p.m.
This adds a configuration script for applying hostname,
coordinates, hoodname and contact address.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
---
 .../fff-gateway/files/etc/gateway.d/01-meta   | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 src/packages/fff/fff-gateway/files/etc/gateway.d/01-meta

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-gateway/files/etc/gateway.d/01-meta b/src/packages/fff/fff-gateway/files/etc/gateway.d/01-meta
new file mode 100644
index 0000000..1b4209b
--- /dev/null
+++ b/src/packages/fff/fff-gateway/files/etc/gateway.d/01-meta
@@ -0,0 +1,43 @@ 
+configure() {
+	## set hostname
+	if name=$(uci -q get gateway.@gateway[0].name); then
+		uci -q set system.@system[0].hostname="$name"
+		uci -q set fff.system.hostname="$name"
+	else
+		echo "WARNING: No gateway name set!"
+	fi
+
+	## set contact
+	if contact=$(uci -q get gateway.@gateway[0].contact); then
+		uci -q set fff.system.contact="$contact"
+	else
+		echo "WARNING: No contact set!"
+	fi
+
+	## set location
+	if lat=$(uci -q get gateway.@gateway[0].latitude) && long=$(uci -q get gateway.@gateway[0].longitude); then
+		uci -q set fff.system.latitude="$lat"
+		uci -q set fff.system.longitude="$long"
+	else
+		echo "WARNING: No gateway location set!"
+	fi
+
+	## hoodname
+	if hood=$(uci -q get gateway.@gateway[0].hoodname); then
+		echo "Setting hood name: $hood"
+		uci -q set "system.@system[0].hood=$hood"
+	else
+		echo "WARNING: No hoodname set!"
+	fi
+}
+
+apply() {
+	uci commit system
+	uci commit fff
+	echo "$(uci get "system.@system[0].hostname")" > /proc/sys/kernel/hostname
+}
+
+revert() {
+	uci revert system
+	uci revert fff
+}

Comments

Tim Niemeyer March 15, 2019, 8:52 p.m.
Hi

Ich glaube es wäre gut, wenn du ein Beispiel Config mit auslieferst..

Tim

Am Freitag, den 15.03.2019, 21:22 +0100 schrieb Fabian Bläse:
> This adds a configuration script for applying hostname,
> coordinates, hoodname and contact address.
> 
> Signed-off-by: Fabian Bläse <fabian@blaese.de>
> ---
>  .../fff-gateway/files/etc/gateway.d/01-meta   | 43
> +++++++++++++++++++
>  1 file changed, 43 insertions(+)
>  create mode 100644 src/packages/fff/fff-
> gateway/files/etc/gateway.d/01-meta
> 
> diff --git a/src/packages/fff/fff-gateway/files/etc/gateway.d/01-meta 
> b/src/packages/fff/fff-gateway/files/etc/gateway.d/01-meta
> new file mode 100644
> index 0000000..1b4209b
> --- /dev/null
> +++ b/src/packages/fff/fff-gateway/files/etc/gateway.d/01-meta
> @@ -0,0 +1,43 @@
> +configure() {
> +	## set hostname
> +	if name=$(uci -q get gateway.@gateway[0].name); then
> +		uci -q set system.@system[0].hostname="$name"
> +		uci -q set fff.system.hostname="$name"
> +	else
> +		echo "WARNING: No gateway name set!"
> +	fi
> +
> +	## set contact
> +	if contact=$(uci -q get gateway.@gateway[0].contact); then
> +		uci -q set fff.system.contact="$contact"
> +	else
> +		echo "WARNING: No contact set!"
> +	fi
> +
> +	## set location
> +	if lat=$(uci -q get gateway.@gateway[0].latitude) &&
> long=$(uci -q get gateway.@gateway[0].longitude); then
> +		uci -q set fff.system.latitude="$lat"
> +		uci -q set fff.system.longitude="$long"
> +	else
> +		echo "WARNING: No gateway location set!"
> +	fi
> +
> +	## hoodname
> +	if hood=$(uci -q get gateway.@gateway[0].hoodname); then
> +		echo "Setting hood name: $hood"
> +		uci -q set "system.@system[0].hood=$hood"
> +	else
> +		echo "WARNING: No hoodname set!"
> +	fi
> +}
> +
> +apply() {
> +	uci commit system
> +	uci commit fff
> +	echo "$(uci get "system.@system[0].hostname")" >
> /proc/sys/kernel/hostname
> +}
> +
> +revert() {
> +	uci revert system
> +	uci revert fff
> +}
Fabian Blaese March 18, 2019, 9:55 p.m.
Hallo Tim,

joa, sollte irgendwo hin.
Allerdings ist mir bisher noch kein guter Weg eingefallen, wie man das machen könnte.

Kann man ja dann später immer noch hinzufügen.

Fabian

On 15.03.19 21:52, Tim Niemeyer wrote:
> Hi
> 
> Ich glaube es wäre gut, wenn du ein Beispiel Config mit auslieferst..
> 
> Tim