Add DNS cache flushing calls for Linux
authorgfyoung <redacted>
Thu, 18 May 2017 15:23:10 +0000 (11:23 -0400)
committergfyoung <redacted>
Thu, 18 May 2017 15:30:23 +0000 (11:30 -0400)
1) Add command for Linux Mint
2) Add additional command for NCSD cache

Closes gh-128.

updateHostsFile.py

index b9a0ddd204ebbe76259b407d3e3a10037352f5ae..eb66bbae1683455a0f9b3016192c3bb8320ba2b4 100644 (file)
@@ -559,14 +559,17 @@ def flush_dns_cache():
         print("Please copy and paste the command 'ipconfig /flushdns' in "
               "administrator command prompt after running this script.")
     else:
-        if os.path.isfile("/etc/rc.d/init.d/nscd"):
-            dns_cache_found = True
-
-            if subprocess.call(["/usr/bin/sudo", "/etc/rc.d/init.d/nscd",
-                                "restart"]):
-                print_failure("Flushing the DNS cache failed.")
-            else:
-                print_success("Flushing DNS by restarting nscd succeeded")
+        nscd_caches = ["/etc/init.d/nscd",
+                       "/etc/rc.d/init.d/nscd"]
+        for nscd_cache in nscd_caches:
+            if os.path.isfile(nscd_cache):
+                dns_cache_found = True
+
+                if subprocess.call(["/usr/bin/sudo", nscd_cache,
+                                    "restart"]):
+                    print_failure("Flushing the DNS cache failed.")
+                else:
+                    print_success("Flushing DNS by restarting nscd succeeded")
 
         if os.path.isfile("/usr/lib/systemd/system/NetworkManager.service"):
             dns_cache_found = True
@@ -606,6 +609,16 @@ def flush_dns_cache():
                 print_success("Flushing DNS by restarting "
                               "networking.service succeeded")
 
+        if os.path.isfile("/etc/init.d/dns-clean"):
+            dns_cache_found = True
+
+            if subprocess.call(["/usr/bin/sudo", "/etc/init.d/dns-clean",
+                                "start"]):
+                print_failure("Flushing the DNS cache failed.")
+            else:
+                print_success("Flushing DNS via dns-clean "
+                              "executable succeeded")
+
         if not dns_cache_found:
             print_failure("Unable to determine DNS management tool.")
 
git clone https://git.99rst.org/PROJECT