Fix to improve hostname handling (#12064)
* Fix to improve hostname handling If config_db.json is missing hostname entry, hostname-config.sh ends up deleting existing entry too and hostname changes to default 'localhost' * default hostname to 'sonic` if missing in config file
This commit is contained in:
parent
e9737814f8
commit
fa609b80f1
@ -3,6 +3,11 @@
|
|||||||
CURRENT_HOSTNAME=`hostname`
|
CURRENT_HOSTNAME=`hostname`
|
||||||
HOSTNAME=`sonic-cfggen -d -v DEVICE_METADATA[\'localhost\'][\'hostname\']`
|
HOSTNAME=`sonic-cfggen -d -v DEVICE_METADATA[\'localhost\'][\'hostname\']`
|
||||||
|
|
||||||
|
if [ -z "$HOSTNAME" ] ; then
|
||||||
|
echo "Missing hostname in the config file, setting to default 'sonic'"
|
||||||
|
HOSTNAME='sonic'
|
||||||
|
fi
|
||||||
|
|
||||||
echo $HOSTNAME > /etc/hostname
|
echo $HOSTNAME > /etc/hostname
|
||||||
hostname -F /etc/hostname
|
hostname -F /etc/hostname
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user