[pve-devel] [PATCH container v2 2/5] setup getty: ensure the correct services are enabled

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jul 18 18:36:59 CEST 2019


I.e., some distro templates do not have anything enabled, thus also
ensure that the respective container-getty@ services are enabled.

But, as to getty on the same TTY makes for a strange experience also
ensure that the getty@ are all removed (and vice versa in the other
case)

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

changes v1 -> v2:

* fix getty at .service template base (tty$i not $i)
* omit changing setup_systemd_console as it will be removed in a next patch

 src/PVE/LXC/Setup/Base.pm | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index 791be32..e0b8244 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -224,6 +224,20 @@ sub setup_container_getty_service {
     if ($raw =~ s at pts/%I|lxc/tty%I@$ttyname at g) {
 	$self->ct_file_set_contents($servicefile, $raw);
     }
+
+    my $ttycount = PVE::LXC::Config->get_tty_count($conf);
+    for (my $i = 1; $i < 7; $i++) {
+	my $getty_target_fn = "/etc/systemd/system/getty.target.wants/";
+	my $tty_service_lnk = "$getty_target_fn/container-getty\@$i.service";
+
+	# ensure that not two gettys are using the same tty!
+	$self->ct_unlink("$getty_target_fn/getty\@tty$i.service");
+
+	$self->ct_unlink($tty_service_lnk);
+	if ($i <= $ttycount) {
+	    $self->ct_symlink($servicefile, $tty_service_lnk);
+	}
+    }
 }
 
 sub setup_systemd_networkd {
-- 
2.20.1





More information about the pve-devel mailing list