#!/bin/sh
set -x

WORKDIR=$(cd `dirname $0`; pwd)
FIRMWARE_M3=Guider_N32.bin
	
	
cd  /control
controlDir=$(ls -ld [0-9]* |awk '/^d/ {print $NF}')
for controlVer in $controlDir
do
	echo $controlVer >> $LOG
done

if [ -f /control/$controlVer/NationsCommand ];then
        chmod a+x /control/$controlVer/NationsCommand
        if [ -f /control/$controlVer/$FIRMWARE_M3 ];then
                echo "burn M3 firmware..." >> $LOG
                /control/$controlVer/NationsCommand -c -d --fn /control/$controlVer/$FIRMWARE_M3 --v -r
        	sleep 20
	fi
fi

exit 0