From 1411bb94e34929dadc656db034d23add5e697390 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Wed, 1 Feb 2017 03:06:43 +0000 Subject: [PATCH] Add DHCP hook to set static hostname after getting from DHCP --- build_debian.sh | 3 ++- files/dhcp/hostname | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 files/dhcp/hostname diff --git a/build_debian.sh b/build_debian.sh index 11d8217ff8bf..88e60e4e648a 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -239,7 +239,8 @@ allow-hotplug eth0 iface eth0 inet dhcp EOF -sudo cp files/dhcp/rfc3442-classless-routes $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks.d +sudo cp files/dhcp/hostname $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks.d/ +sudo cp files/dhcp/rfc3442-classless-routes $FILESYSTEM_ROOT/etc/dhcp/dhclient-exit-hooks.d/ if [ -f sonic_debian_extension.sh ]; then ./sonic_debian_extension.sh $FILESYSTEM_ROOT diff --git a/files/dhcp/hostname b/files/dhcp/hostname new file mode 100644 index 000000000000..b8e924e4ceec --- /dev/null +++ b/files/dhcp/hostname @@ -0,0 +1,6 @@ +case $reason in + BOUND|RENEW|REBIND|REBOOT) + current_hostname=`hostname` + echo $current_hostname > /etc/hostname + ;; +esac