From: Stefan Hanreich Date: Wed, 22 Nov 2023 18:33:47 +0000 (+0100) Subject: dnsmasq: check for existence of dnsmasq binary X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=2c298fa1f8d584d2d00176ecc699cd65b56adea5;p=matthieu%2Fpve-network.git dnsmasq: check for existence of dnsmasq binary Signed-off-by: Stefan Hanreich --- diff --git a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm index 58ce387..8b022fc 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'; @@ -237,6 +239,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@']); }