]> git.proxmox.com Git - pve-container.git/commitdiff
ubuntu: generate correct init/tty<X>.conf file for upstart
authorDietmar Maurer <dietmar@proxmox.com>
Wed, 12 Aug 2015 06:23:10 +0000 (08:23 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 12 Aug 2015 06:23:10 +0000 (08:23 +0200)
src/PVE/LXCSetup/Ubuntu.pm

index ae981b2aa8835259ffd5182c6761af9f23c59bbf..17d3b88ee2f378611ce4c0b208461e6f45a6fc00 100644 (file)
@@ -64,21 +64,43 @@ sub template_fixup {
        $data =~ s/=\"err\"/=0/m;
        PVE::Tools::file_set_contents($filename, $data);
     }
-
-    if ($version eq '12.04' || $version eq '14.04') {
-       my $ttycount = defined($conf->{tty}) ? $conf->{tty} : 4;
-       for (my $i = $ttycount; $i < 7; $i++) {
-           unlink "$rootdir/etc/init/tty$i.conf";
-       }
-    }
 }
 
 sub setup_init {
     my ($self, $conf) = @_;
 
     my $rootdir = $self->{rootdir};
+    my $version = $self->{version};
 
-    # works out of the box
+    if ($version eq '12.04' || $version eq '14.04') {
+       my $ttycount = defined($conf->{tty}) ? $conf->{tty} : 4;
+       for (my $i = 1; $i < 7; $i++) {
+           my $filename = "$rootdir/etc/init/tty$i.conf";
+           if ($i <= $ttycount) {
+               my $tty_conf = <<__EOD__;
+# tty$i - getty
+#
+# This service maintains a getty on tty$i from the point the system is
+# started until it is shut down again.
+
+start on stopped rc RUNLEVEL=[2345] and (
+            not-container or
+            container CONTAINER=lxc or
+            container CONTAINER=lxc-libvirt)
+
+stop on runlevel [!2345]
+
+respawn
+exec /sbin/getty -8 38400 tty$i
+__EOD__
+                PVE::Tools::file_set_contents($filename, $tty_conf);
+           } else {
+               for (my $i = $ttycount + 1; $i < 7; $i++) {
+                   unlink $filename;
+               }
+           }
+       }
+    }
 }
 
 1;