#/bin/bash
cd `dirname $0`
UDISK_ROOT=`pwd`

show_msg()
{
	echo -e "$1" 
}

main()
{
	show_msg "system is updating, please wait..."
	sudo umount /dev/nanda -l 2>/dev/null
	sudo mount /dev/nanda /boot &&
	sudo busybox tar zxvf ${UDISK_ROOT}/dvi_20130225.tgz -C / >/dev/null 2>&1 &&
	sync

	if [ $? -eq 0 ]; then
		show_msg "Update succeed!\nSystem will reboot in 10 seconds"
		sync && sleep 10 && sudo reboot
	else
		show_msg "Update failed!\nPlease check the update package is correct!"
		sudo umount /boot
	fi
}

main


