]> git.proxmox.com Git - pve-container.git/commitdiff
Alpine: generate correct inittab
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 2 May 2016 14:10:59 +0000 (16:10 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 3 May 2016 06:04:06 +0000 (08:04 +0200)
Previously inittab had a hardcoded number of ttys, remove them and
re-add the ones configured by the user.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/LXC/Setup/Alpine.pm

index e7655bc440cba467a3d4679755ac976da1910f81..7705c8ddb9aa640065ca4491344bc080bd9cd86c 100644 (file)
@@ -43,7 +43,27 @@ sub template_fixup {
 }
 
 sub setup_init {
-    # Nothing to do
+    my ($self, $conf) = @_;
+
+    my $filename = "/etc/inittab";
+    return if !$self->ct_file_exists($filename);
+
+    my $ttycount =  PVE::LXC::Config->get_tty_count($conf);
+    my $inittab = $self->ct_file_get_contents($filename);
+
+    my @lines = grep {
+           # remove getty lines
+           !/^\s*tty\d+::[^:]*:.*getty/
+    } split(/\n/, $inittab);
+
+    $inittab = join("\n", @lines) . "\n";
+
+    for (my $id = 1; $id <= $ttycount; $id++) {
+       next if $id == 7; # reserved for X11
+       $inittab .= "tty$id\::respawn:/sbin/getty 38400 tty$id\n";
+    }
+
+    $self->ct_file_set_contents($filename, $inittab);
 }
 
 sub setup_network {