From 43447cd3bd7bd4dd3479898f16acd2a3f1df90fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Sun, 16 Jan 2022 05:49:27 +0100 Subject: [PATCH] manman-sync: only re-sync if changed --- package/gluon-manman-sync/luasrc/usr/bin/manman-sync | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/package/gluon-manman-sync/luasrc/usr/bin/manman-sync b/package/gluon-manman-sync/luasrc/usr/bin/manman-sync index fad694b1..345c68e0 100755 --- a/package/gluon-manman-sync/luasrc/usr/bin/manman-sync +++ b/package/gluon-manman-sync/luasrc/usr/bin/manman-sync @@ -126,6 +126,11 @@ if uci:get_bool('gluon-manman-sync', 'sync', 'enabled') then print('Syncing with location ' .. location.location.name) + if uci:get('gluon-manman-sync', 'sync', 'last_data') and json.stringify(location) == uci:get('gluon-manman-sync', 'sync', 'last_data') then + print('Nothing changed, skipping sync') + return 0 + end + local owner = uci:get_first('gluon-node-info', 'owner') uci:set('gluon-node-info', owner, 'contact', location.administrator.email) local _location = uci:get_first('gluon-node-info', 'location') @@ -179,6 +184,8 @@ if uci:get_bool('gluon-manman-sync', 'sync', 'enabled') then uci:set('gluon-static-ip', net_mapped, 'ip4', cidr) end + uci:set('gluon-manman-sync', 'sync', 'last_data', json.stringify(location)) + uci:save('system') uci:save('gluon-manman-sync') uci:save('gluon-static-ip')