5
if [ "$1" = configure ]; then
6
# A dependent library of Upstart has changed, so restart Upstart
7
# such that it can safely unmount the root filesystem (LP: #740390)
9
# Query running version of Upstart, but only when we know
10
# that initctl will work.
12
# The calculated version string may be the null string if
13
# Upstart is not running (where for example an alternative
14
# init is running outside a chroot environment) or if the
15
# query failed for some reason. However, the version check
16
# below handles a null version string correctly.
17
UPSTART_VERSION_RUNNING=$(initctl version 2>/dev/null |\
18
awk '{print $3}'|tr -d ')' || :)
21
# Do not honour re-exec when requested from within a
24
# (a) The version of Upstart outside might not support it.
25
# (b) An isolated environment such as a chroot should
26
# not be able to modify its containing environment.
28
# A sufficiently new Upstart will actually handle a re-exec
29
# request coming from telinit within a chroot correctly (by
30
# doing nothing) but it's simple enough to perform the check
31
# here and save Upstart the effort.
33
elif dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 1.6.1; then
34
# We are not running inside a chroot and the running version
35
# of Upstart supports stateful re-exec, so we can
36
# restart immediately.
38
# XXX: Note that the check on the running version must
39
# remain *indefinitely* since it's the only safe way to
40
# know if stateful re-exec is supported: simply checking
41
# packaged version numbers is not sufficient since
42
# the package could be upgraded multiple times without a
46
# Before we shutdown or reboot, we need to re-exec so that we
47
# can safely remount the root filesystem; we can't just do that
48
# here because we lose state.
49
touch /var/run/init.upgraded || :