]>
git.proxmox.com Git - pve-container.git/blob - src/PVE/LXC/Setup/Ubuntu.pm
1 package PVE
::LXC
::Setup
::Ubuntu
;
10 use PVE
::LXC
::Setup
::Debian
;
12 use base
qw(PVE::LXC::Setup::Debian);
14 my $known_versions = {
15 '18.04' => 1, # bionic
16 '17.10' => 1, # artful
18 '16.10' => 1, # yakkety
19 '16.04' => 1, # xenial
22 '14.04' => 1, # trusty LTS
23 '12.04' => 1, # precise LTS
27 my ($class, $conf, $rootdir) = @_;
29 my $lsb_fn = "$rootdir/etc/lsb-release";
30 my $lsbinfo = PVE
::Tools
::file_get_contents
($lsb_fn);
32 die "got unknown DISTRIB_ID\n" if $lsbinfo !~ m/^DISTRIB_ID=Ubuntu$/mi;
35 if ($lsbinfo =~ m/^DISTRIB_RELEASE=(\d+\.\d+)$/mi) {
39 die "unable to read version info\n" if !defined($version);
41 die "unsupported Ubuntu version '$version'\n"
42 if !$known_versions->{$version};
44 my $self = { conf
=> $conf, rootdir
=> $rootdir, version
=> $version };
46 $conf->{ostype
} = "ubuntu";
48 return bless $self, $class;
52 my ($self, $conf) = @_;
54 my $version = $self->{version
};
56 if ($version >= '17.10') {
57 # enable systemd-networkd
58 $self->ct_mkdir('/etc/systemd/system/multi-user.target.wants');
59 $self->ct_mkdir('/etc/systemd/system/socket.target.wants');
60 $self->ct_symlink('/lib/systemd/system/systemd-networkd.service',
61 '/etc/systemd/system/multi-user.target.wants/systemd-networkd.service');
62 $self->ct_symlink('/lib/systemd/system/systemd-networkd.socket',
63 '/etc/systemd/system/socket.target.wants/systemd-networkd.socket');
65 # unlink default netplan lxc config
66 $self->ct_unlink('/etc/netplan/10-lxc.yaml');
69 if ($version eq '15.04' || $version eq '15.10' || $version eq '16.04') {
70 # edit /etc/securetty (enable login on console)
71 $self->setup_securetty($conf, qw(pts/0));
74 if ($version eq '12.04') {
75 # suppress log level output for udev
76 my $filename = '/etc/udev/udev.conf';
77 my $data = $self->ct_file_get_contents($filename);
78 $data =~ s/=\"err\"/=0/m;
79 $self->ct_file_set_contents($filename, $data);
84 my ($self, $conf) = @_;
86 my $version = $self->{version
};
88 if ($version >= '16.10') {
89 $self->setup_container_getty_service($conf);
92 if ($version eq '12.04' || $version eq '14.04') {
93 my $ttycount = PVE
::LXC
::Config-
>get_tty_count($conf);
94 for (my $i = 1; $i < 7; $i++) {
95 my $filename = "/etc/init/tty$i.conf";
96 if ($i <= $ttycount) {
97 my $tty_conf = <<__EOD__;
100 # This service maintains a getty on tty$i from the point the system is
101 # started until it is shut down again.
103 start on stopped rc RUNLEVEL=[2345] and (
105 container CONTAINER=lxc or
106 container CONTAINER=lxc-libvirt)
108 stop on runlevel [!2345]
111 exec /sbin/getty -8 38400 tty$i
113 $self->ct_file_set_contents($filename, $tty_conf);
115 for (my $i = $ttycount + 1; $i < 7; $i++) {
116 $self->ct_unlink($filename);
124 my ($self, $conf) = @_;
126 if ($self->{version
} >= '17.10') {
127 $self->setup_systemd_networkd($conf);
129 $self->SUPER::setup_network
($conf);