#!/bin/sh

# Create default directories for application.
# This will be useful while system not be installed correctly.
[ -d /apps/app ] || mkdir /apps/app
[ -d /data/backup ] || mkdir /data/backup
[ -d /data/backup/temp ] || mkdir /data/backup/temp
[ -d /apps/app/data ] || ln -s /data /apps/app
[ -d /mnt/usb ] || mkdir /mnt/usb
[ -d /mnt/mmc ] || mkdir /mnt/mmc

[ -f /lib/modules/2.6.24.3/modules.dep ] || /sbin/depmod

# Check USB update package first.
if [ -x /apps/etc/update.mmc ]
then
	/apps/etc/update.mmc
fi

if [ -x /apps/etc/update.usb ]
then
	/apps/etc/update.usb
fi

. /usr/local/tslib/setenv.sh

cd /apps/update
if [ -f autoupdate ]
then
	[ -x autoupdate ] || chmod +x autoupdate
	./autoupdate
fi

cd /apps/app

if [ -f /apps/app/a7688c ]
then
	# Start up application.
	[ -x a7688c ] || chmod +x a7688c
	./a7688c &
	
	# /bin/install /apps/update/crontab.txt /var/spool/cron/crontabs -d
    	# /bin/install /apps/update/crontab.txt /var/spool/cron/crontabs/root
	# /sbin/crond &

	#2009.11.25
	if [ -f /apps/update/upgrade ]
	then
		# Start up adv update.
		sleep 12
		cd /apps/update
		[ -x advupdate ] || chmod +x advupdate
		./upgrade advupdate &
	fi
else	
	# Application installed incompletely.
	showstr 10 200 "No applet found !"&

	#delete dhcp of a7688 version
fi


#/bin/inetd&
