#!/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 D6000 6Gb SAS Disk Enclosure ROM Flash Component for Linux (x64)"
echo $copyright
echo ""
echo " This package updates the I/O module firmware on HP D6000 Disk Enclosures attached to supported HP Storage Controllers and Host Bus Adapters"
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 "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 D6000 6Gb SAS Disk Enclosure ROM Flash Component for Linux (x64)"
echo $copyright
echo ""
echo "Version : 2.98"
echo ""
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  "${args[@]}"
_RESULT=$?
fi
else
_RESULT=5
fi
exit $_RESULT
fi
if [ $sflag -eq 1 ] ; then
if [ $aflag != 1 ] ; then
./ccissflash  "${args[@]}"
_RESULT=$?
exit $_RESULT
fi
fi
