diff options
Diffstat (limited to 'core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger')
-rwxr-xr-x | core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger b/core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger index 15fb59bf..795dd8a0 100755 --- a/core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger +++ b/core/rootfs/rootfs-stage31/data/inc/udhcpc-trigger @@ -72,6 +72,8 @@ if [ -n "$domain" ] && [ -n "$search" ]; then elif [ -n "$domain" ]; then search="$domain" fi +# Sanitize: domain must not be list +domain="${domain%% *}" # Write out if [ -n "$domain" ]; then echo "domain $domain" >> "/etc/resolv.conf" @@ -93,10 +95,14 @@ if [ -z "$hostname" ]; then [ -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 + fqdn="${hostname}.${domain}" +fi +# Fallback tp IP +if [ -z "$hostname" ]; then + hostname="noname-${ip//./-}" + fqdn="${hostname}.invalid" fi if [ -n "$hostname" ]; then - [ -z "$fqdn" ] && fqdn="$hostname" echo "..setting hostname $hostname (fqdn: $fqdn).." echo "$hostname" > "/proc/sys/kernel/hostname" echo "$hostname" > "/etc/hostname" |