#!/bin/sh
#     cfgnic.sh  - script to configure NICs
#
logfile=$DeploymentStore/cfgnic.log
devlist="eth0 eth1"
speed=1000
duplex=full
ADDLOG=addLogRecord
# ADDLOG=echo

# init the logfile
date >$logfile

for dev in $devlist
do
  isOK=0
  
  # save the NIC parameters
  echo "ethtool $dev"  >>$logfile
  ethtool  $dev  >>$logfile 2>&1
  ret=$?
  if [ $ret -eq 0 ]
  then
   $ADDLOG CFGNIC INFO "Cfg NIC: ethtool $dev"
   isOK=1
  fi

  if [ $isOK -eq 1 ]
  then
    # set the speed and duplex for this NIC
    params="speed $speed duplex $duplex"
    echo "ethtool -s $dev $params" >>$logfile
    ethtool -s $dev $params >>$logfile 2>&1
    ret=$?
    if [ $ret -eq 0 ]
    then
     $ADDLOG CFGNIC INFO "Success: ethtool -s $dev $params"
    else
     $ADDLOG CFGNIC ERROR "Error $ret: ethtool -s $dev $params"
    fi
  fi
done

exit $ret 
