[reboot cause] Move reboot-cause files to /host directory so they persist across SONiC upgrades (#2490)

* [reboot cause] Move reboot-cause files to /host directory so they persist across SONiC upgrades

* [sonic-utilities] Update submodule to include related changes
This commit is contained in:
Joe LeVeque 2019-01-29 03:42:19 -08:00 committed by lguohan
parent 8f43cad061
commit 39b60d2a50
2 changed files with 17 additions and 10 deletions

View File

@ -106,24 +106,31 @@ value_extract() {
done
}
# Set up previous and next reboot cause files
# Set up previous and next reboot cause files accordingly
process_reboot_cause() {
REBOOT_CAUSE_FILE="/var/cache/sonic/reboot-cause.txt"
PREVIOUS_REBOOT_CAUSE_FILE="/var/cache/sonic/previous-reboot-cause.txt"
REBOOT_CAUSE_DIR="/host/reboot-cause"
REBOOT_CAUSE_FILE="${REBOOT_CAUSE_DIR}/reboot-cause.txt"
PREVIOUS_REBOOT_CAUSE_FILE="${REBOOT_CAUSE_DIR}/previous-reboot-cause.txt"
# Set the previous reboot cause accordingly
# If this is the first boot after an image install, state that as the
# cause. Otherwise, move REBOOT_CAUSE_FILE to PREVIOUS_REBOOT_CAUSE_FILE.
# REBOOT_CAUSE_FILE should always exist, but we add the else case
# to ensure we always generate PREVIOUS_REBOOT_CAUSE_FILE here
mkdir -p $REBOOT_CAUSE_DIR
# If this is the first boot after an image install, store that as the
# previous reboot cause.
if [ -f $FIRST_BOOT_FILE ]; then
echo "SONiC image installation" > $PREVIOUS_REBOOT_CAUSE_FILE
elif [ -f $REBOOT_CAUSE_FILE ]; then
fi
# If there is an existing REBOOT_CAUSE_FILE, copy that file to
# PREVIOUS_REBOOT_CAUSE_FILE.
if [ -f $REBOOT_CAUSE_FILE ]; then
mv -f $REBOOT_CAUSE_FILE $PREVIOUS_REBOOT_CAUSE_FILE
else
echo "Unknown reboot cause" > $PREVIOUS_REBOOT_CAUSE_FILE
fi
# Log the previous reboot cause to the syslog
logger "Previous reboot cause: $(cat $PREVIOUS_REBOOT_CAUSE_FILE)"
# Set the default cause for the next reboot
echo "Unexpected reboot" > $REBOOT_CAUSE_FILE
}

@ -1 +1 @@
Subproject commit 3ce8952ca43c2d5015ae90b13aa8a4644bab4c19
Subproject commit 97ac8c7cbd3284c3a1c3443bb2156309f8fc65ea