]> git.proxmox.com Git - pve-installer.git/blobdiff - proxinstall
raise postifx main.cf compatibility_level to 2
[pve-installer.git] / proxinstall
index b06da138a166a46a64a349c30dd62e95722636cf..6ee3aa0bad000365e132f4a8d0969eb31be452c3 100755 (executable)
@@ -328,6 +328,8 @@ mynetworks = 127.0.0.0/8
 inet_interfaces = loopback-only
 recipient_delimiter = +
 
+compatibility_level = 2
+
 _EOD
 
 sub shellquote {
@@ -620,7 +622,7 @@ sub hd_list {
 
 sub read_cmap {
     my $countryfn = "${proxmox_libdir}/country.dat";
-    open (TMP, "<$countryfn") || die "unable to open '$countryfn' - $!\n";
+    open (TMP, "<:encoding(utf8)", "$countryfn") || die "unable to open '$countryfn' - $!\n";
     my $line;
     my $country = {};
     my $countryhash = {};
@@ -1164,21 +1166,29 @@ sub prepare_grub_efi_boot_esp {
     syscmd("mount -n $espdev -t vfat $targetdir/boot/efi") == 0 ||
        die "unable to mount $espdev\n";
 
-    my $rc = syscmd("chroot $targetdir /usr/sbin/grub-install --target x86_64-efi --no-floppy --bootloader-id='proxmox' $dev");
-    if ($rc != 0) {
-       if ($boot_type eq 'efi') {
-           die "unable to install the EFI boot loader on '$dev'\n";
-       } else {
-           warn "unable to install the EFI boot loader on '$dev', ignoring (not booted using UEFI)\n";
+    eval {
+       my $rc = syscmd("chroot $targetdir /usr/sbin/grub-install --target x86_64-efi --no-floppy --bootloader-id='proxmox' $dev");
+       if ($rc != 0) {
+           if ($boot_type eq 'efi') {
+               die "unable to install the EFI boot loader on '$dev'\n";
+           } else {
+               warn "unable to install the EFI boot loader on '$dev', ignoring (not booted using UEFI)\n";
+           }
        }
-    }
-    # also install fallback boot file (OVMF does not boot without)
-    mkdir("$targetdir/boot/efi/EFI/BOOT");
-    syscmd("cp $targetdir/boot/efi/EFI/proxmox/grubx64.efi $targetdir/boot/efi/EFI/BOOT/BOOTx64.EFI") == 0 ||
-       die "unable to copy efi boot loader\n";
+       # also install fallback boot file (OVMF does not boot without)
+       mkdir("$targetdir/boot/efi/EFI/BOOT");
+       syscmd("cp $targetdir/boot/efi/EFI/proxmox/grubx64.efi $targetdir/boot/efi/EFI/BOOT/BOOTx64.EFI") == 0 ||
+           die "unable to copy efi boot loader\n";
+    };
+    my $err = $@;
 
-    syscmd("umount $targetdir/boot/efi") == 0 ||
-       die "unable to umount $targetdir/boot/efi\n";
+    eval {
+       syscmd("umount $targetdir/boot/efi") == 0 ||
+           die "unable to umount $targetdir/boot/efi\n";
+    };
+    warn $@ if $@;
+
+    die "failed to prepare EFI boot using Grub on '$espdev': $err" if $err;
 }
 
 sub extract_data {
@@ -1219,6 +1229,8 @@ sub extract_data {
        die "unable to load zfs kernel module\n" if !$i;
     }
 
+    my $bootloader_err;
+
     eval {
 
 
@@ -1702,29 +1714,40 @@ _EOD
            symlink ("/proc/mounts", "$targetdir/etc/mtab");
            syscmd("mount -n --bind /dev $targetdir/dev");
 
-           syscmd("chroot $targetdir /usr/sbin/update-initramfs -c -k $kapi") == 0 ||
-               die "unable to install initramfs\n";
-
-           foreach my $di (@$bootdevinfo) {
-               my $dev = $di->{devname};
-               syscmd("chroot $targetdir /usr/sbin/grub-install --target i386-pc --no-floppy --bootloader-id='proxmox' $dev") == 0 ||
-                       die "unable to install the i386-pc boot loader on '$dev'\n";
-
-               if (my $esp = $di->{esp}) {
-                   if ($use_zfs) {
-                       prepare_systemd_boot_esp($esp, $targetdir);
-                   } else {
-                       prepare_grub_efi_boot_esp($dev, $esp, $targetdir);
-                   }
+           my $bootloader_err_list = [];
+           eval {
+               syscmd("chroot $targetdir /usr/sbin/update-initramfs -c -k $kapi") == 0 ||
+                   die "unable to install initramfs\n";
+
+               foreach my $di (@$bootdevinfo) {
+                   my $dev = $di->{devname};
+                   eval {
+                       syscmd("chroot $targetdir /usr/sbin/grub-install --target i386-pc --no-floppy --bootloader-id='proxmox' $dev") == 0 ||
+                               die "unable to install the i386-pc boot loader on '$dev'\n";
+                   };
+                   push @$bootloader_err_list, $@ if $@;
+
+                   eval {
+                       if (my $esp = $di->{esp}) {
+                           if ($use_zfs) {
+                               prepare_systemd_boot_esp($esp, $targetdir);
+                           } else {
+                               prepare_grub_efi_boot_esp($dev, $esp, $targetdir);
+                           }
+                       }
+                   };
+                   push @$bootloader_err_list, $@ if $@;
                }
-           }
 
-           syscmd("chroot $targetdir /usr/sbin/update-grub") == 0 ||
-               die "unable to update boot loader config\n";
+               syscmd("chroot $targetdir /usr/sbin/update-grub") == 0 ||
+                   die "unable to update boot loader config\n";
+           };
+           push @$bootloader_err_list, $@ if $@;
 
-           if ($use_zfs && $boot_type eq 'efi') {
-               syscmd("chroot $targetdir /etc/kernel/postinst.d/zz-pve-efiboot") == 0 ||
-                   die "unable to generate systemd-boot config\n";
+           if (scalar(@$bootloader_err_list) > 0) {
+               $bootloader_err = "bootloader setup errors:\n";
+               map { $bootloader_err .= "- $_" } @$bootloader_err_list;
+               warn $bootloader_err;
            }
 
            syscmd("umount $targetdir/dev");
@@ -1819,6 +1842,10 @@ _EOD
        syscmd("zpool export $zfspoolname");
     }
 
+    if ($bootloader_err) {
+       $err = $err ? "$err\n$bootloader_err" : $bootloader_err;
+    }
+
     die $err if $err;
 }
 
@@ -1868,6 +1895,9 @@ sub display_html {
        my $title = "END USER LICENSE AGREEMENT (EULA)";
        $data =~ s/__LICENSE__/$license/;
        $data =~ s/__LICENSE_TITLE__/$title/;
+    } elsif ($filename eq 'success.htm') {
+       my $addr = $ipversion == 6 ? "[${ipaddress}]" : "$ipaddress";
+       $data =~ s/\@IPADDR\@/$addr/;
     }
 
     $htmlview->load_html($data, $url);