#!/bin/sh
#
# Copyright (c) 2019-2022 Citrix Systems, Inc. All rights reserved.
# This software and documentation contain valuable trade
# secrets and proprietary property belonging to Citrix Systems, Inc.
# None of this software and documentation may be copied,
# duplicated or disclosed without the express
# written permission of Citrix Systems, Inc.
#
# 11/04/22
#
# This file contains shell script code provided as a convenience
# for interested parties contemplating Mellanox NIC firmware update.
# It outputs (and logs) important information about installed Mellanox
# NICs.
#
# usage:  sh mellanox_nic_info
#

SCRIPTS_DIR=/var/tmp/Mellanox/scripts
FW_UPDATE_SUBR="./mellanox_fw_update_subr"

cd ${SCRIPTS_DIR}

#
# Load the subroutine file
#
if [ -f ${FW_UPDATE_SUBR} ]
then
	. ${FW_UPDATE_SUBR}
else
	echo ">>> Missing ${FW_UPDATE_SUBR} file!"
	exit 100
fi

log_msg ">>> =================================================================="
log_msg ">>> Invoking mellanox_nic_info informational script $(date)"

has_mellanox_nics
HAS_MELLANOX=$?
if [ ${HAS_MELLANOX} -eq 0 ]
then
	log_msg ">>> NetScaler has at least one Mellanox NIC"
else
	log_msg ">>> NetScaler does not have Mellanox NICs"
	exit 101
fi

# Print FW version and other information for each Mellanox NIC.
output_all_nics_info
# Allow the above to flush out to console, log file.
sleep 4

