Skip to content

Commit

Permalink
[fast-reboot] Update reboot reason file to indicate fast-reboot was c…
Browse files Browse the repository at this point in the history
…alled (sonic-net#277)
  • Loading branch information
jleveque committed Jun 30, 2018
1 parent ff1faa4 commit 9c4c362
Showing 1 changed file with 16 additions and 3 deletions.
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

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

0 comments on commit 9c4c362

Please sign in to comment.