# latebootcmds
#
# Run boot commands that can be delayed until UI is up.

description "latebootcmds"
author      "Debbie Beliveau <debbie.beliveau@canonical.com>"

start on boot-phase ui-started

script

	# For now, we sleep to let UI finish loading. In the future, we need
	# to be smarter about this (UI needs to tell us exactly when its done
	# loading)
	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
	modprobe ieee80211_crypt 
	modprobe ieee80211_crypt_tkip
        
        # load hpmini power control module
        modprobe hpmini

	# 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

	# enable kernel USB PERSIST; enables SD cards to
	# remain inserted/mounted across suspend/resume.
	echo 1 > /sys/bus/usb/devices/5-5/power/persist

  # enable acpi events for video button (Fn+F2)
  echo 0 > /proc/acpi/video/IGD/DOS

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

	# Emit an event so any tasks that depend us know when they can run
	initctl emit boot-phase late-boot-cmds-run -n

end script

