#!/bin/sh
#   cfgbios.sh  - script to save/restore BIOS configuration
#
syscfgd=/opt/deploy/Linux/syscfg
cfgfile=$DeploymentStore/cfgbios.scf
logfile=$DeploymentStore/cfgbios.log
ADDLOG=addLogRecord
# ADDLOG=echo

cd $syscfgd
./syscfg /d BIOS >$logfile 2>&1
ret=$?
if [ $ret -ne 0 ]
then
 $ADDLOG CFGBIOS ERROR "Error $ret: BIOS config display"
 exit $ret
fi

# save the BIOS configuration
rm -f $cfgfile 2>/dev/null
./syscfg /s $cfgfile /b >>$logfile 2>&1
ret=$?
if [ $ret -eq 0 ]
then
 $ADDLOG CFGBIOS INFO "Success: BIOS config saved"
else
 $ADDLOG CFGBIOS ERROR "Error $ret: BIOS config save failed"
fi

# restore the BIOS configuration
./syscfg /r $cfgfile /b >>$logfile 2>&1
ret=$?
if [ $ret -eq 0 ]
then
 $ADDLOG CFGBIOS INFO "Success: BIOS config restored"
else
 $ADDLOG CFGBIOS ERROR "Error $ret: BIOS config restore failed"
fi
echo "cfgbios with $cfgfile returned $ret "
exit $ret
