Don't update /etc/hosts if the hostname is not changed
Signed-off-by: saksarav <sakthivadivu.saravanaraj@nokia.com>
This commit is contained in:
parent
14f3f091d3
commit
12b5d67986
@ -11,7 +11,6 @@ Requires=opennsl-modules.service
|
||||
{% endif %}
|
||||
Requires=updategraph.service
|
||||
After=updategraph.service
|
||||
After=hostname-config.service
|
||||
BindsTo=sonic.target
|
||||
After=sonic.target
|
||||
Before=ntp-config.service
|
||||
|
@ -11,10 +11,16 @@ fi
|
||||
echo $HOSTNAME > /etc/hostname
|
||||
hostname -F /etc/hostname
|
||||
|
||||
#Don't update the /etc/hosts if hostname is not changed
|
||||
#This is to prevent intermittent redis_chassis.server reachability issue
|
||||
if [ $CURRENT_HOSTNAME == $HOSTNAME ] ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Remove the old hostname entry from hosts file.
|
||||
# But, 'localhost' entry is used by multiple applications. Don't remove it altogether.
|
||||
# Edit contents of /etc/hosts and put in /etc/hosts.new
|
||||
if [ $CURRENT_HOSTNAME != "localhost" ] || [ $CURRENT_HOSTNAME == $HOSTNAME ] ; then
|
||||
if [ $CURRENT_HOSTNAME != "localhost" ] ; then
|
||||
sed "/\s$CURRENT_HOSTNAME$/d" /etc/hosts > /etc/hosts.new
|
||||
else
|
||||
cp -f /etc/hosts /etc/hosts.new
|
||||
|
Loading…
Reference in New Issue
Block a user