#!/bin/sh

UpdateStatus=/mnt/mtd/Update.dat
PreUpgradeSh=/upgrade/preupgrade.sh


modprobe vfat              
modprobe nls_ascii        
modprobe nls_iso8859-2   
modprobe scsi_mod       
	
modprobe nls_base
modprobe nls_cp437
modprobe fat
modprobe msdos
modprobe nls_iso8859-1
modprobe libata
	
modprobe usbhid   
modprobe evdev    
modprobe mousedev 
	
#about sata
modprobe scsi_mod
modprobe sd_mod  
modprobe sata_sil
	
modprobe usbcore      
modprobe ohci-hcd     
modprobe ehci-hcd
modprobe usb-storage

rm /nfsdir -rf
mkdir /nfsdir
mount -t tmpfs tmpfs /nfsdir


# 检查文件是否存在和可读
if [ ! -e "$UpdateStatus" -o ! -r "$UpdateStatus" ] ; then
	#为空，表示刚才在升级时，进行了重启。所以需要在次升级
	echo 1 > ${UpdateStatus}
	chmod 666 ${UpdateStatus}
fi

RESULT=`cat "$UpdateStatus"`
if [ "$RESULT" = "1" ] ; then
	ls ${PreUpgradeSh}
	if [ "$?" != 0 ] ; then 
		echo 0 > ${UpdateStatus}
		/mnt/mtd/dep2.sh		
	else
		sh ${PreUpgradeSh}			
	fi		
else
	echo "No need to recovery program from USB"
	/mnt/mtd/dep2.sh
fi

