# latebootcmds
#
# Run commands that can or should be delayed until the end of
# boot

start on runlevel 2

script

    # For now, we just arbitrarily wait 10 seconds. Should change this
    # to some more specific and accurate as needed.
    sleep 10

    # By default, an upstart task will automatically exit on an error. We
    # want the task to complete even if any of our commands return an error
    # so we turn off the exit-on-error option
    set +e

    modprobe uvcvideo

    # We delay iterating though dbus's event directory until now
    EVENTDIR=/etc/dbus-1/event.d

    if [ -d $EVENTDIR ]; then
        run-parts --arg=start $EVENTDIR
    fi

    # Start all services we delayed from /etc/rc2.d
    /etc/init.d/anacron start
    /etc/init.d/apport start
    /etc/init.d/cupsys start
    /etc/init.d/pulseaudio start

    # Re-enable the exit-on-error option now that we're done
    set -e

    initctl emit boot-phase late-boot-cmds-run -n

end script
