#!/bin/sh
export LD_LIBRARY_PATH=.
copyright="(c) Copyright 2019 Hewlett Packard Enterprise Development LP"
maxargs=${#@}
aflag=0
sflag=0
index=0
argindex=0
HELP()
{
echo "HPE D3610B/D3710B 12Gb SAS Disk Enclosure ROM Flash Component for VMware (ESXi)"
echo $copyright
echo ""
echo " This package updates the I/O module firmware on HPE D3610B and D3710B Disk Enclosures attached to supported HPE Storage Controllers and Host Bus Adapters"
echo ""
echo "OPTIONS for in band enclosure flash"
echo "   -d, --discover<absolute path to file>    Dumps discovery information in XML format to <file>"
echo "   -e, --reflash  				             Flash even if the device is already up to date"
echo "   -f, --force                               Always flash applicable devices (same as -e -g)"
echo "   -g, --downgrade                           Flash if the device has a later firmware"
echo "   -s, --silent                              Do not display any text"
echo ""
echo "Activity logs are kept in /var/cpq/Component.log file"
echo ""
exit 0
}
for arg
do
case "$arg" in
--help | -h ) HELP;;
-s | --silent ) sflag=1;;
esac
done
if [ $sflag -eq 0 ] ; then
echo "HPE D3610B/D3710B 12Gb SAS Disk Enclosure ROM Flash Component for VMware (ESXi)"
echo $copyright
echo ""
echo "Version : 6.00"
echo ""
echo "Important Notes:"
cat <<-%IMP_NOTES%
 IMPORTANT: Firmware updates must be performed during a system maintenance window, with all I/O to the system halted. In single domain configuration, if user hosts an OS in D3000B(or any storage box) and flash the SEPs, it will hang/crash everytime as SmartComponent will reset the SEPs after flash/codeload.  WARNING! Do not power cycle or restart during the firmware update as this can result in loss of capabilities for this unit. It typically takes several minutes for the firmware to load.    NOTE: All firmware flash progress messages are logged to /var/cpq/D3000B.log and flash summary is logged to /var/cpq/Component.log.
%IMP_NOTES%
echo ""
echo "Warning - Please go through the above important notes section before continuing!"
echo "Do you want to continue(yes/no):"
read confirm
if expr "$confirm" : "[Yy]$" >/dev/null || expr "$confirm" : "[Yy][Ee][Ss]$" >/dev/null  ; then
if [ $aflag != 1 ] ; then
./ccissflash -t D3600B -t D3610B -t D3700B -t D3710B -v 6.00 -i Reveille-Release-6.00-build-000.bin -l D3000B.log "$@"
_RESULT=$?
fi
else
_RESULT=5
fi
exit $_RESULT
fi
if [ $sflag -eq 1 ] ; then
if [ $aflag != 1 ] ; then
./ccissflash -t D3600B -t D3610B -t D3700B -t D3710B -v 6.00 -i Reveille-Release-6.00-build-000.bin -l D3000B.log "$@"
_RESULT=$?
exit $_RESULT
fi
fi
