From d687823a2732aff3a44e354e326d200b092d6baf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabian=20Bl=C3=A4se?= <fabian@blaese.de>
Date: Tue, 23 Apr 2019 18:09:07 +0200
Subject: [PATCH] gateway.d: Add configuration script for meta information
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This adds a configuration script for applying hostname,
coordinates, hoodname and contact address.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
Reviewed-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Reviewed-by: Tim Niemeyer <tim@tn-x.org>
---
 .../fff-gateway/files/etc/gateway.d/10-meta   | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 src/packages/fff/fff-gateway/files/etc/gateway.d/10-meta

diff --git a/src/packages/fff/fff-gateway/files/etc/gateway.d/10-meta b/src/packages/fff/fff-gateway/files/etc/gateway.d/10-meta
new file mode 100644
index 00000000..3b8c9d21
--- /dev/null
+++ b/src/packages/fff/fff-gateway/files/etc/gateway.d/10-meta
@@ -0,0 +1,37 @@
+configure() {
+	## set hostname
+	if name=$(uci -q get fff.system.hostname); then
+		uci -q set system.@system[0].hostname="$name"
+	else
+		echo "WARNING: No hostname set!"
+	fi
+
+	## set contact
+	if ! contact=$(uci -q get fff.system.contact); then
+		echo "WARNING: No contact set!"
+	fi
+
+	## set location
+	if ! lat=$(uci -q get fff.system.latitude) || ! long=$(uci -q get fff.system.longitude); then
+		echo "WARNING: No location set!"
+	fi
+
+	## hoodname
+	if hood=$(uci -q get fff.system.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
+}
-- 
GitLab