Skip to content

Commit 26c3709

Browse files
authored
[reboot] While rebooting device, execute platform specific reboot tool when available (#188)
* [fast-reboot] Explicitly call Linux native reboot tool * [reboot tool] Reboot device with platform specific tool when available /usr/bin is in front of /sbin in search path. Adding reboot script here will get executed when reboot was called without absolute path. This script will call platform specific reboot tool (name: platform_reboot under device folder) when available. Otherwise, dispatch to native Linux reboot. * [reboot] call sync before calling platform specific reboot tool The platform specific reboot tool could be power cycling. * [reboot] sleep 3 seconds after sync-ing * [reboot] also stop snmp service
1 parent c6bcfa6 commit 26c3709

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

scripts/fast-reboot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ sync
5959
sleep 1
6060
sync
6161

62-
# Reboot
62+
# Reboot: explicity call Linux native reboot under sbin
6363
echo "Rebooting to $NEXT_SONIC_IMAGE..."
64-
reboot
64+
/sbin/reboot

scripts/reboot

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#! /bin/bash
2+
3+
function stop_sonic_services()
4+
{
5+
echo "Stopping sonic services..."
6+
systemctl stop swss
7+
systemctl stop teamd
8+
systemctl stop bgp
9+
systemctl stop lldp
10+
systemctl stop snmp
11+
}
12+
13+
# Obtain our platform as we will mount directories with these names in each docker
14+
PLATFORM=`sonic-cfggen -v platform`
15+
16+
DEVPATH="/usr/share/sonic/device"
17+
REBOOT="platform_reboot"
18+
19+
if [ -x ${DEVPATH}/${PLATFORM}/${REBOOT} ]; then
20+
stop_sonic_services
21+
sync
22+
sleep 3
23+
echo "Rebooting with platform ${PLATFORM} specific tool ..."
24+
${DEVPATH}/${PLATFORM}/${REBOOT}
25+
exit 0
26+
fi
27+
28+
/sbin/reboot $@

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def get_test_suite():
4949
'scripts/port2alias',
5050
'scripts/portconfig',
5151
'scripts/portstat',
52+
'scripts/reboot',
5253
'scripts/teamshow'
5354
],
5455
data_files=[

0 commit comments

Comments
 (0)