* Updated switch-to-configuration for Upstart 0.6.
svn path=/nixos/branches/upstart-0.6/; revision=18237
This commit is contained in:
parent
06fcb121fb
commit
b7c519456e
|
@ -54,27 +54,24 @@ EOF
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
oldEvents=$(readlink -f /etc/event.d || true)
|
oldJobs=$(readlink -f /etc/static/init)
|
||||||
newEvents=$(readlink -f @out@/etc/event.d)
|
newJobs=$(readlink -f @out@/etc/init)
|
||||||
|
|
||||||
#echo "old: $oldEvents"
|
echo "old: $oldJobs"
|
||||||
#echo "new: $newEvents"
|
echo "new: $newJobs"
|
||||||
|
|
||||||
stopJob() {
|
stopJob() {
|
||||||
local job=$1
|
local job=$1
|
||||||
initctl stop "$job"
|
initctl stop "$job" || true
|
||||||
while ! initctl status "$job" 2>&1 | grep -q "(stop) waiting"; do
|
|
||||||
echo "waiting for $job to stop..."
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Stop all services that are not in the new Upstart
|
# Stop all services that are not in the new Upstart
|
||||||
# configuration.
|
# configuration.
|
||||||
for event in $(cd $oldEvents && ls); do
|
for job in $(cd $oldJobs && ls *.conf); do
|
||||||
if ! test -e "$newEvents/$event"; then
|
job=$(basename $job .conf)
|
||||||
echo "stopping $event..."
|
if ! test -e "$newJobs/$job.conf"; then
|
||||||
stopJob $event
|
echo "stopping $job..."
|
||||||
|
stopJob $job
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -83,26 +80,27 @@ EOF
|
||||||
echo "activating the configuration..."
|
echo "activating the configuration..."
|
||||||
@out@/activate @out@
|
@out@/activate @out@
|
||||||
|
|
||||||
# Make Upstart reload its events. !!! Should wait until it has
|
# Make Upstart reload its jobs.
|
||||||
# finished processing its stop events.
|
initctl reload-configuration
|
||||||
kill -TERM 1
|
|
||||||
|
|
||||||
# Start all new services and restart all changed services.
|
# Start all new services and restart all changed services.
|
||||||
for event in $(cd $newEvents && ls); do
|
for job in $(cd $newJobs && ls *.conf); do
|
||||||
|
|
||||||
# Hack: skip the sys-* and ctrl-alt-delete events.
|
job=$(basename $job .conf)
|
||||||
|
|
||||||
|
# Hack: skip the shutdown and control-alt-delete jobs.
|
||||||
# Another hack: don't restart the X server (that would kill all the clients).
|
# Another hack: don't restart the X server (that would kill all the clients).
|
||||||
# And don't restart dbus, since that causes ConsoleKit to
|
# And don't restart dbus, since that causes ConsoleKit to
|
||||||
# forget about current sessions.
|
# forget about current sessions.
|
||||||
if echo "$event" | grep -q "^sys-\|^ctrl-\|^xserver$\|^dbus$"; then continue; fi
|
if echo "$job" | grep -q "^shutdown$\|^control-alt-delete$\|^xserver$\|^dbus$"; then continue; fi
|
||||||
|
|
||||||
if ! test -e "$oldEvents/$event"; then
|
if ! test -e "$oldJobs/$job.conf"; then
|
||||||
echo "starting $event..."
|
echo "starting $job..."
|
||||||
initctl start "$event"
|
initctl start "$job" || true
|
||||||
elif test "$(readlink "$oldEvents/$event")" != "$(readlink "$newEvents/$event")"; then
|
elif test "$(readlink "$oldJobs/$job.conf")" != "$(readlink "$newJobs/$job.conf")"; then
|
||||||
echo "restarting $event..."
|
echo "restarting $job..."
|
||||||
stopJob $event
|
stopJob $job
|
||||||
initctl start "$event"
|
initctl start "$job" || true
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue