]>
Commit | Line | Data |
---|---|---|
a8e58e9c DM |
1 | package PVE::LXCSetup::Ubuntu; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | use Data::Dumper; | |
6 | use PVE::Tools; | |
7 | use PVE::LXC; | |
8 | use File::Path; | |
9 | ||
10 | use PVE::LXCSetup::Debian; | |
11 | ||
12 | use base qw(PVE::LXCSetup::Debian); | |
13 | ||
91bf89e1 DM |
14 | my $known_versions = { |
15 | '15.04' => 1, # vivid | |
16 | '14.04' => 1, # trusty LTS | |
17 | '12.04' => 1, # precise LTS | |
18 | }; | |
19 | ||
a8e58e9c DM |
20 | sub new { |
21 | my ($class, $conf, $rootdir) = @_; | |
22 | ||
23 | my $lsb_fn = "$rootdir/etc/lsb-release"; | |
24 | my $lsbinfo = PVE::Tools::file_get_contents($lsb_fn); | |
25 | ||
26 | die "got unknown DISTRIB_ID\n" if $lsbinfo !~ m/^DISTRIB_ID=Ubuntu$/mi; | |
27 | ||
28 | my $version; | |
29 | if ($lsbinfo =~ m/^DISTRIB_RELEASE=(\d+\.\d+)$/mi) { | |
30 | $version = $1; | |
31 | } | |
32 | ||
33 | die "unable to read version info\n" if !defined($version); | |
34 | ||
91bf89e1 | 35 | die "unsupported ubunt version '$version'\n" if !$known_versions->{$version}; |
a8e58e9c DM |
36 | |
37 | my $self = { conf => $conf, rootdir => $rootdir, version => $version }; | |
38 | ||
39 | $conf->{'lxc.include'} = "/usr/share/lxc/config/ubuntu.common.conf"; | |
40 | ||
41 | return bless $self, $class; | |
42 | } | |
43 | ||
44 | sub template_fixup { | |
45 | my ($self, $conf) = @_; | |
46 | ||
47 | my $rootdir = $self->{rootdir}; | |
91bf89e1 | 48 | my $version = $self->{version}; |
a8e58e9c | 49 | |
91bf89e1 | 50 | if ($version eq '15.04') { |
a8e58e9c DM |
51 | # edit /etc/securetty (enable login on console) |
52 | my $filename = "$rootdir/etc/securetty"; | |
53 | my $data = PVE::Tools::file_get_contents($filename); | |
54 | if ($data !~ m!^pts/0\s*$!m) { | |
55 | $data .= "pts/0\n"; | |
56 | } | |
57 | PVE::Tools::file_set_contents($filename, $data); | |
58 | } | |
91bf89e1 DM |
59 | |
60 | if ($version eq '12.04') { | |
61 | # suppress log level output for udev | |
62 | my $filename = "$rootdir/etc/udev/udev.conf"; | |
63 | my $data = PVE::Tools::file_get_contents($filename); | |
64 | $data =~ s/=\"err\"/=0/m; | |
65 | PVE::Tools::file_set_contents($filename, $data); | |
66 | } | |
67 | ||
68 | if ($version eq '12.04' || $version eq '14.04') { | |
69 | my $ttycount = defined($conf->{'lxc.tty'}) ? $conf->{'lxc.tty'} : 4; | |
70 | for (my $i = $ttycount; $i < 7; $i++) { | |
71 | unlink "$rootdir/etc/init/tty$i.conf"; | |
72 | } | |
73 | } | |
a8e58e9c DM |
74 | } |
75 | ||
76 | sub setup_init { | |
77 | my ($self, $conf) = @_; | |
78 | ||
79 | my $rootdir = $self->{rootdir}; | |
80 | ||
81 | # works out of the box | |
82 | } | |
83 | ||
84 | 1; |