]> git.proxmox.com Git - pve-container.git/blame - src/PVE/LXC/Setup/Ubuntu.pm
add support for Ubuntu 17.04 (zesty)
[pve-container.git] / src / PVE / LXC / Setup / Ubuntu.pm
CommitLineData
7af97ad5 1package PVE::LXC::Setup::Ubuntu;
a8e58e9c
DM
2
3use strict;
4use warnings;
5use Data::Dumper;
6use PVE::Tools;
7use PVE::LXC;
8use File::Path;
9
7af97ad5 10use PVE::LXC::Setup::Debian;
a8e58e9c 11
7af97ad5 12use base qw(PVE::LXC::Setup::Debian);
a8e58e9c 13
91bf89e1 14my $known_versions = {
d9d448fa 15 '17.04' => 1, # zesty
bd4082c1 16 '16.10' => 1, # yakkety
1c5e428d 17 '16.04' => 1, # xenial
90c85c7d 18 '15.10' => 1, # wily
91bf89e1
DM
19 '15.04' => 1, # vivid
20 '14.04' => 1, # trusty LTS
21 '12.04' => 1, # precise LTS
22};
23
a8e58e9c
DM
24sub new {
25 my ($class, $conf, $rootdir) = @_;
26
27 my $lsb_fn = "$rootdir/etc/lsb-release";
28 my $lsbinfo = PVE::Tools::file_get_contents($lsb_fn);
29
30 die "got unknown DISTRIB_ID\n" if $lsbinfo !~ m/^DISTRIB_ID=Ubuntu$/mi;
31
32 my $version;
33 if ($lsbinfo =~ m/^DISTRIB_RELEASE=(\d+\.\d+)$/mi) {
34 $version = $1;
35 }
36
37 die "unable to read version info\n" if !defined($version);
38
40dee029
DM
39 die "unsupported Ubuntu version '$version'\n"
40 if !$known_versions->{$version};
a8e58e9c
DM
41
42 my $self = { conf => $conf, rootdir => $rootdir, version => $version };
43
27916659 44 $conf->{ostype} = "ubuntu";
a8e58e9c
DM
45
46 return bless $self, $class;
47}
48
49sub template_fixup {
50 my ($self, $conf) = @_;
51
91bf89e1 52 my $version = $self->{version};
a8e58e9c 53
45ebd6c7 54 if ($version eq '15.04' || $version eq '15.10' || $version eq '16.04') {
a8e58e9c 55 # edit /etc/securetty (enable login on console)
b7cd927f 56 $self->setup_securetty($conf, qw(pts/0));
a8e58e9c 57 }
91bf89e1
DM
58
59 if ($version eq '12.04') {
60 # suppress log level output for udev
2063d380
WB
61 my $filename = '/etc/udev/udev.conf';
62 my $data = $self->ct_file_get_contents($filename);
91bf89e1 63 $data =~ s/=\"err\"/=0/m;
2063d380 64 $self->ct_file_set_contents($filename, $data);
91bf89e1 65 }
a8e58e9c
DM
66}
67
68sub setup_init {
69 my ($self, $conf) = @_;
70
c40a11f2 71 my $version = $self->{version};
a8e58e9c 72
d9d448fa 73 if ($version eq '17.04' || $version eq '16.10') {
5e84bdc8 74 $self->setup_container_getty_service($conf);
45ebd6c7
DM
75 }
76
c40a11f2 77 if ($version eq '12.04' || $version eq '14.04') {
1b4cf758 78 my $ttycount = PVE::LXC::Config->get_tty_count($conf);
c40a11f2 79 for (my $i = 1; $i < 7; $i++) {
2063d380 80 my $filename = "/etc/init/tty$i.conf";
c40a11f2
DM
81 if ($i <= $ttycount) {
82 my $tty_conf = <<__EOD__;
83# tty$i - getty
84#
85# This service maintains a getty on tty$i from the point the system is
86# started until it is shut down again.
87
88start on stopped rc RUNLEVEL=[2345] and (
89 not-container or
90 container CONTAINER=lxc or
91 container CONTAINER=lxc-libvirt)
92
93stop on runlevel [!2345]
94
95respawn
96exec /sbin/getty -8 38400 tty$i
97__EOD__
2063d380 98 $self->ct_file_set_contents($filename, $tty_conf);
c40a11f2
DM
99 } else {
100 for (my $i = $ttycount + 1; $i < 7; $i++) {
2063d380 101 $self->ct_unlink($filename);
c40a11f2
DM
102 }
103 }
104 }
105 }
a8e58e9c
DM
106}
107
1081;