From 5f94d5e5bcbf2888cb2de9a5881596584e885a5f Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Thu, 28 May 2020 20:18:46 +0000 Subject: [PATCH 1/1] lxc: fall back to 'unmanaged' when no OS detected 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 --- src/PVE/LXC/Setup.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/PVE/LXC/Setup.pm b/src/PVE/LXC/Setup.pm index c738e64..6ebd465 100644 --- a/src/PVE/LXC/Setup.pm +++ b/src/PVE/LXC/Setup.pm @@ -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"; -- 2.39.2