From 7962557f8890c8bdebccc1212cb95f31f000ad17 Mon Sep 17 00:00:00 2001 From: Felipe Sateler Date: Mon, 10 Apr 2017 11:28:35 -0300 Subject: [PATCH] d-s-invoke: Execute systemctl once when starting units This ensures systemd itself can order them the best way it sees fit. Closes: #848192 --- script/deb-systemd-invoke | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/script/deb-systemd-invoke b/script/deb-systemd-invoke index a4b3fbc..71b1c33 100755 --- a/script/deb-systemd-invoke +++ b/script/deb-systemd-invoke @@ -83,6 +83,7 @@ if (-x $policyhelper) { # We don't autostart static units either. if ($action eq "start" || $action eq "restart") { my $global_exit_code = 0; + my @start_units = (); for my $unit (@units) { my $unit_installed = 0; my $enabled_output = `/bin/systemctl is-enabled -- '$unit'`; @@ -98,15 +99,13 @@ if ($action eq "start" || $action eq "restart") { print STDERR "$unit is a disabled or a static unit not running, not starting it.\n"; } else { - system('/bin/systemctl', "$action", "$unit"); - my $exit_code = $?>>8; - if ($exit_code != 0) { - print STDERR "$unit couldn't $action.\n"; - $global_exit_code = $exit_code; - } + push @start_units, $unit; } } - exit($global_exit_code); + if (@start_units) { + exec('/bin/systemctl', $action, @start_units) or die("Could not execute systemctl: $!"); + } + exit(0); } else { exec '/bin/systemctl', @ARGV; }