Newer
Older
From ff190d99d664cd5e641d878ce6565f71b5b912c8 Mon Sep 17 00:00:00 2001
From: runner01 <runner01@ffnw.de>
Date: Mon, 18 Mar 2019 21:29:26 +0100
Subject: [PATCH 4/4] hoodselector to domain migration
Domain migration: restart services after migration
Signed-off-by: runner01 <runner01@ffnw.de>
.../luasrc/lib/gluon/upgrade/010-domain-migrate | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 package/gluon-hoodselector/luasrc/lib/gluon/upgrade/010-domain-migrate
diff --git a/package/gluon-hoodselector/luasrc/lib/gluon/upgrade/010-domain-migrate b/package/gluon-hoodselector/luasrc/lib/gluon/upgrade/010-domain-migrate
new file mode 100644
index 00000000..9146970b
--- /dev/null
+++ b/package/gluon-hoodselector/luasrc/lib/gluon/upgrade/010-domain-migrate
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
+#!/usr/bin/lua
+
+local uci = require('simple-uci').cursor()
+local hoodutil = require('hoodselector.util')
+
+local last_hood = uci:get('hoodselector', 'hoodselector', 'hood')
+
+-- Return domain based on a given MESH-ID. nil if no matching domain could be found
+function get_domain_by_meshid(jdomains, meshid)
+ for _, jdomain in pairs(jdomains) do
+ if jdomain.domain.wifi24 ~= nil then
+ if jdomain.domain.wifi24.mesh ~= nil then
+ if meshid:lower() == jdomain.domain.wifi24.mesh.id:lower() then
+ return jdomain
+ end
+ end
+ end
+ if jdomain.domain.wifi5 ~= nil then
+ if jdomain.domain.wifi5.mesh ~= nil then
+ if meshid:lower() == jdomain.domain.wifi5.mesh.id:lower() then
+ return jdomain
+ end
+ end
+ end
+ end
+ return nil
+end
+
+if last_hood ~= nil then
+ print(last_hood)
+ local new_domain = get_domain_by_meshid(hoodutil.get_domains(),"ffnw-mesh_"..last_hood)
+ if new_domain ~= nil then
+ print(new_domain.domain_code)
+ hoodutil.set_domain_config(new_domain)
+ os.execute("rm /etc/config/hoodselector")
+ hoodutil.restart_services()
+ end
+end
--
2.11.0