Skip to content

Commit

Permalink
[reboot] While rebooting device, execute platform specific reboot too…
Browse files Browse the repository at this point in the history
…l 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
  • Loading branch information
yxieca authored Jan 18, 2018
1 parent c6bcfa6 commit 26c3709
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/fast-reboot
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ sync
sleep 1
sync

# Reboot
# Reboot: explicity call Linux native reboot under sbin
echo "Rebooting to $NEXT_SONIC_IMAGE..."
reboot
/sbin/reboot
28 changes: 28 additions & 0 deletions scripts/reboot
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! /bin/bash

function stop_sonic_services()
{
echo "Stopping sonic services..."
systemctl stop swss
systemctl stop teamd
systemctl stop bgp
systemctl stop lldp
systemctl stop snmp
}

# Obtain our platform as we will mount directories with these names in each docker
PLATFORM=`sonic-cfggen -v platform`

DEVPATH="/usr/share/sonic/device"
REBOOT="platform_reboot"

if [ -x ${DEVPATH}/${PLATFORM}/${REBOOT} ]; then
stop_sonic_services
sync
sleep 3
echo "Rebooting with platform ${PLATFORM} specific tool ..."
${DEVPATH}/${PLATFORM}/${REBOOT}
exit 0
fi

/sbin/reboot $@
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def get_test_suite():
'scripts/port2alias',
'scripts/portconfig',
'scripts/portstat',
'scripts/reboot',
'scripts/teamshow'
],
data_files=[
Expand Down

0 comments on commit 26c3709

Please sign in to comment.