From bb1b8e81aeccdb2715b905abf959265da13636b4 Mon Sep 17 00:00:00 2001 From: Max G Date: Fri, 10 Jul 2020 23:48:36 +0300 Subject: [PATCH] Check if a service has already been restarted (Fixes #1338) --- updateHostsFile.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/updateHostsFile.py b/updateHostsFile.py index 8eaff17177c..34c7032adb1 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -1293,6 +1293,7 @@ def flush_dns_cache(): system_prefixes = ["/usr", ""] service_types = ["NetworkManager", "wicd", "dnsmasq", "networking"] + restarted_services = [] for system_prefix in system_prefixes: systemctl = system_prefix + "/bin/systemctl" @@ -1300,6 +1301,9 @@ def flush_dns_cache(): for service_type in service_types: service = service_type + ".service" + if service in restarted_services: + continue + service_file = path_join_robust(system_dir, service) service_msg = ( "Flushing the DNS cache by restarting " + service + " {result}" @@ -1312,6 +1316,7 @@ def flush_dns_cache(): print_failure(service_msg.format(result="failed")) else: print_success(service_msg.format(result="succeeded")) + restarted_services += [service] dns_clean_file = "/etc/init.d/dns-clean" dns_clean_msg = "Flushing the DNS cache via dns-clean executable {result}"