Skip to content

Commit

Permalink
[warm reboot] provide option to reboot with "kexec -e" (#406)
Browse files Browse the repository at this point in the history
* [warm reboot] provide option to reboot with "kexec -e"

Signed-off-by: Ying Xie <[email protected]>

* add the new options to parsing list
  • Loading branch information
yxieca authored Dec 11, 2018
1 parent 2a7c301 commit 28fd82e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ REBOOT_SCRIPT_NAME=$(basename $0)
REBOOT_TYPE="${REBOOT_SCRIPT_NAME}"
VERBOSE=no
FORCE=no
REBOOT_METHOD="/sbin/reboot"

# Check root privileges
if [[ "$EUID" -ne 0 ]]
Expand All @@ -31,13 +32,15 @@ function showHelpAndExit()
echo " -h -? : get this help"
echo " -v : turn on verbose"
echo " -f : force execution"
echo " -r : reboot with /sbin/reboot [default]"
echo " -k : reboot with /sbin/kexec -e"

exit 0
}

function parseOptions()
{
while getopts "vfh?" opt; do
while getopts "vfh?rk" opt; do
case ${opt} in
h )
showHelpAndExit
Expand All @@ -51,6 +54,12 @@ function parseOptions()
f )
FORCE=yes
;;
r )
REBOOT_METHOD="/sbin/reboot"
;;
k )
REBOOT_METHOD="/sbin/kexec -e"
;;
esac
done
}
Expand Down Expand Up @@ -371,10 +380,9 @@ sync
sleep 1
sync

debug "Rebooting ..."
# Reboot: explicity call Linux native reboot under sbin
echo "Rebooting to $NEXT_SONIC_IMAGE..."
exec /sbin/reboot
debug "Rebooting with ${REBOOT_METHOD} to ${NEXT_SONIC_IMAGE} ..."
exec ${REBOOT_METHOD}

# Should never reach here
echo "${REBOOT_TYPE} failed!" >&2
Expand Down

0 comments on commit 28fd82e

Please sign in to comment.