sonic-buildimage/files/image_config/updategraph/updategraph
jingwenxie fdc65d7600
Remove minigraph loading in updategraph script (#11146)
Why I did it
Minigraph will be deprecated in the future. So minigraph related reload should be deleted.

How I did it
Remove unused load_minigraph
2022-06-21 08:57:57 +08:00

52 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# read SONiC immutable variables
[ -f /etc/sonic/sonic-environment ] && . /etc/sonic/sonic-environment
if [ ! -f /etc/sonic/updategraph.conf ]; then
echo "No updategraph.conf found, generating a default one."
echo "enabled=false" >/etc/sonic/updategraph.conf
fi
. /etc/sonic/updategraph.conf
if [ "$enabled" = "reload_only" ]; then
echo "reload_only will not be supported in file updategraph.conf"
exit 1
fi
if [ "$enabled" != "true" ]; then
echo "Disabled in updategraph.conf. Skipping graph update."
exit 0
fi
# If ZTP package is available and enabled, use ZTP to download and load the graph.
if [ -e /usr/bin/ztp ] && [ "$(ztp status -c)" != "0:DISABLED" ]; then
echo "ZTP is available and enabled. Skipping graph update."
exit 0
fi
# "`cat /tmp/dhcp_graph_url`" is always "N/A"
echo "No graph_url option in DHCP response. Skipping graph update and generating an empty configuration."
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
if [ -f /etc/sonic/minigraph.xml ]; then
sonic-cfggen -H -m /etc/sonic/minigraph.xml --preset empty > /tmp/device_meta.json
else
PRESET=(`head -n 1 /usr/share/sonic/device/$PLATFORM/default_sku`)
sonic-cfggen -H -k ${PRESET[0]} --preset empty > /tmp/device_meta.json
fi
if [ -f /etc/sonic/init_cfg.json ]; then
sonic-cfggen -j /tmp/device_meta.json -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json
else
cp -f /tmp/device_meta.json /etc/sonic/config_db.json
fi
sonic-db-cli CONFIG_DB FLUSHDB
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
if [ "$dhcp_as_static" = "true" ]; then
sed -i "/enabled=/d" /etc/sonic/updategraph.conf
echo "enabled=false" >> /etc/sonic/updategraph.conf
fi
exit 0