Skip to content

Commit

Permalink
Add a parameter to pidofFTL() function to allow a delay if necessary
Browse files Browse the repository at this point in the history
Signed-off-by: RD WebDesign <[email protected]>
  • Loading branch information
rdwebdesign committed Apr 10, 2023
1 parent f6acb8f commit d010187
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion scripts/pi-hole/php/func.php
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,12 @@ function convertUnicodeToIDNA($unicode)
}

// Return PID of FTL (used in settings.php)
function pidofFTL()
function pidofFTL($add_delay = false)
{
if ($add_delay) {
usleep(100000);
}

return shell_exec('pidof pihole-FTL');
}

Expand Down
3 changes: 3 additions & 0 deletions scripts/pi-hole/php/savesettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ function addStaticDHCPLease($mac, $ip, $hostname)

$error = '';
$success = '';
$FTLrestarted = false;

if (isset($_POST['field'])) {
// Handle CSRF
Expand Down Expand Up @@ -445,6 +446,7 @@ function addStaticDHCPLease($mac, $ip, $hostname)

case 'restartdns':
pihole_execute('-a restartdns');
$FTLrestarted = true;
$success = 'The DNS server has been restarted';

break;
Expand Down Expand Up @@ -554,6 +556,7 @@ function addStaticDHCPLease($mac, $ip, $hostname)

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';
Expand Down
2 changes: 1 addition & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
<div class="row">
<div class="col-lg-12">
<?php
$FTLpid = intval(pidofFTL());
$FTLpid = intval(pidofFTL($FTLrestarted));
if ($FTLpid !== 0) {
$FTLversion = exec('/usr/bin/pihole-FTL version'); ?>
<table class="table table-striped table-bordered nowrap">
Expand Down

0 comments on commit d010187

Please sign in to comment.