Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/bash

REBOOT_USER=$(logname)
REBOOT_TIME=$(date)
REBOOT_CAUSE_FILE="/var/cache/sonic/reboot-cause.txt"

# Check root privileges
if [[ "$EUID" -ne 0 ]]
then
echo "Please run as root"
echo "This command must be run as root" >&2
exit
fi

Expand Down Expand Up @@ -50,7 +54,7 @@ docker kill lldp > /dev/null
# Kill teamd, otherwise it gets down all LAGs
docker kill teamd > /dev/null

# syncd graceful stop is supported only for Broadcoms platforms only for now
# syncd graceful stop is supported only for Broadcom platforms only for now
if [[ "$sonic_asic_type" = 'broadcom' ]];
then
# Gracefully stop syncd
Expand Down Expand Up @@ -82,11 +86,20 @@ then
systemctl stop nps-modules-`uname -r`.service
fi

# Update the reboot cause file to reflect that user issued 'fast-reboot' command
# Upon next boot, the contents of this file will be used to determine the
# cause of the previous reboot
echo "User issued 'fast-reboot' command [User: ${REBOOT_USER}, Time: ${REBOOT_TIME}]" > ${REBOOT_CAUSE_FILE}

# Wait until all buffers synced with disk
sync
sleep 1
sync

# Reboot: explicity call Linux native reboot under sbin
echo "Rebooting to $NEXT_SONIC_IMAGE..."
/sbin/reboot
exec /sbin/reboot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure for this exec. Did you test it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I made the same change recently in the scripts/reboot script and tested that thoroughly.


# Should never reach here
echo "fast-reboot failed!" >&2
exit 1