From 3f70bd05d0fc22d417b73c2a8767b15bf9622bec Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 3 Aug 2020 18:01:56 +0200 Subject: [rfs-stage31] Fix hostname lookup for newer busybox nslookup --- core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'core/rootfs') diff --git a/core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger b/core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger index cc7454e7..5ec15a74 100755 --- a/core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger +++ b/core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger @@ -73,7 +73,7 @@ done if [ -z "$domain" ] && [ -n "$dns" ]; then # try to get domain via reverse lookup if empty echo "..trying to get domain via DNS, as DHCP didn't supply one.." - fqdn=$(timeout -t 3 nslookup "$ip" | grep -E "^Address +[0-9]+: +$ip " | head -n 1 | awk '{print $4}') + fqdn=$(timeout -t 3 nslookup "$ip" | awk '{if ($2 == "name") { print $4; exit; } }') domain="${fqdn#*.}" fi # Add domain to list of search domains if not in there yet @@ -106,7 +106,7 @@ done 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" ] && [ -n "$dns" ] && fqdn=$(timeout -t 3 nslookup "$ip" | grep -E "^Address +[0-9]+: +$ip " | head -n 1 | awk '{print $4}') + [ -z "$fqdn" ] && [ -n "$dns" ] && fqdn=$(timeout -t 3 nslookup "$ip" | awk '{if ($2 == "name") { print $4; exit; } }') hostname="${fqdn%%.*}" elif [ -n "$domain" ]; then fqdn="${hostname}.${domain}" -- cgit v1.2.3-55-g7522