]> git.proxmox.com Git - pve-container.git/commitdiff
lxc: fall back to 'unmanaged' when no OS detected
authorArnout Engelen <arnout@bzzt.net>
Thu, 28 May 2020 20:18:46 +0000 (20:18 +0000)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 29 May 2020 09:30:56 +0000 (11:30 +0200)
This is useful when the uploaded CT does not contain a full OS. When the
autodetection detects an OS, that OS is returned. When it does not
successfully detect a supported OS, but /etc/os-release exists and has an ID
other than 'unmanaged', then the setup fails.

Signed-off-by: Arnout Engelen <arnout@bzzt.net>
src/PVE/LXC/Setup.pm

index c738e64e0649d1779f4e709c207dcecf4ed62cf4..6ebd4651038a64918ecdaca2e7dff87093df3027 100644 (file)
@@ -70,8 +70,12 @@ my $autodetect_type = sub {
        return "alpine";
     } elsif (-f  "$rootdir/etc/gentoo-release") {
        return "gentoo";
+    } elsif (-f "$rootdir/etc/os-release") {
+       die "unable to detect OS distribution\n";
+    } else {
+       warn "/etc/os-release file not found and autodetection failed, falling back to 'unmanaged'\n";
+       return "unmanaged";
     }
-    die "unable to detect OS distribution\n";
 };
 
 sub new {
@@ -94,6 +98,11 @@ sub new {
            if $type ne $expected_type;
     }
 
+    if ($type eq 'unmanaged') {
+       $conf->{ostype} = $type;
+       return $self;
+    }
+
     my $plugin_class = $plugins->{$type} ||
        "no such OS type '$type'\n";