tinc-refresh: log files that change

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-11-24 16:37:41 +01:00
parent aa5ef63f1f
commit ac288bb169
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 7 additions and 4 deletions

View File

@ -156,7 +156,10 @@ def check_file_change(mod_func):
before = md5(file_path)
mod_func(file_path, data)
after = md5(file_path)
return before != after
changed = before != after
if changed:
LOG.info('Changed: %s', file_path)
return changed
return wrapper
@check_file_change
@ -259,9 +262,6 @@ LOG.debug('Saving VNP IP: %s', vpn_ip)
with open('{}/tinc-ip'.format(tinc_network_path), 'w') as f:
f.write(vpn_ip)
LOG.debug('Updating main config file')
config_changed = write_config(tinc_config_path, sorted_services)
LOG.debug('Generating host config files')
hosts_changed = []
for service in sorted_services:
@ -270,6 +270,9 @@ for service in sorted_services:
)
hosts_changed.append(add_host_config(host_config_path, service))
LOG.debug('Updating main config file')
config_changed = write_config(tinc_config_path, sorted_services)
# Avoid reloading Tinc if possible
if not config_changed and not any(hosts_changed):
LOG.info('No changes detected')