1
1
#! /bin/bash
2
2
3
+ DEVICE_MGR_REBOOT_FILE=/tmp/device_mgr_reboot
4
+ REBOOT_CAUSE_FILE=/host/reboot-cause/reboot-cause.txt
5
+ DEVICE_REBOOT_CAUSE_FILE=/etc/opt/srlinux/reboot-cause.txt
6
+ kHeartbeatLostRebootCause=" Heartbeat with the Supervisor card lost"
7
+ DEVICE_DETAILS_FILE=" /etc/opt/srlinux/devices/hw_details.json"
8
+
9
+ ungraceful_reboot_handle ()
10
+ {
11
+ str=$( grep " $kHeartbeatLostRebootCause " $DEVICE_REBOOT_CAUSE_FILE 2> /dev/null)
12
+ status=$?
13
+ if [ $status -eq 0 ]; then
14
+ slot_num=$( jq -r ' .slot_num' $DEVICE_DETAILS_FILE 2> /dev/null)
15
+ slot_num=$(( slot_num - 1 ))
16
+ sonic-db-cli CHASSIS_STATE_DB del " CHASSIS_MODULE_REBOOT_INFO_TABLE|LINE-CARD${slot_num} "
17
+ fi
18
+ }
3
19
update_reboot_cause ()
4
20
{
5
- DEVICE_MGR_REBOOT_FILE=/tmp/device_mgr_reboot
6
- REBOOT_CAUSE_FILE=/host/reboot-cause/reboot-cause.txt
7
- DEVICE_REBOOT_CAUSE_FILE=/etc/opt/srlinux/reboot-cause.txt
8
21
if [ -e $DEVICE_MGR_REBOOT_FILE ]; then
9
22
if [ -e $DEVICE_REBOOT_CAUSE_FILE ]; then
23
+ # reomve the REBOOT_INFO_TABLE entry for unpexected reboot
24
+ ungraceful_reboot_handle
10
25
cp -f $DEVICE_REBOOT_CAUSE_FILE $REBOOT_CAUSE_FILE
11
26
fi
12
27
rm -f $DEVICE_MGR_REBOOT_FILE
@@ -18,7 +33,7 @@ update_reboot_cause()
18
33
}
19
34
20
35
echo " Disable all SFPs"
21
- python3 -c ' import sonic_platform.platform; platform_chassis = sonic_platform.platform.Platform().get_chassis(); platform_chassis.tx_disable_all_sfps()'
36
+ python3 -c ' import sonic_platform.platform; platform_chassis = sonic_platform.platform.Platform().get_chassis(); platform_chassis.tx_disable_all_sfps()' &
22
37
sleep 3
23
38
24
39
# update the reboot_cuase file when reboot is trigger by device-mgr
0 commit comments