Files
webmin/net/net-detect.pl
Ilia Ross 6574373761 Fix to detect NetworkManager networking on Debian
ⓘ Prefer Netplan when Debian has Netplan YAML config, otherwise select the existing NetworkManager backend for Debian systems with saved NM connection profiles, with regression tests for backend selection.

https://github.com/webmin/webmin/issues/2559
2026-06-02 01:33:59 +02:00

33 lines
701 B
Perl

# net-detect.pl
# Helper functions for choosing the network config backend
sub net_has_network_manager_config
{
my ($dir) = @_;
$dir ||= "/etc/NetworkManager/system-connections";
my @files = glob("$dir/*.nmconnection");
return -d $dir && scalar(@files);
}
sub net_has_netplan_config
{
my ($dir) = @_;
$dir ||= "/etc/netplan";
return &has_command("netplan") &&
-d $dir;
}
sub net_auto_backend
{
my ($os_type, $netplan_dir, $nm_conn_dir) = @_;
return "netplan"
if ($os_type eq "debian-linux" &&
&net_has_netplan_config($netplan_dir));
return "nm"
if (($os_type eq "redhat-linux" || $os_type eq "debian-linux") &&
&net_has_network_manager_config($nm_conn_dir));
return undef;
}
1;