# -*- mode: shell-script; -*-

# NOTE: PmUpdater sometimes calls system("/sbin/reboot") or otherwise
# changes the runlevel and so kicks off a second chain of upstart
# jobs.  In that case we don't want to continue this one.  So when it
# does that, PmUpdater returns a non-0 value from main().  The job
# that immediately follows this one should test for that (via "ok").
# Currently that's hostname.  Any other job doing 'start on stopped
# updater' must also add "ok".

start on stopped devpts

script
    if [ -e /var/lib/software/updating ]; then
        if [ -x /var/lib/update/PmUpdater ]; then
            if [ -x /var/lib/update/libipkg.so.0.0.0 ]; then
                LD_LIBRARY_PATH=/var/lib/update/ /var/lib/update/PmUpdater
            else
                /var/lib/update/PmUpdater
            fi
        else
            /usr/bin/PmUpdater
        fi
    fi
end script
