~jamesodhunt/ubuntu/saucy/upstart/1.9

« back to all changes in this revision

Viewing changes to debian/upstart.postinst

  • Committer: Dmitrijs Ledkovs
  • Date: 2013-06-14 17:02:58 UTC
  • Revision ID: dmitrijs.ledkovs@canonical.com-20130614170258-vr589l2iy9qigeh5
* Simplify postinst re-exec logic by removing runlevel checks. Now the
  logic is:
  - re-exec if lossless stateful re-exec is available
  - perform partial stateful re-exec, unless running under upstart
  - re-exec if upgrading from pre dbus capable upstart
  - do nothing if running from chroot
  - otherwise hint that init is upgraded

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
                # but it's simple enough to perform the check here and save
61
61
                # Upstart the effort.
62
62
                :
63
 
            elif dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 1.6.1; then
 
63
            elif dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 1.9 || [ "$UPSTART_VERSION_RUNNING" = 1.8-ubuntu-full-serialization ]; then
64
64
                # We are not running inside a chroot and the running version
65
 
                # of Upstart supports stateful re-exec, so we can
 
65
                # of Upstart supports lossless stateful re-exec, so we can
66
66
                # restart immediately.
67
67
                #
68
68
                # XXX: Note that the check on the running version must
71
71
                # packaged version numbers is not sufficient since
72
72
                # the package could be upgraded multiple times without a
73
73
                # reboot.
74
 
                runlevel=$(runlevel|awk '{print $2}' || :)
75
 
 
76
 
                # Only perform stateful re-exec with upstart that has
77
 
                # full serialisation or if running on a system that
78
 
                # has booted "fully" to runlevel 2 or higher.
79
 
                #
80
 
                # This works around a potential problem where
81
 
                # cloud-init (which runs in early boot) in
82
 
                # dist-upgrading the system ends up upgrading Upstart,
83
 
                # which calls this maintainer script.
84
 
 
85
 
                if dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 1.9 || [ "$UPSTART_VERSION_RUNNING" = 1.8-ubuntu-full-serialization ]
86
 
                then
87
 
                    telinit u || :
88
 
                elif [ "$UPSTART_JOB" = "cloud-config" ]
89
 
                then
90
 
                    touch /var/run/init.upgraded || :
91
 
                    [ -x /usr/share/update-notifier/notify-reboot-required ] && \
92
 
                        /usr/share/update-notifier/notify-reboot-required || true
93
 
                else
94
 
                    case $runlevel in
95
 
                        [2345])
96
 
                            telinit u || :
97
 
                            ;;
98
 
                        *)
99
 
                            touch /var/run/init.upgraded || :
100
 
                            [ -x /usr/share/update-notifier/notify-reboot-required ] && \
101
 
                                /usr/share/update-notifier/notify-reboot-required || true                           
102
 
                            ;;
103
 
                    esac
104
 
                fi
 
74
                telinit u || :
 
75
            elif [ "$UPSTART_JOB" = "cloud-config" ]; then
 
76
                # If upgraded by cloud-init, do not perform partial
 
77
                # stateful re-exec, as cloud-init instance will fail
 
78
                # to initialise.
 
79
                touch /var/run/init.upgraded || :
 
80
                [ -x /usr/share/update-notifier/notify-reboot-required ] && \
 
81
                    /usr/share/update-notifier/notify-reboot-required || true
 
82
 
 
83
            elif dpkg --compare-version "$UPSTART_VERSION_RUNNING" ge 1.6.1; then
 
84
                # Otherwise, perform partial stateful re-exec and
 
85
                # request a reboot.
 
86
                telinit u || :
 
87
                [ -x /usr/share/update-notifier/notify-reboot-required ] && \
 
88
                    /usr/share/update-notifier/notify-reboot-required || true                       
105
89
            else
106
90
                # Before we shutdown or reboot, we need to re-exec so that we
107
91
                # can safely remount the root filesystem; we can't just do that