#!/bin/bash
export LD_LIBRARY_PATH=.
copyright="(c) Copyright 2015 Hewlett Packard Enterprise Development LP"
maxargs=${#@}
args[maxargs]=
aflag=0
sflag=0
index=0
argindex=0
HELP()
{
echo "HP D2600/D2700 6Gb SAS Disk Enclosure ROM Flash Component for Linux (x64)"
echo $copyright
echo ""
echo " This package updates the firmware on HP D2600 and D2700 Disk enclosures attached to Smart Array Controllers and Host Bus Adapters. I/O module firmware included in this package adds improvements and corrects issues found during use and additional qualification testing after initial product release."
echo ""
echo "OPTIONS for in band enclosure flash"
echo "   -d <file>    Dumps discovery information in XML format to <file>"
echo "   -g|-f|-e     Force reflashing of supported items"
echo "   -q           Query hardware attached - human readable, see -d"
echo ""
echo "OPTIONS for out of band enclosure flash (flash through P2000 G3)"
echo "   -d, --discover FILE   Write discovery information in XML"
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 "   -n, --target IPADDR   Set Ip address (*)"
echo "   -l, --user UNAME      Set username (*)"
echo "   -p, --passwd PASSWORD Set password (*)"
echo " Options marked (*) are required if not set in OA_USERNAME, OA_PASSWORD, OA_ADDRESS env variables"
echo ""
echo "Activity logs are kept in /var/cpq/Component.log file"
echo ""
exit 0
}
until [ $index -ge $maxargs ]
do
case "$1" in
--help | -h ) HELP;;
-s | --silent | -d* ) sflag=1;args[$argindex]="$1"; let "argindex += 1"
let "index += 1"; shift;;
--user | -l )   export OA_USERNAME="$2"
let "index += 2"; shift 2;;
--passwd | -p )   export OA_PASSWORD="$2"
let "index += 2";shift 2;;
--target | -n ) export OA_ADDRESS="$2"
let "index += 2";shift 2;;
*)              args[$argindex]="$1"; let "argindex += 1"
let "index += 1";shift;;
esac
done
if [ -n "$OA_USERNAME" -o -n "$OA_PASSWORD" -o -n "$OA_ADDRESS" ]
then
aflag=1
fi
if [ $sflag -eq 0 ] ; then
echo "HP D2600/D2700 6Gb SAS Disk Enclosure ROM Flash Component for Linux (x64)"
echo $copyright
echo ""
echo "Version : 0150"
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.  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: When disk enclosures are cascaded, I/O module A of one enclosure is connected to I/O module A of the subsequent enclosure. During a firmware update, I/O module A in the cascaded disk enclosures is automatically updated.  In dual-domain configurations, both I/O modules of the target disk enclosure and cascaded disk enclosures are automatically updated during the firmware installation process.  All firmware flash progress messages are 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
chmod a+x ./DHFlash;./DHFlash -iCAMSPR0150_6G_app_4MB_ai.pmc -v0150 -t"D2600 SAS AJ940A" -t"D2700 SAS AJ941A" -t"260 SAS AJ940A" -t"270 SAS AJ941A" -t"D2x00 Disk Enc." -t"MDS260 CAMARO" -t"MDS270 CAMARO" "${args[@]}"
_RESULT=$?
else
./ccissflash -iCAMSPR0150_6G_app_4MB_ai.pmc -v0150 -t"D2600 SAS AJ940A" -t"D2700 SAS AJ941A" -t"260 SAS AJ940A" -t"270 SAS AJ941A" -t"D2x00 Disk Enc." -t"MDS260 CAMARO" -t"MDS270 CAMARO" "${args[@]}"
_RESULT=$?
fi
else
_RESULT=5
fi
exit $_RESULT
fi
if [ $sflag -eq 1 ] ; then
if [ $aflag == 1 ] ; then
chmod a+x ./DHFlash;./DHFlash -iCAMSPR0150_6G_app_4MB_ai.pmc -v0150 -t"D2600 SAS AJ940A" -t"D2700 SAS AJ941A" -t"260 SAS AJ940A" -t"270 SAS AJ941A" -t"D2x00 Disk Enc." -t"MDS260 CAMARO" -t"MDS270 CAMARO" "${args[@]}"
_RESULT=$?
else
./ccissflash -iCAMSPR0150_6G_app_4MB_ai.pmc -v0150 -t"D2600 SAS AJ940A" -t"D2700 SAS AJ941A" -t"260 SAS AJ940A" -t"270 SAS AJ941A" -t"D2x00 Disk Enc." -t"MDS260 CAMARO" -t"MDS270 CAMARO" "${args[@]}"
_RESULT=$?
exit $_RESULT
fi
fi
