#!/bin/sh
SD_DEV_1=/dev/mmcblk0p1
SD_DEV_2=/dev/mmcblk0p2
SD_DIR_1=/mnt/sd1
SD_DIR_2=/mnt/sd2
SD_DIR_3=/mnt/sd3
OPT_DIR=/opt
UPDATE_FOLDER=UPDATE_GLITE965GW
UPDATE_FILENAME=update.sh

mount_check=`mount | grep $SD_DEV_1 | awk '{print $1}'`
if [ "$mount_check" == "" ] ; then
	mount -t vfat $SD_DEV_1 $SD_DIR_1
fi

mount_check=`mount | grep $SD_DEV_2 | awk '{print $1}'`
if [ "$mount_check" == "" ] ; then
	mount -t vfat $SD_DEV_2 $SD_DIR_2
fi

if [ -f $SD_DIR_2/$UPDATE_FOLDER/$UPDATE_FILENAME ]; then
	$SD_DIR_2/$UPDATE_FOLDER/$UPDATE_FILENAME
fi

if [ -f $SD_DIR_1/$UPDATE_FOLDER/$UPDATE_FILENAME ]; then
	$SD_DIR_1/$UPDATE_FOLDER/$UPDATE_FILENAME
fi

if [ -d $SD_DIR_2$OPT_DIR ] ; then
	WORKDIR=$SD_DIR_2$OPT_DIR
else
	WORKDIR=$OPT_DIR
fi


echo "AUTORUN_WORKDIR="$WORKDIR
cd $WORKDIR
./loadmodules.sh
insmod SENSOR.ko
insmod io.ko
./GL965GW &
