Add DNS cache flushing calls for Linux

1) Add command for Linux Mint
2) Add additional command for NCSD cache

Closes gh-128.
This commit is contained in:
gfyoung
2017-05-18 11:23:10 -04:00
parent c0196ce5dc
commit b3838ef2d2

View 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
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", "/etc/rc.d/init.d/nscd",
"restart"]):
print_failure("Flushing the DNS cache failed.")
else:
print_success("Flushing DNS by restarting nscd succeeded")
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.")