From patchwork Mon Jan 27 13:25:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [5/5] VARIANT layer3: generate hoodfile From: Robert Langhammer X-Patchwork-Id: 1269 Message-Id: <20200127132512.16359-6-rlanghammer@web.de> To: franken-dev@freifunk.net Date: Mon, 27 Jan 2020 14:25:12 +0100 This generates a hoodfile out of config/gateway and config/fff. Signed-off-by: Robert Langhammer --- .../files/etc/gateway.d/90-generate-hoodfile | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/packages/fff/fff-gateway/files/etc/gateway.d/90-generate-hoodfile -- 2.20.1 diff --git a/src/packages/fff/fff-gateway/files/etc/gateway.d/90-generate-hoodfile b/src/packages/fff/fff-gateway/files/etc/gateway.d/90-generate-hoodfile new file mode 100644 index 0000000..f61415f --- /dev/null +++ b/src/packages/fff/fff-gateway/files/etc/gateway.d/90-generate-hoodfile @@ -0,0 +1,37 @@ +# source jshn shell library +. /usr/share/libubox/jshn.sh + +configure() { + # remove old hoodfile + rm /www/hood/keyxchangev2data + + # generating json data + json_init + json_add_string "version" "1" + + json_add_object "network" + json_add_string "ula_prefix" "$(uci get gateway.@client[0].ip6addr | sed 's/.*\(fd43[^ ]*\).*/\1/' | sed 's;::.\{1,4\}/;:/;')" + json_close_object + + json_add_object "hood" + json_add_string "name" "$(uci -q get fff.system.hoodname)" + json_add_string "essid" "$(uci -q get gateway.@client[0].essid)" + json_add_string "mesh_id" "$(uci -q get gateway.@client[0].mesh_id)" + json_add_string "channel2" "$(uci -q get gateway.@client[0].chan2ghz)" + json_add_string "mode2" "ht20" + json_add_string "mesh_type2" "802.11s" + json_add_string "channel5" "$(uci -q get gateway.@client[0].chan5ghz)" + json_add_string "mode5" "ht20" + json_add_string "mesh_type5" "802.11s" + json_add_string "upgrade_path" "http://[fd43:5602:29bd:ffff::feee]:83" + json_add_string "ntp_ip" "fd43:5602:29bd:ffff::1" + json_add_string "timestamp" "$(date +%s)" + json_close_object + + json_dump > /www/hood/keyxchangev2data +} + +revert() { + configure +} +