From 0810a08519c6a18c4adbb059d940e94a185a8661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Wed, 15 Dec 2021 09:10:05 +0100 Subject: [PATCH] manman tweaks --- package/gluon-config-mode-manman-sync/i18n/de.po | 2 +- .../i18n/gluon-config-mode-manman-sync.pot | 2 +- .../gluon/config-mode/wizard/0100-manman-sync.lua | 4 ++-- .../gluon-manman-sync/luasrc/usr/bin/manman-sync | 14 +++++++++++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/package/gluon-config-mode-manman-sync/i18n/de.po b/package/gluon-config-mode-manman-sync/i18n/de.po index 5b04eddb..014d314e 100644 --- a/package/gluon-config-mode-manman-sync/i18n/de.po +++ b/package/gluon-config-mode-manman-sync/i18n/de.po @@ -19,7 +19,7 @@ msgid "ManMan location ID" msgstr "ManMan Standort-ID" msgid "" -"Sync data from ManMan by entering ManMan location id here.\n" +"Sync configuration from ManMan by entering ManMan location id here.\n" "This will automatically keep name, location and ips in sync with the values " "specified in ManMan." msgstr "" diff --git a/package/gluon-config-mode-manman-sync/i18n/gluon-config-mode-manman-sync.pot b/package/gluon-config-mode-manman-sync/i18n/gluon-config-mode-manman-sync.pot index b974cd47..3e7c4638 100644 --- a/package/gluon-config-mode-manman-sync/i18n/gluon-config-mode-manman-sync.pot +++ b/package/gluon-config-mode-manman-sync/i18n/gluon-config-mode-manman-sync.pot @@ -8,7 +8,7 @@ msgid "ManMan location ID" msgstr "" msgid "" -"Sync data from ManMan " +"Sync configuration from ManMan " "by entering ManMan location id here.\n" "This will automatically keep name, location and ips " "in sync with the values specified in ManMan." diff --git a/package/gluon-config-mode-manman-sync/luasrc/lib/gluon/config-mode/wizard/0100-manman-sync.lua b/package/gluon-config-mode-manman-sync/luasrc/lib/gluon/config-mode/wizard/0100-manman-sync.lua index e6af0c6f..ef08550e 100644 --- a/package/gluon-config-mode-manman-sync/luasrc/lib/gluon/config-mode/wizard/0100-manman-sync.lua +++ b/package/gluon-config-mode-manman-sync/luasrc/lib/gluon/config-mode/wizard/0100-manman-sync.lua @@ -6,8 +6,8 @@ return function(form, uci) local pkg_i18n = i18n 'gluon-config-mode-manman-sync' local msg = pkg_i18n.translate( - 'Sync data from ManMan ' .. - 'by entering ManMan location id here.\n' .. + 'Sync configuration from ManMan ' .. + 'by entering ManMan location id here.\n' .. 'This will automatically keep name, location and ips ' .. 'in sync with the values specified in ManMan.' ) diff --git a/package/gluon-manman-sync/luasrc/usr/bin/manman-sync b/package/gluon-manman-sync/luasrc/usr/bin/manman-sync index c2f4e076..6771215d 100755 --- a/package/gluon-manman-sync/luasrc/usr/bin/manman-sync +++ b/package/gluon-manman-sync/luasrc/usr/bin/manman-sync @@ -12,12 +12,16 @@ local mappings = { } if uci:get_bool('gluon', 'manman_sync', 'enabled') then - if not uci:get('gluon', 'manman_sync', 'location_id') then + local location_id = uci:get('gluon', 'manman_sync', 'location_id') + + if not location_id then print('E: manman location_id missing') return 2 end - -- check manman location, abort if not reachable + -- check manman reachability, abort if not reachable + + -- get location from ip location = getLocation() print('Syncing with location ' .. location['name']) @@ -48,7 +52,10 @@ if uci:get_bool('gluon', 'manman_sync', 'enabled') then for index, net in ipairs(device['networks']) do net_name = net['name'] - net_mapped = 'mesh_' .. (mappings[net_name] or net_name) + net_mapped = mappings[net_name] or net_name + if not string.find(net_mapped, '_') then + net_mapped = 'mesh_' .. net_mapped + end cidr = ip.new(net['ip'], net['netmask']):string() @@ -57,6 +64,7 @@ if uci:get_bool('gluon', 'manman_sync', 'enabled') then end -- TODO: exec gluon-reload + print('Reloading...') else print('manman-sync not enabled, skipping') end