]>
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 '17.10' => 1, # artful
17 '16.10' => 1, # yakkety
18 '16.04' => 1, # xenial
21 '14.04' => 1, # trusty LTS
22 '12.04' => 1, # precise LTS
26 my ($class, $conf, $rootdir) = @_;
28 my $lsb_fn = "$rootdir/etc/lsb-release";
29 my $lsbinfo = PVE
::Tools
::file_get_contents
($lsb_fn);
31 die "got unknown DISTRIB_ID\n" if $lsbinfo !~ m/^DISTRIB_ID=Ubuntu$/mi;
34 if ($lsbinfo =~ m/^DISTRIB_RELEASE=(\d+\.\d+)$/mi) {
38 die "unable to read version info\n" if !defined($version);
40 die "unsupported Ubuntu version '$version'\n"
41 if !$known_versions->{$version};
43 my $self = { conf
=> $conf, rootdir
=> $rootdir, version
=> $version };
45 $conf->{ostype
} = "ubuntu";
47 return bless $self, $class;
51 my ($self, $conf) = @_;
53 my $version = $self->{version
};
55 if ($version >= '17.10') {
56 # enable systemd-networkd
57 $self->ct_mkdir('/etc/systemd/system/multi-user.target.wants');
58 $self->ct_mkdir('/etc/systemd/system/socket.target.wants');
59 $self->ct_symlink('/lib/systemd/system/systemd-networkd.service',
60 '/etc/systemd/system/multi-user.target.wants/systemd-networkd.service');
61 $self->ct_symlink('/lib/systemd/system/systemd-networkd.socket',
62 '/etc/systemd/system/socket.target.wants/systemd-networkd.socket');
64 # unlink default netplan lxc config
65 $self->ct_unlink('/etc/netplan/10-lxc.yaml');
68 if ($version eq '15.04' || $version eq '15.10' || $version eq '16.04') {
69 # edit /etc/securetty (enable login on console)
70 $self->setup_securetty($conf, qw(pts/0));
73 if ($version eq '12.04') {
74 # suppress log level output for udev
75 my $filename = '/etc/udev/udev.conf';
76 my $data = $self->ct_file_get_contents($filename);
77 $data =~ s/=\"err\"/=0/m;
78 $self->ct_file_set_contents($filename, $data);
83 my ($self, $conf) = @_;
85 my $version = $self->{version
};
87 if ($version eq '17.10' || $version eq '17.04' || $version eq '16.10') {
88 $self->setup_container_getty_service($conf);
91 if ($version eq '12.04' || $version eq '14.04') {
92 my $ttycount = PVE
::LXC
::Config-
>get_tty_count($conf);
93 for (my $i = 1; $i < 7; $i++) {
94 my $filename = "/etc/init/tty$i.conf";
95 if ($i <= $ttycount) {
96 my $tty_conf = <<__EOD__;
99 # This service maintains a getty on tty$i from the point the system is
100 # started until it is shut down again.
102 start on stopped rc RUNLEVEL=[2345] and (
104 container CONTAINER=lxc or
105 container CONTAINER=lxc-libvirt)
107 stop on runlevel [!2345]
110 exec /sbin/getty -8 38400 tty$i
112 $self->ct_file_set_contents($filename, $tty_conf);
114 for (my $i = $ttycount + 1; $i < 7; $i++) {
115 $self->ct_unlink($filename);
123 my ($self, $conf) = @_;
125 if ($self->{version
} >= '17.10') {
126 $self->setup_systemd_networkd($conf);
128 $self->SUPER::setup_network
($conf);