From c64d423fec2ab1e0aedd07591e9b4d0473ec3147 Mon Sep 17 00:00:00 2001 From: Marian Pritsak Date: Wed, 8 Nov 2017 18:50:22 +0200 Subject: [PATCH] [rc.local]: Fix init_cfg.json (#1129) If device MAC is added to init_cfg.json, it has to be done using intermediate file. We cannot redirect to same file while trying to read from it because it will be truncated first. Signed-off-by: marian-pritsak --- files/image_config/platform/rc.local | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/files/image_config/platform/rc.local b/files/image_config/platform/rc.local index daeccfd524..f4dd9cb3ad 100755 --- a/files/image_config/platform/rc.local +++ b/files/image_config/platform/rc.local @@ -91,7 +91,8 @@ if [ -f /host/image-$sonic_version/platform/firsttime ]; then fi if [ -f /etc/sonic/init_cfg.json ]; then - sonic-cfggen -j /etc/sonic/init_cfg.json -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'"}}}' --print-data > /etc/sonic/init_cfg.json + sonic-cfggen -j /etc/sonic/init_cfg.json -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'"}}}' --print-data > /tmp/init_cfg.json + mv /tmp/init_cfg.json /etc/sonic/init_cfg.json else sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'"}}}' --print-data > /etc/sonic/init_cfg.json fi