[pve-devel] [PATCH container v2 4/5] setup getty: drop now obsolete setup_systemd_console

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jul 18 18:37:01 CEST 2019


The setup_container_getty_service can now handle also old
getty at .service if the newer container-getty at .service is not
available. So drop, and convert the two remaining users to calling
the now compatible setup_container_getty_service

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

new in v2

 src/PVE/LXC/Setup/Base.pm   | 25 -------------------------
 src/PVE/LXC/Setup/CentOS.pm |  2 +-
 src/PVE/LXC/Setup/SUSE.pm   | 12 +-----------
 3 files changed, 2 insertions(+), 37 deletions(-)

diff --git a/src/PVE/LXC/Setup/Base.pm b/src/PVE/LXC/Setup/Base.pm
index 4880a2b..06c0089 100644
--- a/src/PVE/LXC/Setup/Base.pm
+++ b/src/PVE/LXC/Setup/Base.pm
@@ -155,31 +155,6 @@ sub setup_init {
     die "please implement this inside subclass"
 }
 
-sub setup_systemd_console {
-    my ($self, $conf) = @_;
-
-    my $systemd_dir_rel = $self->ct_is_executable("/lib/systemd/systemd") ?
-	"/lib/systemd/system" : "/usr/lib/systemd/system";
-
-    my $systemd_getty_service_rel = "$systemd_dir_rel/getty\@.service";
-
-    return if !$self->ct_file_exists($systemd_getty_service_rel);
-
-    my $ttycount = PVE::LXC::Config->get_tty_count($conf);
-
-    for (my $i = 1; $i < 7; $i++) {
-	my $tty_service_lnk = "/etc/systemd/system/getty.target.wants/getty\@tty$i.service";
-	if ($i > $ttycount) {
-	    $self->ct_unlink($tty_service_lnk);
-	} else {
-	    if (!$self->ct_is_symlink($tty_service_lnk)) {
-		$self->ct_unlink($tty_service_lnk);
-		$self->ct_symlink($systemd_getty_service_rel, $tty_service_lnk);
-	    }
-	}
-    }
-}
-
 # A few distros as well as unprivileged containers cannot deal with the
 # /dev/lxc/ tty subdirectory.
 sub devttydir {
diff --git a/src/PVE/LXC/Setup/CentOS.pm b/src/PVE/LXC/Setup/CentOS.pm
index f72dbc0..a18aead 100644
--- a/src/PVE/LXC/Setup/CentOS.pm
+++ b/src/PVE/LXC/Setup/CentOS.pm
@@ -117,7 +117,7 @@ sub setup_init {
 
     $self->fixup_old_getty();
 
-    $self->setup_systemd_console($conf);
+    $self->setup_container_getty_service($conf);
 }
 
 sub set_hostname {
diff --git a/src/PVE/LXC/Setup/SUSE.pm b/src/PVE/LXC/Setup/SUSE.pm
index 4a037b4..a983afd 100644
--- a/src/PVE/LXC/Setup/SUSE.pm
+++ b/src/PVE/LXC/Setup/SUSE.pm
@@ -12,22 +12,17 @@ sub new {
 
     my $version = $os_release->{VERSION_ID};
     my $ostype = $os_release->{ID};
-    my $setup_ct_getty_service;
 
     if ($version =~ m/^(\d+)\.(\d+)$/) {
 	my ($major, $minor) = ($1, $2);
 	if ($major >= 42) {
 	    # OK
-	    $setup_ct_getty_service = 1;
 	} elsif ($major == 13 && $minor <= 2) {
 	    # OK
-	    $setup_ct_getty_service = 1 if $minor >= 2;
 	} elsif ($ostype eq 'sles' && $major == 12) {
 	    # OK - shares base with LEAP (42)
-	    $setup_ct_getty_service = 1;
 	} elsif ($major == 15) {
 	    # OK for SLES and openSUSE Leap, see: https://lwn.net/Articles/720924/
-	    $setup_ct_getty_service = 1;
 	} else {
 	    die "unsupported suse release '$version'\n";
 	}
@@ -35,7 +30,6 @@ sub new {
 	my ($year, $month, $day) = ($1, $2, $3);
 	if ($year >= 2017 && $month <= 12 && $day <= 31) {
 	    # OK
-	    $setup_ct_getty_service = 1;
 	} else {
 	    die "unsupported suse tumbleweed release '$version'\n";
 	}
@@ -44,7 +38,6 @@ sub new {
     }
 
     my $self = { conf => $conf, rootdir => $rootdir, version => $version, os_release => $os_release };
-    $self->{setup_ct_getty_service} = 1 if $setup_ct_getty_service;
 
     $conf->{ostype} = 'opensuse';
 
@@ -62,10 +55,7 @@ sub setup_init {
 
     $self->fixup_old_getty();
 
-    if ($self->{setup_ct_getty_service}) {
-	$self->setup_container_getty_service($conf);
-    }
-    $self->setup_systemd_console($conf);
+    $self->setup_container_getty_service($conf);
 }
 
 sub setup_network {
-- 
2.20.1





More information about the pve-devel mailing list