File qla4xxx.sh of Package qlogic-rules

#!/bin/sh

#***********************************************************************#
# QLogic qla4xxx firmware dump collection script
# Copyright (C) 2013-2014 QLogic Corporation
# (www.qlogic.com)
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# A copy of the GNU General Public License, version 2 can be found at
# http://www.gnu.org/licenses/gpl-2.0.txt
#***********************************************************************#

# ACTION FILE: located in /usr/lib/qlogic-rules/

err() {
	echo "$@" >&2
	if [ -x /bin/logger ]; then
		/bin/logger -t "${0##*/}[$$]" "$@"
	fi
}

SYSFS=/sys
HOST=${FW_DUMP}
QFWD=${SYSFS}/class/scsi_host/host${HOST}/device/fw_dump
DFILE_PATH=/opt/QLogic_Corporation/FW_Dumps
DFILE=${DFILE_PATH}/qla4xxx_fw_dump_${HOST}_`eval date +%Y%m%d_%H%M%S`.bin

mkdir -p $DFILE_PATH &> /dev/null
# Verify fw_dump binary-attribute file
if ! test -f ${QFWD} ; then
	err "qla4xxx: no firmware dump file at host $HOST!!!"
	exit 1
fi

# Go with dump
echo 1 > ${QFWD}
cat ${QFWD} > ${DFILE}
echo 0 > ${QFWD}
if ! test -s "${DFILE}" ; then
	err "qla4xxx: no firmware dump file at host ${HOST}!!!"
	rm ${DFILE}
	exit 1
fi

gzip ${DFILE}
err "qla4xxx: firmware dump saved to file ${DFILE}.gz."
exit 0
openSUSE Build Service is sponsored by