From c4501062911a483c393905a8864c989b49a81952 Mon Sep 17 00:00:00 2001 From: Stepan Blyschak Date: Thu, 26 Sep 2019 12:49:24 +0000 Subject: [PATCH] [docker_image_ctl.j2] skip hostname update if is up to date Signed-off-by: Stepan Blyschak --- files/build_templates/docker_image_ctl.j2 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 718730f813ef..8bf0f2c6d4b0 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -119,7 +119,7 @@ function postStartAction() v3SnmpTrapIp=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v3TrapDest" DestIp` v3SnmpTrapPort=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v3TrapDest" DestPort` v3MgmtVrf=`/usr/bin/redis-cli -n 4 hget "SNMP_TRAP_CONFIG|v3TrapDest" vrf` - + if [ "${v1SnmpTrapIp}" != "" ] then sed -i "s/v1_trap_dest:.*/v1_trap_dest: ${v1SnmpTrapIp}:${v1SnmpTrapPort}%${v1MgmtVrf}/" "/etc/sonic/snmp.yml" @@ -185,7 +185,10 @@ start() { {%- endif %} preStartAction docker start {{docker_container_name}} - updateHostName "$HOSTNAME" + CURRENT_HOSTNAME="$(docker exec {{docker_container_name}} hostname)" + if [ x"$HOSTNAME" != x"$CURRENT_HOSTNAME" ]; then + updateHostName "$HOSTNAME" + fi postStartAction exit $? fi