mirror of
https://github.com/webmin/webmin.git
synced 2025-07-29 11:50:54 +00:00
Attempt to preserve unknown config entries
This commit is contained in:
@ -25,6 +25,7 @@ foreach my $f (glob("$netplan_dir/*.yaml")) {
|
||||
my $cfg = { 'name' => $e->{'name'},
|
||||
'fullname' => $e->{'name'},
|
||||
'file' => $f,
|
||||
'yaml' => $e,
|
||||
'line' => $e->{'line'},
|
||||
'eline' => $e->{'eline'},
|
||||
'edit' => 1,
|
||||
@ -211,6 +212,16 @@ else {
|
||||
push(@lines, $id." "."macaddress: ".$iface->{'ether'});
|
||||
}
|
||||
|
||||
# Add all extra YAML directives from the original config
|
||||
my @poss = ( "optional", "dhcp4", "dhcp6", "addresses", "gateway4",
|
||||
"gateway6", "nameservers", "macaddress" );
|
||||
if ($iface->{'yaml'}) {
|
||||
foreach my $y (@{$yaml->{'members'}}) {
|
||||
next if (&indexof($y->{'name'}, @poss) >= 0);
|
||||
push(@lines, &yaml_lines($y, $id." "));
|
||||
}
|
||||
}
|
||||
|
||||
if ($iface->{'file'}) {
|
||||
# Replacing an existing interface
|
||||
my ($old) = grep { $_->{'fullname'} eq $iface->{'fullname'} } @$boot;
|
||||
@ -582,6 +593,23 @@ foreach my $origl (@$lref) {
|
||||
return $rv;
|
||||
}
|
||||
|
||||
# yaml_lines(&directive, indent-string)
|
||||
sub yaml_lines
|
||||
{
|
||||
my ($yaml, $id) = @_;
|
||||
my @rv;
|
||||
push(@rv, $id.$yaml->{'name'}.":".
|
||||
(ref($yaml->{'value'}) eq 'ARRAY' ?
|
||||
" [".&join_addr_list(@{$yaml->{'value'}})."]" :
|
||||
defined($yaml->{'value'}) ? " ".$yaml->{'value'} : ""));
|
||||
if ($yaml->{'members'}) {
|
||||
foreach my $m (@{$yaml->{'members'}}) {
|
||||
push(@rv, &yaml_lines($m, $id." "));
|
||||
}
|
||||
}
|
||||
return @rv;
|
||||
}
|
||||
|
||||
# set_parent_elines(&conf, eline)
|
||||
sub set_parent_elines
|
||||
{
|
||||
|
Reference in New Issue
Block a user