]>
Commit | Line | Data |
---|---|---|
1 | package PVE::LXC::Setup::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::LXC::Setup::Debian; | |
11 | ||
12 | use base qw(PVE::LXC::Setup::Debian); | |
13 | ||
14 | my $known_versions = { | |
15 | '17.04' => 1, # zesty | |
16 | '16.10' => 1, # yakkety | |
17 | '16.04' => 1, # xenial | |
18 | '15.10' => 1, # wily | |
19 | '15.04' => 1, # vivid | |
20 | '14.04' => 1, # trusty LTS | |
21 | '12.04' => 1, # precise LTS | |
22 | }; | |
23 | ||
24 | sub 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 | ||
39 | die "unsupported Ubuntu version '$version'\n" | |
40 | if !$known_versions->{$version}; | |
41 | ||
42 | my $self = { conf => $conf, rootdir => $rootdir, version => $version }; | |
43 | ||
44 | $conf->{ostype} = "ubuntu"; | |
45 | ||
46 | return bless $self, $class; | |
47 | } | |
48 | ||
49 | sub template_fixup { | |
50 | my ($self, $conf) = @_; | |
51 | ||
52 | my $version = $self->{version}; | |
53 | ||
54 | if ($version eq '15.04' || $version eq '15.10' || $version eq '16.04') { | |
55 | # edit /etc/securetty (enable login on console) | |
56 | $self->setup_securetty($conf, qw(pts/0)); | |
57 | } | |
58 | ||
59 | if ($version eq '12.04') { | |
60 | # suppress log level output for udev | |
61 | my $filename = '/etc/udev/udev.conf'; | |
62 | my $data = $self->ct_file_get_contents($filename); | |
63 | $data =~ s/=\"err\"/=0/m; | |
64 | $self->ct_file_set_contents($filename, $data); | |
65 | } | |
66 | } | |
67 | ||
68 | sub setup_init { | |
69 | my ($self, $conf) = @_; | |
70 | ||
71 | my $version = $self->{version}; | |
72 | ||
73 | if ($version eq '17.04' || $version eq '16.10') { | |
74 | $self->setup_container_getty_service($conf); | |
75 | } | |
76 | ||
77 | if ($version eq '12.04' || $version eq '14.04') { | |
78 | my $ttycount = PVE::LXC::Config->get_tty_count($conf); | |
79 | for (my $i = 1; $i < 7; $i++) { | |
80 | my $filename = "/etc/init/tty$i.conf"; | |
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 | ||
88 | start on stopped rc RUNLEVEL=[2345] and ( | |
89 | not-container or | |
90 | container CONTAINER=lxc or | |
91 | container CONTAINER=lxc-libvirt) | |
92 | ||
93 | stop on runlevel [!2345] | |
94 | ||
95 | respawn | |
96 | exec /sbin/getty -8 38400 tty$i | |
97 | __EOD__ | |
98 | $self->ct_file_set_contents($filename, $tty_conf); | |
99 | } else { | |
100 | for (my $i = $ttycount + 1; $i < 7; $i++) { | |
101 | $self->ct_unlink($filename); | |
102 | } | |
103 | } | |
104 | } | |
105 | } | |
106 | } | |
107 | ||
108 | 1; |