From a630a314f2e6fc64f45b07f0822cea615c336708 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 19 Dec 2006 01:34:09 +0000 Subject: [PATCH] * Wait for jobs to finish. svn path=/nixos/trunk/; revision=7418 --- configuration/switch-to-configuration.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/configuration/switch-to-configuration.sh b/configuration/switch-to-configuration.sh index 11a5ccb53676..1a83f380a77c 100644 --- a/configuration/switch-to-configuration.sh +++ b/configuration/switch-to-configuration.sh @@ -41,12 +41,21 @@ if test "$action" = "switch" -o "$action" = "test"; then echo "old: $oldEvents" echo "new: $newEvents" + stopJob() { + local job=$1 + initctl stop "$job" + while ! initctl list 2>&1 | grep -q "initctl: $job (stop)"; do + echo "waiting for $job..." + sleep 1 + done + } + # Stop all services that are not in the new Upstart # configuration. for event in $(cd $oldEvents && ls); do if ! test -e "$newEvents/$event"; then echo "stopping $event..." - initctl stop "$event" + stopJob $event fi done @@ -66,7 +75,7 @@ if test "$action" = "switch" -o "$action" = "test"; then initctl start "$event" elif test "$(readlink "$oldEvents/$event")" != "$(readlink "$newEvents/$event")"; then echo "restarting $event..." - initctl stop "$event" + stopJob $event initctl start "$event" else echo "unchanged $event"