From 56ce5614f9c17b84e21783ab3cf69774e954967c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 3 Aug 2012 10:40:01 -0400 Subject: [PATCH] switch-to-configuration: Print all failed services --- .../activation/switch-to-configuration.pl | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/system/activation/switch-to-configuration.pl b/modules/system/activation/switch-to-configuration.pl index b9ba9b14e63c..4ff4cf1420fe 100644 --- a/modules/system/activation/switch-to-configuration.pl +++ b/modules/system/activation/switch-to-configuration.pl @@ -57,6 +57,9 @@ sub getActiveUnits { return $res; } +# Forget about previously failed services. +system("@systemd@/bin/systemctl", "reset-failed"); + # Stop all services that no longer exist or have changed in the new # configuration. # FIXME: handle template units (e.g. getty@.service). @@ -91,9 +94,24 @@ system("@systemd@/bin/systemctl", "daemon-reload") == 0 or $res = 3; # Start all units required by the default target. This should start # all changed units we stopped above as well as any new dependencies. print STDERR "starting default target...\n"; -system("@systemd@/bin/systemctl", "start", "default.target") == 0 or $res = 3; +system("@systemd@/bin/systemctl", "start", "default.target") == 0 or $res = 4; # Signal dbus to reload its configuration. system("@systemd@/bin/systemctl", "reload", "dbus.service"); +# Check all the failed services. +$active = getActiveUnits; +my @failed; +while (my ($unit, $state) = each %{$active}) { + push @failed, $unit if $state->{state} eq "failed"; +} +if (scalar @failed > 0) { + print STDERR "warning: the following units failed: ", join(", ", @failed), "\n"; + foreach my $unit (@failed) { + print STDERR "\n"; + system("@systemd@/bin/systemctl status '$unit' >&2"); + } + $res = 4; +} + exit $res;