#!/bin/sh
filename=`cat rom_enc.txt`
echo ""
echo BMC firmware image: $filename

ip=$1
pwd=$2

cd linuxflash

#check architecture
CMD=`uname -m | cut -c 1-6`
if [ "$CMD" = "x86_64" ]; then
   cd Linux_x86_64
   echo ""
   echo Linux x86_64 Environment
   chmod 777 Yafuflash2
   ./Yafuflash2 -vyes -nw -ip $ip -u admin -p $pwd -fb -pc ../../$filename
   errorcode=$?
   if [ "$errorcode" != "0" ]
   then
   echo -e " Yafuflash error code : $errorcode , stop update"
   exit 0 
   fi
else
   cd Linux_x86_32
   echo ""
   echo Linux x86 Environment
   chmod 777 Yafuflash2
   ./Yafuflash2 -vyes -nw -ip $ip -u admin -p $pwd -fb -pc ../../$filename
   errorcode=$?
   if [ "$errorcode" != "0" ]
   then
   echo -e " Yafuflash error code : $errorcode , stop update"
   exit 0 
   fi
fi
 
cd ../.. 
