[pve-devel] [PATCH pve-network] dnsmasq: check for existence of dnsmasq binary
Stefan Hanreich
s.hanreich at proxmox.com
Wed Nov 22 19:33:47 CET 2023
Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
src/PVE/Network/SDN/Dhcp/Dnsmasq.pm | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
index 654f9e4..ed930cf 100644
--- a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
+++ b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
@@ -11,6 +11,8 @@ use PVE::Tools qw(file_set_contents run_command lock_file);
use File::Copy;
use Net::DBus;
+use PVE::RESTEnvironment qw(log_warn);
+
my $DNSMASQ_CONFIG_ROOT = '/etc/dnsmasq.d';
my $DNSMASQ_DEFAULT_ROOT = '/etc/default';
my $DNSMASQ_LEASE_ROOT = '/var/lib/misc';
@@ -236,6 +238,12 @@ sub after_configure {
sub before_regenerate {
my ($class) = @_;
+ my $bin_path = "/usr/sbin/dnsmasq";
+ if (!-e $bin_path) {
+ log_warn("Please install dnsmasq in order to use the DHCP feature!");
+ die;
+ }
+
PVE::Tools::run_command(['systemctl', 'stop', "dnsmasq@*"]);
PVE::Tools::run_command(['systemctl', 'disable', 'dnsmasq@']);
}
--
2.39.2
More information about the pve-devel
mailing list