2017-05-11 13:18:10 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-10-04 03:02:30 -05:00
|
|
|
set -e
|
|
|
|
|
2017-05-24 13:57:33 -05:00
|
|
|
function fast_reboot {
|
|
|
|
case "$(cat /proc/cmdline)" in
|
|
|
|
*fast-reboot*)
|
|
|
|
if [[ -f /fdb.json ]];
|
|
|
|
then
|
|
|
|
swssconfig /fdb.json
|
2020-06-20 17:30:53 -05:00
|
|
|
mv -f /fdb.json /fdb.json.1
|
2017-05-24 13:57:33 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -f /arp.json ]];
|
|
|
|
then
|
|
|
|
swssconfig /arp.json
|
2020-06-20 17:30:53 -05:00
|
|
|
mv -f /arp.json /arp.json.1
|
2017-05-24 13:57:33 -05:00
|
|
|
fi
|
2018-02-14 21:09:28 -06:00
|
|
|
|
|
|
|
if [[ -f /default_routes.json ]];
|
|
|
|
then
|
|
|
|
swssconfig /default_routes.json
|
2020-06-20 17:30:53 -05:00
|
|
|
mv -f /default_routes.json /default_routes.json.1
|
2018-02-14 21:09:28 -06:00
|
|
|
fi
|
|
|
|
|
2021-11-08 17:21:11 -06:00
|
|
|
if [[ -f /media_config.json ]];
|
|
|
|
then
|
|
|
|
swssconfig /media_config.json
|
|
|
|
mv -f /media_config.json /media_config.json.1
|
|
|
|
fi
|
|
|
|
|
2017-05-24 13:57:33 -05:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2018-02-26 13:23:29 -06:00
|
|
|
# Wait until swss.sh in the host system create file swss:/ready
|
|
|
|
until [[ -e /ready ]]; do
|
|
|
|
sleep 0.1;
|
|
|
|
done
|
|
|
|
|
|
|
|
rm -f /ready
|
|
|
|
|
2017-05-24 13:57:33 -05:00
|
|
|
# Restore FDB and ARP table ASAP
|
|
|
|
fast_reboot
|
|
|
|
|
2020-07-31 19:59:09 -05:00
|
|
|
# read SONiC immutable variables
|
|
|
|
[ -f /etc/sonic/sonic-environment ] && . /etc/sonic/sonic-environment
|
|
|
|
|
|
|
|
HWSKU=${HWSKU:-`sonic-cfggen -d -v "DEVICE_METADATA['localhost']['hwsku']"`}
|
2017-05-11 13:18:10 -05:00
|
|
|
|
2018-09-07 14:25:38 -05:00
|
|
|
# Don't load json config if system warm start or
|
|
|
|
# swss docker warm start is enabled, the data already exists in appDB.
|
2020-01-22 13:27:21 -06:00
|
|
|
SYSTEM_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
|
|
|
SWSS_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|swss" enable`
|
2018-09-07 14:25:38 -05:00
|
|
|
if [[ "$SYSTEM_WARM_START" == "true" ]] || [[ "$SWSS_WARM_START" == "true" ]]; then
|
2020-09-04 11:34:26 -05:00
|
|
|
exit 0
|
2018-09-07 14:25:38 -05:00
|
|
|
fi
|
|
|
|
|
2020-11-23 11:31:42 -06:00
|
|
|
SWSSCONFIG_ARGS="ipinip.json ports.json switch.json "
|
2017-05-11 13:18:10 -05:00
|
|
|
|
|
|
|
for file in $SWSSCONFIG_ARGS; do
|
|
|
|
swssconfig /etc/swss/config.d/$file
|
|
|
|
sleep 1
|
|
|
|
done
|