2018-10-05 12:33:40 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
declare -r EXIT_SUCCESS="0"
|
|
|
|
declare -r EXIT_ERROR="1"
|
|
|
|
|
2022-01-24 02:56:38 -06:00
|
|
|
declare -r PENDING_COMPONENT_FW="/usr/bin/install-pending-fw.py"
|
2018-10-05 12:33:40 -05:00
|
|
|
declare -r FW_UPGRADE_SCRIPT="/usr/bin/mlnx-fw-upgrade.sh"
|
2022-06-07 07:05:54 -05:00
|
|
|
declare -r SYSFS_PWR_CYCLE="/var/run/hw-management/system/pwr_cycle"
|
2018-10-05 12:33:40 -05:00
|
|
|
|
|
|
|
FORCE_REBOOT="no"
|
|
|
|
|
|
|
|
function ParseArguments() {
|
|
|
|
while [ $# -ge 1 ]; do
|
|
|
|
case "$1" in
|
|
|
|
-f|--force)
|
|
|
|
FORCE_REBOOT="yes"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-09-17 11:38:30 -05:00
|
|
|
function SafePwrCycle() {
|
2023-08-04 15:24:38 -05:00
|
|
|
sync; sync
|
|
|
|
umount -fa > /dev/null 2>&1
|
2019-09-17 11:38:30 -05:00
|
|
|
echo 1 > $SYSFS_PWR_CYCLE
|
|
|
|
}
|
|
|
|
|
2018-10-05 12:33:40 -05:00
|
|
|
ParseArguments "$@"
|
|
|
|
|
2023-08-04 15:24:38 -05:00
|
|
|
# Reboot immediately if the kdump capture kernel is running
|
|
|
|
VMCORE_FILE=/proc/vmcore
|
|
|
|
if [ -s $VMCORE_FILE ]; then
|
|
|
|
sync; sync
|
|
|
|
umount -fa > /dev/null 2>&1
|
|
|
|
|
|
|
|
# Run Debian reboot because the platform reboot isn't available
|
|
|
|
/sbin/reboot
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2019-08-19 12:25:39 -05:00
|
|
|
${FW_UPGRADE_SCRIPT} --upgrade --verbose
|
2018-10-05 12:33:40 -05:00
|
|
|
EXIT_CODE="$?"
|
|
|
|
if [[ "${EXIT_CODE}" != "${EXIT_SUCCESS}" ]]; then
|
|
|
|
echo "Failed to burn MLNX FW: errno=${EXIT_CODE}"
|
|
|
|
|
|
|
|
if [[ "${FORCE_REBOOT}" != "yes" ]]; then
|
|
|
|
echo "Reboot is interrupted: use -f|--force to override"
|
|
|
|
exit "${EXIT_ERROR}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2022-01-24 02:56:38 -06:00
|
|
|
${PENDING_COMPONENT_FW}
|
|
|
|
|
2019-09-17 11:38:30 -05:00
|
|
|
SafePwrCycle
|