aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/network-functions
diff options
context:
space:
mode:
authorDavid Kaspar [Dee'Kej] <dkaspar@redhat.com>2017-05-02 23:17:19 +0200
committerDee'Kej <deekej@linuxmail.org>2017-05-03 10:59:51 +0200
commitcb7a84e8106398cd021237f41e7dd1e1e503c286 (patch)
treeee2407b7b0253f4e8c2807848244693b568a0125 /sysconfig/network-scripts/network-functions
parent4f8720706228d316e57ed95c3676e3478eb380fc (diff)
downloadinitscripts-cb7a84e8106398cd021237f41e7dd1e1e503c286.tar
initscripts-cb7a84e8106398cd021237f41e7dd1e1e503c286.tar.gz
initscripts-cb7a84e8106398cd021237f41e7dd1e1e503c286.tar.bz2
initscripts-cb7a84e8106398cd021237f41e7dd1e1e503c286.tar.xz
initscripts-cb7a84e8106398cd021237f41e7dd1e1e503c286.zip
DHCP_FQDN and DHCP_SEND_HOSTNAME introduced
The way DHCP_HOSTNAME is being sent to DHCP server has been completely reworked... DHCP_FQDN now allows user to specify fully qualified domain name to be sent to DHCP server instead of just using simple hostname. This option takes precedence before DHCP_HOSTNAME variable. DHCP_SEND_HOSTNAME can be used to tell initscripts to not send either DHCP_HOSTNAME or DHCP_FQDN to DHCP server. Both of these options should behave same as they do in NetworkManager.
Diffstat (limited to 'sysconfig/network-scripts/network-functions')
-rw-r--r--sysconfig/network-scripts/network-functions32
1 files changed, 32 insertions, 0 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index 850cc3ff..1867c38a 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -397,6 +397,38 @@ need_hostname ()
fi
}
+set_hostname_options ()
+{
+ # User explicitly requires to *not* send DHCP_HOSTNAME, DHCP_FQDN or HOSTNAME:
+ is_false "${DHCP_SEND_HOSTNAME}" && return
+
+ if [[ -n "${DHCP_HOSTNAME}" && -n "${DHCP_FQDN}" ]]; then
+ net_log $"Both 'DHCP_HOSTNAME=${DHCP_HOSTNAME}' and 'DHCP_FQDN=${DHCP_FQDN}' are configured... Using DHCP_FQDN." warning
+ fi
+
+ local hostname_options=''
+
+ # DHCP_FQDN takes precedence before DHCP_HOSTNAME -- as it does in NetworkManager,
+ # and DHCP_HOSTNAME takes precedence before HOSTNAME:
+ if [[ -n "${DHCP_FQDN}" ]]; then
+ hostname_options="-F ${DHCP_FQDN}"
+ elif [[ -n "${DHCP_HOSTNAME}" ]]; then
+ hostname_options="-H ${DHCP_HOSTNAME}"
+ elif is_hostname_set; then
+ # We need to truncate the hostname in case it is the FQDN:
+ hostname_options="-H ${HOSTNAME%%.*}"
+ else
+ # Nothing to send to the DHCP server:
+ # ['(none)', 'localhost' or 'localhost.localdomain' are not valid]
+ return
+ fi
+
+ # Append the hostname options to the content of passed variable name:
+ eval "$1='${!1} ${hostname_options}'"
+
+ return
+}
+
set_hostname ()
{
hostname $1