integ/base/dhcp/centos/patches/dhclient-ipv6-conditionally-set-hostname.patch
Long Li b2c483a806 CentOS 8: Upgrade dhcp to version 4.3.6
(1)Release Version Upgrade
(2)Matching code changes with el7 to el8

Set hostname based on ipv6 lease if not set

Story: 2006729
Task: 37684
Depends-On: https://review.opendev.org/#/c/696481/
Depends-On: https://review.opendev.org/#/c/696050/
Change-Id: Iba34ddd1cfcdbdcfc152a9b88227c72f398b3b1b
Signed-off-by: Long Li <lilong-neu@neusoft.com>
2019-12-18 11:30:28 +00:00

47 lines
1.6 KiB
Diff

From 04e5bef0d9bb0e1b3c8bbecccf11228ae809dfd2 Mon Sep 17 00:00:00 2001
From: Scott Little <scott.little@windriver.com>
Date: Mon, 2 Oct 2017 15:25:21 -0400
Subject: dhclient-ipv6-conditionally-set-hostname.patch
---
client/scripts/linux | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/client/scripts/linux b/client/scripts/linux
index 5fb1612..061e00c 100755
--- a/client/scripts/linux
+++ b/client/scripts/linux
@@ -398,11 +398,24 @@ case "$reason" in
;;
- BOUND6|RENEW6|REBIND6)
- if [ "${new_ip6_address}" ] && [ "${new_ip6_prefixlen}" ]; then
- # set leased IP
- ${ip} -6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
- dev ${interface} scope global
+ BOUND6|RENEW6|REBIND6|REBOOT6)
+ current_hostname=$(hostname)
+ if [ -z "${current_hostname}" ] || \
+ [ "$current_hostname" = '(none)' ] || \
+ [ "$current_hostname" = 'localhost' ] || \
+ [ "$current_hostname" = "$old_fqdn_hostname" ]; then
+ if [ "$new_fqdn_hostname" != "$old_fqdn_hostname" ]; then
+ hostname "$new_fqdn_hostname"
+ fi
+ fi
+
+ # set leased IP
+ if [ "${reason}" = BOUND6 ] ||
+ [ "${reason}" = RENEW6 ] || [ "${reason}" = REBIND6 ]; then
+ if [ "${new_ip6_address}" ] && [ "${new_ip6_prefixlen}" ]; then
+ ${ip} -6 addr add ${new_ip6_address}/${new_ip6_prefixlen} \
+ dev ${interface} scope global
+ fi
fi
# update /etc/resolv.conf
--
2.7.4