[pve-devel] [PATCH container 2/2] setup getty: ensure the getty.target is enabled

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Jul 17 12:08:25 CEST 2019


some distro templates have this disabled (masked) by default, it
makes sense to always ensure that it is enabled.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/LXC/Setup/Base.pm | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index 5ec78a0..516bd68 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -200,6 +200,8 @@ sub setup_systemd_console {
 	    }
 	}
     }
+
+    $self->enable_getty_target();
 }
 
 # A few distros as well as unprivileged containers cannot deal with the
@@ -209,6 +211,19 @@ sub devttydir {
     return $conf->{unprivileged} ? '' : 'lxc/';
 }
 
+sub enable_getty_target {
+    my ($self) = @_;
+
+    my $systemd_dir_rel = $self->ct_is_executable("/lib/systemd/systemd") ?
+	"/lib/systemd/system" : "/usr/lib/systemd/system";
+
+    my $targetfile = "$systemd_dir_rel/getty.target";
+    my $getty_target_lnk = "/etc/systemd/system/getty.target";
+
+    $self->ct_unlink($getty_target_lnk);
+    $self->ct_symlink($targetfile, $getty_target_lnk);
+}
+
 sub setup_container_getty_service {
     my ($self, $conf) = @_;
 
@@ -239,6 +254,8 @@ sub setup_container_getty_service {
 	    }
 	}
     }
+
+    $self->enable_getty_target();
 }
 
 sub setup_systemd_networkd {
-- 
2.20.1





More information about the pve-devel mailing list