]>
git.proxmox.com Git - pve-container.git/blob - src/PVE/LXC/Setup/Ubuntu.pm
c5bd07d48a0ac0dd0a680956fb44599ce5ff6056
1 package PVE
::LXC
::Setup
::Ubuntu
;
10 use PVE
::LXC
::Setup
::Debian
;
12 use base
qw(PVE::LXC::Setup::Debian);
14 my $known_versions = {
16 '18.10' => 1, # cosmic
17 '18.04' => 1, # bionic
18 '17.10' => 1, # artful
20 '16.10' => 1, # yakkety
21 '16.04' => 1, # xenial
24 '14.04' => 1, # trusty LTS
25 '12.04' => 1, # precise LTS
29 my ($class, $conf, $rootdir) = @_;
31 my $lsb_fn = "$rootdir/etc/lsb-release";
32 my $lsbinfo = PVE
::Tools
::file_get_contents
($lsb_fn);
34 die "got unknown DISTRIB_ID\n" if $lsbinfo !~ m/^DISTRIB_ID=Ubuntu$/mi;
37 if ($lsbinfo =~ m/^DISTRIB_RELEASE=(\d+\.\d+)$/mi) {
41 die "unable to read version info\n" if !defined($version);
43 die "unsupported Ubuntu version '$version'\n"
44 if !$known_versions->{$version};
46 my $self = { conf
=> $conf, rootdir
=> $rootdir, version
=> $version };
48 $conf->{ostype
} = "ubuntu";
50 return bless $self, $class;
54 my ($self, $conf) = @_;
56 my $version = $self->{version
};
58 if ($version >= '17.10') {
59 # enable systemd-networkd
60 $self->ct_mkdir('/etc/systemd/system/multi-user.target.wants');
61 $self->ct_mkdir('/etc/systemd/system/socket.target.wants');
62 $self->ct_symlink('/lib/systemd/system/systemd-networkd.service',
63 '/etc/systemd/system/multi-user.target.wants/systemd-networkd.service');
64 $self->ct_symlink('/lib/systemd/system/systemd-networkd.socket',
65 '/etc/systemd/system/socket.target.wants/systemd-networkd.socket');
67 # unlink default netplan lxc config
68 $self->ct_unlink('/etc/netplan/10-lxc.yaml');
71 if ($version eq '15.04' || $version eq '15.10' || $version eq '16.04') {
72 # edit /etc/securetty (enable login on console)
73 $self->setup_securetty($conf, qw(pts/0));
76 if ($version eq '12.04') {
77 # suppress log level output for udev
78 my $filename = '/etc/udev/udev.conf';
79 my $data = $self->ct_file_get_contents($filename);
80 $data =~ s/=\"err\"/=0/m;
81 $self->ct_file_set_contents($filename, $data);
86 my ($self, $conf) = @_;
88 my $version = $self->{version
};
90 if ($version >= '16.10') {
91 $self->setup_container_getty_service($conf);
94 if ($version eq '12.04' || $version eq '14.04') {
95 my $ttycount = PVE
::LXC
::Config-
>get_tty_count($conf);
96 for (my $i = 1; $i < 7; $i++) {
97 my $filename = "/etc/init/tty$i.conf";
98 if ($i <= $ttycount) {
99 my $tty_conf = <<__EOD__;
102 # This service maintains a getty on tty$i from the point the system is
103 # started until it is shut down again.
105 start on stopped rc RUNLEVEL=[2345] and (
107 container CONTAINER=lxc or
108 container CONTAINER=lxc-libvirt)
110 stop on runlevel [!2345]
113 exec /sbin/getty -8 38400 tty$i
115 $self->ct_file_set_contents($filename, $tty_conf);
117 for (my $i = $ttycount + 1; $i < 7; $i++) {
118 $self->ct_unlink($filename);
126 my ($self, $conf) = @_;
128 if ($self->{version
} >= '17.10') {
129 $self->setup_systemd_networkd($conf);
131 $self->SUPER::setup_network
($conf);