mirror of
https://github.com/webmin/webmin.git
synced 2026-06-04 20:30:22 +01:00
ⓘ 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
33 lines
701 B
Perl
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;
|