]> git.proxmox.com Git - pve-container.git/commitdiff
setup: debian: factor out inittab setup
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 16 Jun 2023 07:59:26 +0000 (09:59 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 16 Jun 2023 08:17:41 +0000 (10:17 +0200)
it's too easy to try to append to `setup_init`, missing that
there's a `return if !file_exists` in there...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/LXC/Setup/Debian.pm

index b3ba76ec972b79c768aee09896713c9774736590..a7308a4664e6016c81068c4683bd86923097ee24 100644 (file)
@@ -63,24 +63,9 @@ my sub at_least : prototype($$$) {
     );
 }
 
-sub setup_init {
+my sub setup_inittab {
     my ($self, $conf) = @_;
 
-    my $systemd = $self->ct_readlink('/sbin/init');
-    if (defined($systemd) && $systemd =~ m@/systemd$@) {
-       $self->setup_container_getty_service($conf);
-
-       my $version = $self->{version};
-       if (at_least($version, 12, 0)) {
-           # this only affects the first-boot (if no /etc/machien-id exists).
-           $self->setup_systemd_preset({
-               # systemd-networkd gets enabled by default, disable it, debian uses
-               # ifupdown
-               'systemd-networkd.service' => 0,
-           });
-       }
-    }
-
     my $filename = "/etc/inittab";
     return if !$self->ct_file_exists($filename);
 
@@ -98,6 +83,7 @@ sub setup_init {
 
     $inittab .= "p0::powerfail:/sbin/init 0\n";
 
+    my $version = $self->{version};
     for (my $id = 1; $id <= $ttycount; $id++) {
        next if $id == 7; # reserved for X11
        my $levels = ($id == 1) ? '2345' : '23';
@@ -111,6 +97,27 @@ sub setup_init {
     $self->ct_file_set_contents($filename, $inittab);
 }
 
+sub setup_init {
+    my ($self, $conf) = @_;
+
+    my $systemd = $self->ct_readlink('/sbin/init');
+    if (defined($systemd) && $systemd =~ m@/systemd$@) {
+       $self->setup_container_getty_service($conf);
+
+       my $version = $self->{version};
+       if (at_least($version, 12, 0)) {
+           # this only affects the first-boot (if no /etc/machien-id exists).
+           $self->setup_systemd_preset({
+               # systemd-networkd gets enabled by default, disable it, debian uses
+               # ifupdown
+               'systemd-networkd.service' => 0,
+           });
+       }
+    }
+
+    setup_inittab($self, $conf);
+}
+
 sub remove_gateway_scripts {
     my ($attr) = @_;
     my $length = scalar(@$attr);