]> git.proxmox.com Git - pve-container.git/commitdiff
add support for Ubuntu 15.04
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 24 Jun 2015 11:34:59 +0000 (13:34 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 24 Jun 2015 11:35:49 +0000 (13:35 +0200)
src/PVE/LXCSetup.pm
src/PVE/LXCSetup/Makefile
src/PVE/LXCSetup/Ubuntu.pm [new file with mode: 0644]

index 55f35366a835be2d9d1ca6c354543bad62770f27..197c224870972e66cea7014b727ada20ee4c56e1 100644 (file)
@@ -2,19 +2,28 @@ package PVE::LXCSetup;
 
 use strict;
 use warnings;
+use PVE::Tools;
 
 use PVE::LXCSetup::Debian;
+use PVE::LXCSetup::Ubuntu;
 use PVE::LXCSetup::Redhat;
 
 my $plugins = {
     debian =>  'PVE::LXCSetup::Debian',
+    ubuntu =>  'PVE::LXCSetup::Ubuntu',
     redhat =>  'PVE::LXCSetup::Redhat',
 };
 
 my $autodetect_type = sub {
     my ($rootdir) = @_;
-    
-    if (-f "$rootdir/etc/debian_version") {
+
+    my $lsb_fn = "$rootdir/etc/lsb-release";
+    if (-f $lsb_fn) {
+       my $data =  PVE::Tools::file_get_contents($lsb_fn);
+       if ($data =~ m/^DISTRIB_ID=Ubuntu$/im) {
+           return 'ubuntu';
+       }
+    } elsif (-f "$rootdir/etc/debian_version") {
        return "debian";
     } elsif (-f  "$rootdir/etc/redhat-release") {
        return "redhat";
index c8ec0bd692717484cc4e4fbe88ac3343f44253d0..828d89f4a8ee28d06daddb2067ea201d48eb1049 100644 (file)
@@ -1,4 +1,4 @@
-SOURCES=Base.pm Debian.pm Redhat.pm
+SOURCES=Base.pm Debian.pm Ubuntu.pm Redhat.pm
 
 .PHONY: install
 install:
diff --git a/src/PVE/LXCSetup/Ubuntu.pm b/src/PVE/LXCSetup/Ubuntu.pm
new file mode 100644 (file)
index 0000000..a8f9658
--- /dev/null
@@ -0,0 +1,62 @@
+package PVE::LXCSetup::Ubuntu;
+
+use strict;
+use warnings;
+use Data::Dumper;
+use PVE::Tools;
+use PVE::LXC;
+use File::Path;
+
+use PVE::LXCSetup::Debian;
+
+use base qw(PVE::LXCSetup::Debian);
+
+sub new {
+    my ($class, $conf, $rootdir) = @_;
+
+    my $lsb_fn = "$rootdir/etc/lsb-release";
+    my $lsbinfo = PVE::Tools::file_get_contents($lsb_fn);
+
+    die "got unknown DISTRIB_ID\n" if $lsbinfo !~ m/^DISTRIB_ID=Ubuntu$/mi;
+    
+    my $version;
+    if ($lsbinfo =~ m/^DISTRIB_RELEASE=(\d+\.\d+)$/mi) {
+       $version = $1;
+    }
+    
+    die "unable to read version info\n" if !defined($version);
+  
+    die "unsupported ubunt version '$version'\n" if $version ne '15.04';
+
+    my $self = { conf => $conf, rootdir => $rootdir, version => $version };
+
+    $conf->{'lxc.include'} = "/usr/share/lxc/config/ubuntu.common.conf";
+
+    return bless $self, $class;
+}
+
+sub template_fixup {
+    my ($self, $conf) = @_;
+
+    my $rootdir = $self->{rootdir};
+    
+    if ($self->{version} eq '15.04') {
+       # edit /etc/securetty (enable login on console)
+       my $filename = "$rootdir/etc/securetty";
+       my $data = PVE::Tools::file_get_contents($filename);
+       if ($data !~ m!^pts/0\s*$!m) {
+           $data .= "pts/0\n"; 
+       }
+       PVE::Tools::file_set_contents($filename, $data);
+    }
+}
+
+sub setup_init {
+    my ($self, $conf) = @_;
+
+    my $rootdir = $self->{rootdir};
+
+    # works out of the box
+}
+
+1;