Skip to content

Commit

Permalink
remove exit codes, add mlnx if fi
Browse files Browse the repository at this point in the history
Signed-off-by: vadymhlushko-mlnx <[email protected]>
  • Loading branch information
vadymhlushko-mlnx committed Nov 27, 2023
1 parent 78b9ba1 commit 6293229
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions scripts/reboot
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash -x

declare -r EXIT_SUCCESS="0"
declare -r EXIT_ERROR="1"

DEVPATH="/usr/share/sonic/device"
PLAT_REBOOT="platform_reboot"
PLATFORM_UPDATE_REBOOT_CAUSE="platform_update_reboot_cause"
Expand Down Expand Up @@ -128,7 +125,7 @@ function show_help_and_exit()
echo " -h, -? : getting this help"
echo " -f : execute reboot force"

exit "${EXIT_SUCCESS}"
exit 0
}

function setup_reboot_variables()
Expand Down Expand Up @@ -200,7 +197,7 @@ parse_options $@
# Exit if not superuser
if [[ "$EUID" -ne 0 ]]; then
echo "This command must be run as root" >&2
exit "${EXIT_ERROR}"
exit 1
fi

debug "User requested rebooting device ..."
Expand Down Expand Up @@ -254,12 +251,6 @@ if [ -x ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} ]; then
VERBOSE=yes debug "Rebooting with platform ${PLATFORM} specific tool ..."
${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} ${FLAGS}

EXIT_CODE="$?"

if [[ "${EXIT_CODE}" == "${EXIT_SUCCESS}" ]]; then
exit "${EXIT_SUCCESS}"
fi

# There are a couple reasons execution reaches here:
#
# 1. The vendor platform reboot returned after scheduled the platform specific reboot.
Expand All @@ -268,9 +259,11 @@ if [ -x ${DEVPATH}/${PLATFORM}/${PLAT_REBOOT} ]; then
#
# As result if the reboot script reaches here. We should make the reboot happen.
# Sleep 1 second before calling /sbin/reboot to accommodate situation #1 above.
sleep 1
if [[ x"$ASIC_TYPE" != x"mellanox" ]]; then
sleep 1

VERBOSE=yes debug "Platform specific reboot failed!" >&2
VERBOSE=yes debug "Platform specific reboot failed!" >&2
fi
fi

VERBOSE=yes debug "Issuing OS-level reboot ..." >&2
Expand Down

0 comments on commit 6293229

Please sign in to comment.