#!/bin/bash

#enter sub folder
cd lxflash_v11800/

#check architecture
CMD=`uname -m | cut -c 1-6`
if [ "$CMD" = "x86_64" ]; then
		[ -f ./socflash_x64 ] || {
		echo "There is no BMC flash utility in current directory."
		exit 4
		}
   chmod 777 socflash_x64
   #./socflash_x64 $@
   ./socflash_x64 if=../rom.ima option=g
else
		[ -f ./socflash ] || {
		echo "There is no BMC flash utility in current directory."
		exit 4
		}
   chmod 777 socflash
   #./socflash $@
   ./socflash if=../rom.ima option=g
fi

retval=$?
if [ $retval -ne 0 ]; then 
	echo "Update BMC firmware failed"
	exit 1
fi