This repository has been archived on 2025-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
sonic-buildimage/files/image_config
Prabhu Sreenivasan f28a670097 [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-01-17 22:47:19 -08: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
asn [BGPD]: add bgp dynamic neighbor configuration (#708) 2017-06-21 18:52:50 -07:00
bash [baseimage]: enable auto logout for console (ttyS*) sessions (#1398) 2018-02-20 09:36:54 -08:00
caclmgrd Remove Arista-specific service ACL solution; All platforms now use caclmgrd (#2202) 2018-10-29 10:25:18 -07:00
cron.d [System logs]: Improvements to prevent filling /var/log partition (#865) 2017-08-10 16:24:57 -07:00
environment [image]: Update login message (#706) 2017-06-14 15:18:02 -07:00
hostcfgd tacacs management vrf changes (#2217) 2018-12-04 10:22:48 -08:00
hostname [baseimage]: Avoid removing localhost entry from /etc/hosts file (#2452) 2019-01-17 22:47:19 -08:00
interfaces [sonic boot] disable dhcp during boot up, until updategraph service is running (#2316) 2018-11-29 08:34:22 -08:00
logrotate Decrease usable space in log partition to 90% (#1648) 2018-04-30 11:18:56 -07:00
ntp [boot] Refactor: All services which start Docker containers start before ntp-config service (#2335) 2018-12-03 16:01:44 -08:00
platform [bde driver] black list linux_kernel_bde driver (#2284) 2018-11-21 08:08:37 -08:00
rsyslog [rsyslog]: use # to separate container name and program name in syslog message (#1918) 2018-08-12 22:23:58 -07:00
snmp Remove extra trailing newlines at EOF (#804) 2017-07-12 20:54:37 -07:00
sudoers [sudoers] Add 'SONIC_CLI_IFACE_MODE' to env_keep to ensure variable is made available to sudo calls (#2249) 2018-11-15 15:16:06 -08:00
systemd Remove extra trailing newlines at EOF (#804) 2017-07-12 20:54:37 -07:00
updategraph [update graph] adapt to warm reboot scenario (#2353) 2018-12-06 10:24:50 -08:00