File qla2xxx.sh of Package qlogic-rules

#!/bin/sh

#***********************************************************************#
# QLogic qla2xxx 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 /lib/udev/

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

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

# Verify fw_dump binary-attribute file
if ! test -f ${QFWD} ; then
	err "qla2xxx: no firmware dump file at host $HOST!!!"
	exit 1
fi

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

gzip ${DFILE}
err "qla2xxx: firmware dump saved to file ${DFILE}.gz."
exit 0

openSUSE Build Service is sponsored by