[pve-devel] [PATCH container 3/3] debian: support containers upgraded to use systemd
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Apr 6 14:32:39 CEST 2016
These otherwise spawn consoles at /dev/pts%I and cause
errors in the logs about the container-getty@ services.
This happens for instance when dist-upgrading from wheezy to
jessie.
---
src/PVE/LXC/Setup/Base.pm | 14 +++++++++++---
src/PVE/LXC/Setup/Debian.pm | 5 +++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index 9f21d6f..e65b04a 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -198,10 +198,13 @@ sub setup_systemd_console {
}
sub setup_container_getty_service {
- my ($self) = @_;
- my $servicefile = '/usr/lib/systemd/system/container-getty at .service';
+ my ($self, $nosubdir) = @_;
+ my $systemd_dir_rel = -x "/lib/systemd/systemd" ?
+ "/lib/systemd/system" : "/usr/lib/systemd/system";
+ my $servicefile = "$systemd_dir_rel/container-getty\@.service";
my $raw = $self->ct_file_get_contents($servicefile);
- if ($raw =~ s at pts/%I at lxc/tty%I at g) {
+ my $ttyname = ($nosubdir ? '' : 'lxc/') . 'tty%I';
+ if ($raw =~ s at pts/%I@$ttyname at g) {
$self->ct_file_set_contents($servicefile, $raw);
}
}
@@ -507,6 +510,11 @@ sub ct_symlink {
return CORE::symlink($old, $new);
}
+sub ct_readlink {
+ my ($self, $name) = @_;
+ return CORE::readlink($name);
+}
+
sub ct_file_exists {
my ($self, $file) = @_;
return -f $file;
diff --git a/src/PVE/LXC/Setup/Debian.pm b/src/PVE/LXC/Setup/Debian.pm
index 577646e..db5d317 100644
--- a/src/PVE/LXC/Setup/Debian.pm
+++ b/src/PVE/LXC/Setup/Debian.pm
@@ -69,6 +69,11 @@ sub setup_init {
}
$self->ct_file_set_contents($filename, $inittab);
+
+ my $systemd = $self->ct_readlink('/sbin/init');
+ if (defined($systemd) && $systemd =~ m@/systemd$@) {
+ $self->setup_container_getty_service(1);
+ }
}
sub remove_gateway_scripts {
--
2.1.4
More information about the pve-devel
mailing list