]> git.proxmox.com Git - pve-container.git/commitdiff
setup/debian: avoid writing multiple auto lines
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 16 Oct 2015 06:31:58 +0000 (08:31 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 16 Oct 2015 07:41:54 +0000 (09:41 +0200)
src/PVE/LXC/Setup/Debian.pm

index 819a2841dc6a76d8d57eb885f5c004a19c5ec945..752d670613c5a59641429c0b33e1d38e0404d3bf 100644 (file)
@@ -113,6 +113,7 @@ sub setup_network {
 
     my $section;
 
+    my $done_auto = {};
     my $done_v4_hash = {};
     my $done_v6_hash = {};
     
@@ -123,11 +124,14 @@ sub setup_network {
 
        my $net = $networks->{$section->{ifname}};
 
+       if ($new && !$done_auto->{$section->{ifname}}) {
+           $interfaces .= "auto $section->{ifname}\n";
+           $done_auto->{$section->{ifname}} = 1;
+       }
+
        if ($section->{type} eq 'ipv4') {
            $done_v4_hash->{$section->{ifname}} = 1;
 
-           $interfaces .= "auto $section->{ifname}\n" if $new;
-
            if ($net->{address} =~ /^(dhcp|manual)$/) {
                $interfaces .= "iface $section->{ifname} inet $1\n";
            } elsif ($net->{address}) {
@@ -200,9 +204,17 @@ sub setup_network {
                $section = { type => 'ipv6', ifname => $ifname, attr => []};
                next;
            }
+           # Handle 'auto'
+           if ($line =~ m/^\s*auto\s*(.*)$/) {
+               foreach my $iface (split(/\s+/, $1)) {
+                   $done_auto->{$iface} = 1;
+               }
+               &$print_section();
+               $interfaces .= "$line\n";
+               next;
+           }
            # Handle other section delimiters:
            if ($line =~ m/^\s*(?:mapping\s
-                                |auto\s
                                 |allow-
                                 |source\s
                                 |source-directory\s