#! /bin/sh
# Run on the first boot after shipping to the end user to reconfigure the
# system for them; removes itself thereafter.
set -e

PATH="/usr/local/sbin:/usr/sbin:/sbin${PATH:+:$PATH}"

if ! type oem-config-firstboot >/dev/null 2>&1; then
	exit 0
fi

case $1 in
	start)
		# Make the splash screen go away if necessary.
		if type usplash_write >/dev/null 2>&1 && \
		   [ "$TERM" = linux ]; then
			clear >/dev/tty1
			chvt 1
			usplash_write QUIT || true
		fi

		# Reconfigure the system (starts a temporary display
		# manager).
		oem-config-firstboot </dev/console >/dev/console 2>&1
		
		# The lateboot cmds may need some setup after user config
		# has completed 
		if [ -x /usr/sbin/lateboot-setup ]; then
			/usr/sbin/lateboot-setup
		fi
		;;
esac

exit 0
