From f63748cd80a7250d0f6b03e00fdf1af9c7b321b3 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 27 Aug 2019 14:07:35 +0200 Subject: [slx-network] no domain for forced hostname --- .../slx-network/scripts/udhcpc-trigger.stage3 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage3 b/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage3 index ee870873..d54939a8 100755 --- a/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage3 +++ b/builder/modules.d/slx-network/scripts/udhcpc-trigger.stage3 @@ -105,19 +105,19 @@ if [ -n "$ntpsrv" ]; then fi # Hostname -# Ignore it if hostname was forced per KCL +# Ignore hostname/fqdn it if hostname was forced per KCL. if [ -n "$SLX_PXE_HOSTNAME" ]; then echo "Hostname set via KCL, ignoring DHCP hostname: '$hostname'" hostname="$SLX_PXE_HOSTNAME" -fi - -if [ -z "$hostname" ]; then - # as with domain, if there's no hostname, try to get via DNS - echo "..trying to get hostname via DNS, as DHCP didn't supply one.." - [ -z "$fqdn" ] && fqdn=$(timeout -t 3 nslookup "$ip" | grep -E "^Address +[0-9]+: +$ip " | head -n 1 | awk '{print $4}') - hostname="${fqdn%%.*}" -elif [ -n "$domain" ]; then - fqdn="${hostname}.${domain%% *}" # in case domain is a list +else + if [ -z "$hostname" ]; then + # as with domain, if there's no hostname, try to get via DNS + echo "..trying to get hostname via DNS, as DHCP didn't supply one.." + [ -z "$fqdn" ] && fqdn=$(timeout -t 3 nslookup "$ip" | grep -E "^Address +[0-9]+: +$ip " | head -n 1 | awk '{print $4}') + hostname="${fqdn%%.*}" + elif [ -n "$domain" ]; then + fqdn="${hostname}.${domain%% *}" # in case domain is a list + fi fi if [ -z "$hostname" ]; then -- cgit v1.2.3-55-g7522