sonic-buildimage/device/mellanox/x86_64-mlnx_msn2700-r0/platform_reboot
Mykola F 2a7d8624cb [Mellanox] align platform reboot to use "hardware reboot" (#3321)
Signed-off-by: Mykola Faryma <mykolaf@mellanox.com>
2019-08-19 10:25:39 -07:00

39 lines
850 B
Bash
Executable File

#!/bin/bash
declare -r EXIT_SUCCESS="0"
declare -r EXIT_ERROR="1"
declare -r FW_UPGRADE_SCRIPT="/usr/bin/mlnx-fw-upgrade.sh"
declare -r SYSFS_PWR_CYCLE="/sys/devices/platform/mlxplat/mlxreg-io/hwmon/hwmon*/pwr_cycle"
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 --verbose
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
# perform "hardware" reboot
echo 1 > $SYSFS_PWR_CYCLE
sleep 3
echo 0 > $SYSFS_PWR_CYCLE