#!/bin/sh
#######################################################################
#Version:1.0
#Author:Neo.Zhang
#Program:This shell script is used to update Inspur server BIOS and BMC
#only support V4 and V5 Platform
#date:2018/08/31
#######################################################################

CPWD=`cd $(dirname  $0);pwd`
os_version=`cat /etc/redhat-release |awk '{print $3}' |awk -F"." '{print $1}'`

gcc_4_9_2_inst(){
if [  ! -e /usr/bin/expect ];then
        yum install expect -y
else
        echo "expect tool is already installed"
fi
yum install policycoreutils-python.x86_64 scl* devtoolset-3-runtime devtoolset-3-binutils devtoolset-3-gcc devtoolset-3-libstdc++ devtoolset-3-gcc-c++ -y
#rpm -ivh \
 #        devtoolset-3-runtime-3.1-12.el6.x86_64.rpm \
  #       devtoolset-3-binutils-2.24-18.el6.x86_64.rpm \
   #      devtoolset-3-gcc-4.9.2-6.2.retpoline.el6.x86_64.rpm \
    #     devtoolset-3-libstdc++-devel-4.9.2-6.2.retpoline.el6.x86_64.rpm \
     #    devtoolset-3-gcc-c++-4.9.2-6.2.retpoline.el6.x86_64.rpm
}

if [[ ${os_version} =~ 6 ]];then
        cd $CPWD
        gcc_4_9_2_inst
        scl enable devtoolset-3 "sh BIOS_BMC.sh"
else
        cd $CPWD
        sh BIOS_BMC.sh
fi
