Skip to content

Commit

Permalink
Resolve PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
taoyl-ms committed Mar 9, 2018
1 parent c03a6b9 commit c8aba9a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions files/image_config/updategraph/updategraph
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#!/bin/bash

CONFIG_DB_INDEX=4

reload_minigraph()
{
echo "Reloading minigraph..."
if [ ! -f /etc/sonic/init_cfg.json ]; then
echo "{}" > /etc/sonic/init_cfg.json
fi
redis-cli -n 4 FLUSHDB
redis-cli -n $CONFIG_DB_INDEX FLUSHDB
sonic-cfggen -H -m -j /etc/sonic/init_cfg.json --write-to-db
redis-cli -n 4 SET "CONFIG_DB_INITIALIZED" "1"
redis-cli -n $CONFIG_DB_INDEX SET "CONFIG_DB_INITIALIZED" "1"
if [ -f /etc/sonic/acl.json ]; then
acl-loader update full /etc/sonic/acl.json
fi
Expand Down Expand Up @@ -38,7 +40,7 @@ fi

. /etc/sonic/updategraph.conf

if [ -f /tmp/firstboot ]; then
if [ -f /tmp/migration ]; then
if [ "$enabled" = "true" ]; then
echo "Use minigraph.xml from old system..."
cp /etc/sonic/old_config/minigraph.xml /etc/sonic/
Expand All @@ -52,17 +54,17 @@ if [ -f /tmp/firstboot ]; then
cp /etc/sonic/old_config/acl.json /etc/sonic/
fi
reload_minigraph
sonic-cfggen -d --print_data > /etc/sonic/config_db.json
sonic-cfggen -d --print-data > /etc/sonic/config_db.json
elif [ -f /etc/sonic/old_config/config_db.json ]; then
echo "Use config_db.json from old system..."
cp /etc/sonic/old_config/config_db.json /etc/sonic/
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
else
copy_default_minigraph
reload_minigraph
sonic-cfggen -d --print_data > /etc/sonic/config_db.json
sonic-cfggen -d --print-data > /etc/sonic/config_db.json
fi
rm -f /tmp/firstboot
rm -f /tmp/migration
sed -i "/enabled=/d" /etc/sonic/updategraph.conf
echo "enabled=false" >> /etc/sonic/updategraph.conf
exit 0
Expand Down Expand Up @@ -106,9 +108,9 @@ if [ "$src" = "dhcp" ]; then
else
cp -f /tmp/device_meta.json /etc/sonic/config_db.json
fi
redis-cli -n 4 FLUSHDB
redis-cli -n $CONFIG_DB_INDEX FLUSHDB
sonic-cfggen -j /etc/sonic/config_db.json --write-to-db
redis-cli -n 4 SET "CONFIG_DB_INITIALIZED" "1"
redis-cli -n $CONFIG_DB_INDEX 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
Expand Down Expand Up @@ -172,7 +174,7 @@ else
fi

reload_minigraph
sonic-cfggen -d --print_data > /etc/sonic/config_db.json
sonic-cfggen -d --print-data > /etc/sonic/config_db.json

# Mark as disabled after graph is successfully downloaded
sed -i "/enabled=/d" /etc/sonic/updategraph.conf
Expand Down

0 comments on commit c8aba9a

Please sign in to comment.