From 59ed6f399de8af29fa6f3ffb50e07d23f215feff Mon Sep 17 00:00:00 2001 From: Santhosh Kumar T <53558409+santhosh-kt@users.noreply.github.com> Date: Fri, 23 Apr 2021 00:03:39 +0530 Subject: [PATCH] platform pre-check for reboot in master branch (#1556) What I did Added platform pre check support in reboot script. Checking platform based changes before stopping dockers and sonic services. Porting changes in master from 201911 branch #1472 How I did it On branch reboot_pre_check_master Changes not staged for commit: (use "git add ..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: scripts/reboot How to verify it Write a platform pre check script(platform_reboot_pre_check) and place it in /usr/share/sonic/device// directory. If the script exit with status 0, reboot will be proceeded. If script exit with non-zero status, the reboot script gets stopped. --- scripts/reboot | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/reboot b/scripts/reboot index 546aa0fbff8b..dfbd309ba8f9 100755 --- a/scripts/reboot +++ b/scripts/reboot @@ -3,6 +3,7 @@ DEVPATH="/usr/share/sonic/device" PLAT_REBOOT="platform_reboot" PLATFORM_UPDATE_REBOOT_CAUSE="platform_update_reboot_cause" REBOOT_CAUSE_FILE="/host/reboot-cause/reboot-cause.txt" +PLATFORM_REBOOT_PRE_CHECK="platform_reboot_pre_check" REBOOT_TIME=$(date) # Reboot immediately if we run the kdump capture kernel @@ -121,6 +122,11 @@ function reboot_pre_check() fi rm ${filename} + if [ -x ${DEVPATH}/${PLATFORM}/${PLATFORM_REBOOT_PRE_CHECK} ]; then + ${DEVPATH}/${PLATFORM}/${PLATFORM_REBOOT_PRE_CHECK} + [[ $? -ne 0 ]] && exit $? + fi + # Verify the next image by sonic-installer local message=$(sonic-installer verify-next-image 2>&1) if [ $? -ne 0 ]; then