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
|
|
|
|
rm -f /fdb.json
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -f /arp.json ]];
|
|
|
|
then
|
|
|
|
swssconfig /arp.json
|
|
|
|
rm -f /arp.json
|
|
|
|
fi
|
2018-02-14 21:09:28 -06:00
|
|
|
|
|
|
|
if [[ -f /default_routes.json ]];
|
|
|
|
then
|
|
|
|
swssconfig /default_routes.json
|
|
|
|
rm -f /default_routes.json
|
|
|
|
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
|
|
|
|
|
2017-11-23 18:31:37 -06:00
|
|
|
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.
|
2019-02-14 14:12:55 -06:00
|
|
|
SYSTEM_WARM_START=`redis-cli -n 6 hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
|
|
|
SWSS_WARM_START=`redis-cli -n 6 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
|
|
|
|
# We have to make sure db data has not been flushed.
|
2018-10-02 08:08:26 -05:00
|
|
|
RESTORE_COUNT=`redis-cli -n 6 hget "WARM_RESTART_TABLE|orchagent" restore_count`
|
|
|
|
if [[ -n "$RESTORE_COUNT" ]] && [[ "$RESTORE_COUNT" != "0" ]]; then
|
2018-09-07 14:25:38 -05:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-11-02 17:09:27 -05:00
|
|
|
SWSSCONFIG_ARGS="00-copp.config.json 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
|