#! /bin/sh
set -x

cd "$(dirname "$0")"

if [ `md5sum /boot/setting.ss |awk '{print $1}'` == `md5sum ./setting.ss |awk '{print $1}'` ]
  then 
    echo "no need /boot/setting.ss"
  else 
	echo "need copy /bootx/setting.ss!"
#	cp ./setting.ss /boot
fi

if [ `md5sum /home/root/sboox_data/setting.ss |awk '{print $1}'` == `md5sum ./setting.ss |awk '{print $1}'` ]
  then 
    rm ./setting.ss
  else 
	echo "need copy /bootx/fpga.img!"
#	mv ./setting.ss /home/root/sboox_data/
fi

if [ `md5sum /boot/fpga.img |awk '{print $1}'` == `md5sum ./fpga.img |awk '{print $1}'` ]
  then 
    rm ./fpga.img
  else 
	echo "need copy /bootx/fpga.img!"
	mv ./fpga.img /boot
	write_fpga
fi

sync
/home/root/sboox/run.sh
