#!/bin/sh
#      cfgamt.sh  - script to configure AMT firmware settings
# 
# Usage: amtcfg [-deopx -DGHINPS ]
#  where -x   shows eXtra debug messages
#        -d   disables/unprovisions AMT
#        -o oldpsw Old AMT password, used with -p
#        -p psw    sets AMT password
#        -D        sets DHCP shared mode
#        -I ipadr  sets static IP address
#        -S subnet sets Subnet mask
#        -G gwyip  sets Gateway IP address
#        -P dnsip  sets Primary DNS address
#        -N domain sets domain Name
#        -H hostnm sets Hostname
amtip=10.243.42.235
amtgwy=10.243.42.251
amtdns=10.127.1.11
amtdom=intel.com
amtname=aspenhill1
oldpsw=admin
newpsw=Password~2
logfile=$DeploymentStore/cfgamt.log
ADDLOG=addLogRecord
# ADDLOG=echo

if [ $# -ge 1 ]
then
   amtip=$1
   if [ $# -ge 2 ]
   then
      amtname=$2
      if [ $# -ge 3 ]
      then
         amtgwy=$3
      fi
      if [ $# -ge 4 ]
      then
         amtdns=$4
      fi
   fi
fi

# init the logfile
date >$logfile
parms="-I $amtip -G $amtgwy -P $amtdns -N $amtdom -H $amtname"
amtcfg $parms -o $oldpsw -p $newpsw >>$logfile 2>&1
ret=$?
if [ $ret -eq 0 ]
then
 $ADDLOG AMTCFG INFO "Success: amtcfg $parms"
else
 $ADDLOG AMTCFG ERROR "Error $ret: amtcfg $parms"
fi
echo "amtcfg $parms returned $ret "
exit $ret
