sonic-buildimage/files
Prabhu Sreenivasan ff137a8e56 [baseimage]: Avoid removing localhost entry from /etc/hosts file (#2452)
- What I did
This fix removes the possibility of 'localhost' entry getting removed from /etc/hosts file by hostname-config service.

Without this change, whenever we change the hostname from 'localhost' to any other name on the config_db.json and reload the config, /etc/hosts file will only have the new hostname on it. But there are multiple sonic utilities (eg: swssconfig) which relies on the hard coded 'localhost' name and they tend to stop working.

- How I did it
Added a new check on hostname-config.sh script to avid blindly deleting the line containing the old hostname from /etc/hosts file. Now it will delete the old hostname only if its not localhost or when the hostname is not changing.

- How to verify it

Bring up SONiC on a device with hostname as localhost
Edit /etc/sonic/config_db.json to update the 'hostname' filed under DEVICE_METADATA from "hostname" : "localhost" --> "hostname" : "sonic"
run config reload -y to reflect the hostname change done on config_db.json file.
cat /etc/hosts and check whether both 127.0.0.1 localhost and 127.0.0.1 sonic entry are present on the file.
ping localhost should work fine.
- Description for the changelog
Make hostname-config service more robust in handling SONiC hostname change from localhost to anything else.
2019-10-29 15:42:04 +00:00
..
Aboot [build]: enable docker in ram option for small disk device (#3279) 2019-08-07 06:07:46 +00:00
apt [baseimage]: Download picocom version 3.1-2 from stretch-backports; No longer build from source (#1946) 2018-08-17 17:38:20 -07:00
build_scripts [build_debian] Include checksum of ASIC config files in SONiC filesystem (#3384) 2019-09-09 18:53:15 +00:00
build_templates [mellanox]: Add CPLD update for SN2700 (#3570) 2019-10-09 17:36:45 -07:00
dhcp [updategraph] Use empty configuration when DHCP graphurl option is missing (#2185) 2018-10-29 12:16:00 -07:00
docker [docker-engine]: upgrade docker engine to 18.09 (#2417) 2019-01-04 20:47:43 -08:00
image_config [baseimage]: Avoid removing localhost entry from /etc/hosts file (#2452) 2019-10-29 15:42:04 +00:00
initramfs-tools [build]: enable docker in ram option for small disk device (#3279) 2019-08-07 06:07:46 +00:00
scripts [cron.d] Add cron job to periodically clean-up core files (#3449) 2019-09-13 17:52:10 +00:00
sshd [security] Do not generate ssh server keys for non RSA protocols (#2718) 2019-03-29 22:37:47 +00:00