#!/bin/sh
export LD_LIBRARY_PATH=.
copyright="(c) Copyright 2019 Hewlett Packard Enterprise Development LP"
buildnumber="Smart Component Build Number : 10"
maxargs=${#@}
aflag=0
sflag=0
index=0
argindex=0
HELP()
{
echo "HPE D8000 12Gb SAS Disk Enclosure ROM Flash Component for VMware (ESXi)"
echo $copyright
echo $buildnumber
echo ""
echo " This package updates the I/O module firmware on HPE D8000 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 D8000 12Gb SAS Disk Enclosure ROM Flash Component for VMware (ESXi)"
echo $copyright
echo $buildnumber
echo ""
echo "Version : 0130"
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 D8000(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/D8000.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 D8000 -v 0130 -i 93-00001181_hpe_cffebod_dual_path_combined_fw_inband_r2021.51.4.gff -i 93-00007488_hpe_cffebod_single_path_combined_fw_inband_r2021.51.4.gff -l D8000.log "$@"
_RESULT=$?
fi
else
_RESULT=5
fi
exit $_RESULT
fi
if [ $sflag -eq 1 ] ; then
if [ $aflag != 1 ] ; then
./ccissflash -t D8000 -v 0130 -i 93-00001181_hpe_cffebod_dual_path_combined_fw_inband_r2021.51.4.gff -i 93-00007488_hpe_cffebod_single_path_combined_fw_inband_r2021.51.4.gff -l D8000.log "$@"
_RESULT=$?
exit $_RESULT
fi
fi
