2020-01-26 15:56:42 -06:00
|
|
|
#!/bin/bash
|
|
|
|
# This script is invoked by topology.service only
|
2021-02-19 00:02:29 -06:00
|
|
|
# for multi-asic virtual platform. For multi-asic platform
|
|
|
|
# multiple Database instances are present
|
2020-01-26 15:56:42 -06:00
|
|
|
# and HWKSU information is retrieved from first database instance.
|
|
|
|
#
|
|
|
|
|
2021-02-19 00:02:29 -06:00
|
|
|
get_hwsku() {
|
|
|
|
# Get HWSKU from config_db. If HWSKU is not available in config_db
|
|
|
|
# get HWSKU from minigraph.xml if minigraph file exists.
|
|
|
|
HWSKU=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]' 2>&1`
|
|
|
|
if [[ $? -ne 0 || $HWSKU == "" ]]; then
|
|
|
|
if [[ -f "/etc/sonic/minigraph.xml" ]]; then
|
|
|
|
HWSKU=`sonic-cfggen -m /etc/sonic/minigraph.xml -v "DEVICE_METADATA['localhost']['hwsku']" 2>&1`
|
|
|
|
if [[ $? -ne 0 || $HWSKU == "" ]]; then
|
|
|
|
HWSKU=""
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
HWSKU=""
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "${HWSKU}"
|
|
|
|
}
|
|
|
|
|
2020-01-26 15:56:42 -06:00
|
|
|
start() {
|
2020-03-31 12:06:19 -05:00
|
|
|
TOPOLOGY_SCRIPT="topology.sh"
|
2021-02-19 00:02:29 -06:00
|
|
|
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
|
|
|
|
HWSKU=`get_hwsku`
|
|
|
|
if [[ $HWSKU != "" ]]; then
|
|
|
|
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT start
|
|
|
|
else
|
|
|
|
echo "Failed to get HWSKU"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-01-26 15:56:42 -06:00
|
|
|
}
|
2021-02-19 00:02:29 -06:00
|
|
|
|
2020-01-26 15:56:42 -06:00
|
|
|
stop() {
|
2020-03-31 12:06:19 -05:00
|
|
|
TOPOLOGY_SCRIPT="topology.sh"
|
2021-02-19 00:02:29 -06:00
|
|
|
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`
|
|
|
|
HWSKU=`get_hwsku`
|
|
|
|
if [[ $HWSKU != "" ]]; then
|
|
|
|
/usr/share/sonic/device/$PLATFORM/$HWSKU/$TOPOLOGY_SCRIPT stop
|
|
|
|
else
|
|
|
|
echo "Failed to get HWSKU"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-01-26 15:56:42 -06:00
|
|
|
}
|
|
|
|
|
2020-07-31 19:59:09 -05:00
|
|
|
# read SONiC immutable variables
|
|
|
|
[ -f /etc/sonic/sonic-environment ] && . /etc/sonic/sonic-environment
|
|
|
|
|
2020-01-26 15:56:42 -06:00
|
|
|
case "$1" in
|
|
|
|
start|stop)
|
|
|
|
$1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop}"
|
|
|
|
;;
|
|
|
|
esac
|