sonic-buildimage/files/image_config/platform/rc.local
Taoyu Li a2fe0212be [ConfigDB] Move all BGP configuration into DB (#861)
- BGP data read from minigraph.py now match DB schema
- BGP templates are updated
- bgpcfgd can now deal with runtime neighbor create/delete
2017-08-08 16:23:58 -07:00

62 lines
2.0 KiB
Bash
Executable File

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
. /host/machine.conf
echo "install platform dependent packages at the first boot time"
sonic_version=$(cat /etc/sonic/sonic_version.yml | grep build_version | cut -f2 -d" ")
if [ -f /host/image-$sonic_version/platform/firsttime ]; then
if [ -n "$aboot_platform" ]; then
platform=$aboot_platform
elif [ -n "$onie_platform" ]; then
platform=$onie_platform
else
echo "Unknown sonic platform"
rm /host/image-$sonic_version/platform/firsttime
exit 0
fi
# Try to take old configuration saved during installation
if [ -d /host/old_config ]; then
rm -f /host/old_config/sonic_version.yml
mv -f /host/old_config/* /etc/sonic/
elif [ -f /host/minigraph.xml ]; then
mv /host/minigraph.xml /etc/sonic/
# Combine information in minigraph and init_cfg.json to form initiate config DB dump file.
# TODO: After moving all information from minigraph to DB, sample config DB dump should be provide
if [ -f /etc/sonic/init_cfg.json ]; then
sonic-cfggen -m -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json
else
sonic-cfggen -m --print-data > /etc/sonic/config_db.json
fi
else
cp /usr/share/sonic/device/$platform/minigraph.xml /etc/sonic/
if [ -f /etc/sonic/init_cfg.json ]; then
sonic-cfggen -m -j /etc/sonic/init_cfg.json --print-data > /etc/sonic/config_db.json
else
sonic-cfggen -m --print-data > /etc/sonic/config_db.json
fi
fi
if [ -d /host/image-$sonic_version/platform/$platform ]; then
dpkg -i /host/image-$sonic_version/platform/$platform/*.deb
fi
rm /host/image-$sonic_version/platform/firsttime
fi
exit 0