start on started java-serviceboot
start on started filecache

# Stop when the Software Update tool is about to install an update.  The tool
# uses upstart to restart jobs when the installation is complete.
stop on started start_update

respawn

pre-start script
	echo "1" > /proc/sys/vm/overcommit_memory
	mkdir -p /var/luna/preferences
	if grep -qs "qemux86" /etc/hostname ; then
		touch /var/luna/preferences/ran-first-use
	fi
	if [ ! -f /var/luna/preferences/ran-first-use ]
	then
		echo " -u minimal -a com.palm.app.firstuse" > /var/luna/preferences/sysmgr-args
	else
		echo "" > /var/luna/preferences/sysmgr-args
	fi
end script

script
	#check for MFTboot flag and attempt to launch MFT if present
	if [ `grep -c MFTboot /proc/cmdline` == "1" ]
	then
		#check for TED app
		if [ -f /var/mft/usr/bin/ted ]
		then
			exec /var/mft/usr/bin/ted -m --dfb:no-vt --dfb:no-cursor --dfb:bg-color=00000000 --dfb:pixelformat=ARGB
		else
			exec /usr/bin/LunaSysMgr -s `cat /var/luna/preferences/sysmgr-args`
		fi
	fi
	if grep -qs "qemux86" /etc/hostname ; then
		export HOME=/var/home/root
	fi
	exec /usr/bin/LunaSysMgr -s `cat /var/luna/preferences/sysmgr-args`
end script

