mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-25 22:06:58 +00:00
try to keep comments in /etc/network/interfaces
This commit is contained in:
parent
9934cd0bd1
commit
72ca652054
2
Makefile
2
Makefile
@ -1,7 +1,7 @@
|
|||||||
RELEASE=2.0
|
RELEASE=2.0
|
||||||
|
|
||||||
VERSION=1.0
|
VERSION=1.0
|
||||||
PKGREL=15
|
PKGREL=16
|
||||||
|
|
||||||
PACKAGE=libpve-common-perl
|
PACKAGE=libpve-common-perl
|
||||||
|
|
||||||
|
@ -722,44 +722,51 @@ sub read_etc_network_interfaces {
|
|||||||
$ifaces->{$i}->{method} = $2;
|
$ifaces->{$i}->{method} = $2;
|
||||||
|
|
||||||
my $d = $ifaces->{$i};
|
my $d = $ifaces->{$i};
|
||||||
while (defined ($line = <$fh>) && ($line =~ m/^\s+((\S+)\s+(.+))$/)) {
|
while (defined ($line = <$fh>)) {
|
||||||
my $option = $1;
|
if ($line =~ m/^#(.*)\s*$/) {
|
||||||
my ($id, $value) = ($2, $3);
|
$d->{comment} = '' if !$d->{comment};
|
||||||
if (($id eq 'address') || ($id eq 'netmask') || ($id eq 'broadcast')) {
|
$d->{comment} .= PVE::Tools::decode_text($1) . "\n";
|
||||||
$d->{$id} = $value;
|
} elsif ($line =~ m/^\s+((\S+)\s+(.+))$/) {
|
||||||
} elsif ($id eq 'gateway') {
|
my $option = $1;
|
||||||
$d->{$id} = $value;
|
my ($id, $value) = ($2, $3);
|
||||||
$gateway = 1;
|
if (($id eq 'address') || ($id eq 'netmask') || ($id eq 'broadcast')) {
|
||||||
} elsif ($id eq 'slaves' || $id eq 'bridge_ports') {
|
$d->{$id} = $value;
|
||||||
my $devs = {};
|
} elsif ($id eq 'gateway') {
|
||||||
foreach my $p (split (/\s+/, $value)) {
|
$d->{$id} = $value;
|
||||||
next if $p eq 'none';
|
$gateway = 1;
|
||||||
$devs->{$p} = 1;
|
} elsif ($id eq 'slaves' || $id eq 'bridge_ports') {
|
||||||
}
|
my $devs = {};
|
||||||
my $str = join (' ', sort keys %{$devs});
|
foreach my $p (split (/\s+/, $value)) {
|
||||||
$d->{$id} = $str || '';
|
next if $p eq 'none';
|
||||||
} elsif ($id eq 'bridge_stp') {
|
$devs->{$p} = 1;
|
||||||
if ($value =~ m/^\s*(on|yes)\s*$/i) {
|
|
||||||
$d->{$id} = 'on';
|
|
||||||
} else {
|
|
||||||
$d->{$id} = 'off';
|
|
||||||
}
|
|
||||||
} elsif ($id eq 'bridge_fd') {
|
|
||||||
$d->{$id} = $value;
|
|
||||||
} elsif ($id eq 'bond_miimon') {
|
|
||||||
$d->{$id} = $value;
|
|
||||||
} elsif ($id eq 'bond_mode') {
|
|
||||||
# always use names
|
|
||||||
foreach my $bm (keys %$bond_modes) {
|
|
||||||
my $id = $bond_modes->{$bm};
|
|
||||||
if ($id eq $value) {
|
|
||||||
$value = $bm;
|
|
||||||
last;
|
|
||||||
}
|
}
|
||||||
|
my $str = join (' ', sort keys %{$devs});
|
||||||
|
$d->{$id} = $str || '';
|
||||||
|
} elsif ($id eq 'bridge_stp') {
|
||||||
|
if ($value =~ m/^\s*(on|yes)\s*$/i) {
|
||||||
|
$d->{$id} = 'on';
|
||||||
|
} else {
|
||||||
|
$d->{$id} = 'off';
|
||||||
|
}
|
||||||
|
} elsif ($id eq 'bridge_fd') {
|
||||||
|
$d->{$id} = $value;
|
||||||
|
} elsif ($id eq 'bond_miimon') {
|
||||||
|
$d->{$id} = $value;
|
||||||
|
} elsif ($id eq 'bond_mode') {
|
||||||
|
# always use names
|
||||||
|
foreach my $bm (keys %$bond_modes) {
|
||||||
|
my $id = $bond_modes->{$bm};
|
||||||
|
if ($id eq $value) {
|
||||||
|
$value = $bm;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$d->{$id} = $value;
|
||||||
|
} else {
|
||||||
|
push @{$d->{options}}, $option;
|
||||||
}
|
}
|
||||||
$d->{$id} = $value;
|
|
||||||
} else {
|
} else {
|
||||||
push @{$d->{options}}, $option;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -864,6 +871,12 @@ sub __interface_to_string {
|
|||||||
$raw .= "\t$option\n";
|
$raw .= "\t$option\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# add comments
|
||||||
|
my $comment = $d->{comment} || '';
|
||||||
|
foreach my $cl (split(/\n/, $comment)) {
|
||||||
|
$raw .= '#' . PVE::Tools::encode_text($cl) . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
$raw .= "\n";
|
$raw .= "\n";
|
||||||
|
|
||||||
return $raw;
|
return $raw;
|
||||||
|
6
debian/changelog
vendored
6
debian/changelog
vendored
@ -1,3 +1,9 @@
|
|||||||
|
libpve-common-perl (1.0-16) unstable; urgency=low
|
||||||
|
|
||||||
|
* try to keep comments in /etc/network/interfaces
|
||||||
|
|
||||||
|
-- Proxmox Support Team <support@proxmox.com> Thu, 01 Mar 2012 09:49:22 +0100
|
||||||
|
|
||||||
libpve-common-perl (1.0-15) unstable; urgency=low
|
libpve-common-perl (1.0-15) unstable; urgency=low
|
||||||
|
|
||||||
* add Swedish keymap
|
* add Swedish keymap
|
||||||
|
Loading…
Reference in New Issue
Block a user