diff --git a/scripts/pi-hole/js/restartdns.js b/scripts/pi-hole/js/restartdns.js new file mode 100644 index 00000000..248fac07 --- /dev/null +++ b/scripts/pi-hole/js/restartdns.js @@ -0,0 +1,39 @@ +/* Pi-hole: A black hole for Internet advertisements + * (c) 2017 Pi-hole, LLC (https://pi-hole.net) + * Network-wide ad blocking via your own hardware. + * + * This file is copyright under the latest version of the EUPL. + * Please see LICENSE file for your rights under this license. */ + +var timeleft = 60; +var status = -1; +var reloadMsg = + "FTL was restarted: Reload FTL details."; +var warningMsg = "FTL was not able to reload after " + timeleft + " seconds."; +var counterMsg = "FTL is reloading: "; + +var reloadTimer = setInterval(function () { + $.getJSON("api.php?dns-port", function (data) { + if ("FTLnotrunning" in data) { + return; + } + + status = data["dns-port"]; + }); + + if (timeleft <= 0 || status >= 0) { + clearInterval(reloadTimer); + if (status < 0) { + // FTL was not restarted in 60 seconds. Show warning message + document.getElementById("restart-countdown").innerHTML = warningMsg; + } else { + // FTL restartd. + document.getElementById("restart-countdown").innerHTML = reloadMsg; + } + } else { + document.getElementById("restart-countdown").innerHTML = + counterMsg + timeleft + " seconds remaining..."; + } + + timeleft -= 1; +}, 1000); diff --git a/scripts/pi-hole/php/savesettings.php b/scripts/pi-hole/php/savesettings.php index 41f03a64..c4ba3c17 100644 --- a/scripts/pi-hole/php/savesettings.php +++ b/scripts/pi-hole/php/savesettings.php @@ -197,6 +197,7 @@ $DNSserverslist = readDNSserversList(); $error = ''; $success = ''; +$FTLrestarted = false; if (isset($_POST['field'])) { // Handle CSRF @@ -445,6 +446,7 @@ if (isset($_POST['field'])) { case 'restartdns': pihole_execute('-a restartdns'); + $FTLrestarted = true; $success = 'The DNS server has been restarted'; break; @@ -554,6 +556,7 @@ if (isset($_POST['field'])) { if ($privacylevel > $level) { pihole_execute('-a restartdns'); + $FTLrestarted = true; $success .= 'The privacy level has been decreased and the DNS resolver has been restarted'; } elseif ($privacylevel < $level) { $success .= 'The privacy level has been increased'; diff --git a/settings.php b/settings.php index 5f9ed866..6ad968d9 100644 --- a/settings.php +++ b/settings.php @@ -240,10 +240,13 @@ if (isset($_GET['tab']) && in_array($_GET['tab'], array('sysadmin', 'dns', 'piho
| Time FTL started: | -+ | |
|---|---|---|
| User / Group: | -/ | +|
| Total CPU utilization: | -% | +% |
| Memory utilization: | -% | +% |
| @@ -298,10 +300,20 @@ if ($FTLpid !== 0) { |