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

Fabian Bläse fabian at blaese.de
Mo Mär 18 22:54:00 CET 2019


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

Signed-off-by: Fabian Bläse <fabian at 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. at gateway[0].name); then
+		uci -q set system. at 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. at 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. at gateway[0].latitude) && long=$(uci -q get gateway. at 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. at gateway[0].hoodname); then
+		echo "Setting hood name: $hood"
+		uci -q set "system. at system[0].hood=$hood"
+	else
+		echo "WARNING: No hoodname set!"
+	fi
+}
+
+apply() {
+	uci commit system
+	uci commit fff
+	echo "$(uci get "system. at system[0].hostname")" > /proc/sys/kernel/hostname
+}
+
+revert() {
+	uci revert system
+	uci revert fff
+}
-- 
2.21.0



Mehr Informationen über die Mailingliste franken-dev