35 lines
681 B
Plaintext
35 lines
681 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
declare -r EXIT_SUCCESS="0"
|
||
|
declare -r EXIT_ERROR="1"
|
||
|
|
||
|
declare -r FW_UPGRADE_SCRIPT="/usr/bin/mlnx-fw-upgrade.sh"
|
||
|
|
||
|
FORCE_REBOOT="no"
|
||
|
|
||
|
function ParseArguments() {
|
||
|
while [ $# -ge 1 ]; do
|
||
|
case "$1" in
|
||
|
-f|--force)
|
||
|
FORCE_REBOOT="yes"
|
||
|
;;
|
||
|
esac
|
||
|
shift
|
||
|
done
|
||
|
}
|
||
|
|
||
|
ParseArguments "$@"
|
||
|
|
||
|
${FW_UPGRADE_SCRIPT} --upgrade
|
||
|
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
|
||
|
|
||
|
exec /sbin/reboot $@
|