Implement dnsmasq restart button

This commit is contained in:
billz
2025-07-28 13:34:45 -07:00
parent f30abc4bd7
commit 3c1d4325f2
2 changed files with 13 additions and 0 deletions

View File

@@ -37,6 +37,18 @@ function DisplayDHCPConfig()
$status->addMessage('Failed to start dnsmasq', 'danger'); $status->addMessage('Failed to start dnsmasq', 'danger');
} }
} }
} elseif (isset($_POST['restartdhcpd'])) {
if ($dnsmasq_state) {
exec('sudo /bin/systemctl restart dnsmasq.service', $dnsmasq, $return);
if ($return == 0) {
$status->addMessage('Successfully restarted dnsmasq', 'success');
$dnsmasq_state = false;
} else {
$status->addMessage('Failed to restart dnsmasq', 'danger');
}
} else {
$status->addMessage('dnsmasq already stopped', 'info');
}
} elseif (isset($_POST['stopdhcpd'])) { } elseif (isset($_POST['stopdhcpd'])) {
if ($dnsmasq_state) { if ($dnsmasq_state) {
exec('sudo /bin/systemctl stop dnsmasq.service', $dnsmasq, $return); exec('sudo /bin/systemctl stop dnsmasq.service', $dnsmasq, $return);

View File

@@ -3,6 +3,7 @@
<input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" /> <input type="submit" class="btn btn-outline btn-primary" value="<?php echo _("Save settings"); ?>" name="savedhcpdsettings" />
<?php if ($dnsmasq_state) : ?> <?php if ($dnsmasq_state) : ?>
<input type="submit" class="btn btn-warning" value="<?php echo _("Stop dnsmasq") ?>" name="stopdhcpd" /> <input type="submit" class="btn btn-warning" value="<?php echo _("Stop dnsmasq") ?>" name="stopdhcpd" />
<input type="submit" class="btn btn-warning" value="<?php echo _("Restart dnsmasq") ?>" name="restartdhcpd" />
<?php else : ?> <?php else : ?>
<input type="submit" class="btn btn-success" value="<?php echo _("Start dnsmasq") ?>" name="startdhcpd" /> <input type="submit" class="btn btn-success" value="<?php echo _("Start dnsmasq") ?>" name="startdhcpd" />
<?php endif ?> <?php endif ?>