summaryrefslogtreecommitdiffstats
path: root/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
diff options
context:
space:
mode:
authorSimon Rettberg2023-06-21 18:00:09 +0200
committerSimon Rettberg2023-06-21 18:00:09 +0200
commitbee36aec4290daeb46ffd5e8cdc070299554a2a7 (patch)
treea750cfd83523f3b41685a9a01997fe30f10cd959 /core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
parent[dhcpc-busybox] hostname fallback: Try harder (diff)
downloadmltk-bee36aec4290daeb46ffd5e8cdc070299554a2a7.tar.gz
mltk-bee36aec4290daeb46ffd5e8cdc070299554a2a7.tar.xz
mltk-bee36aec4290daeb46ffd5e8cdc070299554a2a7.zip
[dhcpc-busybox] More DHCP hostname shenanigans
Diffstat (limited to 'core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx')
-rwxr-xr-xcore/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx41
1 files changed, 24 insertions, 17 deletions
diff --git a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
index 99e8b0dd..0e64643e 100755
--- a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
+++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
@@ -202,25 +202,26 @@ case "$1" in
echo "SLX_NET_WINS='$wins'" >> /opt/openslx/config
fi
- if [ -z "$dns_fqdn" ] && [ -n "$domain" ] && [ -n "$hostname" ]; then
- # fallback to what the dhcp told us
- dns_fqdn="${hostname}.${domain}"
- fi
- if [ -z "$dns_fqdn" ]; then
- dns_fqdn="$( hostname -f )"
- fi
- if [ -z "$dns_fqdn" ]; then
- if [ -s "/etc/hostname" ]; then
- dns_fqdn="$( head -n 1 /etc/hostname )"
- else
- dns_fqdn="noname-${ip//./-}.invalid"
- fi
- fi
-
# Only update hostname if network is not ready yet
# later on this might cause issues
if ! [ -e "$flag" ]; then
- # Update hostname
+ # Fallback for hostname
+ if [ -z "$dns_fqdn" ] && [ -n "$domain" ] && [ -n "$hostname" ]; then
+ # fallback to what the dhcp told us
+ dns_fqdn="${hostname}.${domain}"
+ fi
+ if [ -z "$dns_fqdn" ]; then
+ # Try currently set fqdn
+ dns_fqdn="$( hostname -f )"
+ fi
+ if [ -z "$dns_fqdn" ]; then
+ if [ -s "/etc/hostname" ]; then
+ dns_fqdn="$( head -n 1 /etc/hostname )"
+ else
+ # Final fallback, nothing valid found
+ dns_fqdn="noname-${ip//./-}.invalid"
+ fi
+ fi
# finally, if dns_fqdn was set to anything, apply it
if [ -n "$dns_fqdn" ]; then
dns_short="${dns_fqdn%%.*}"
@@ -237,7 +238,13 @@ case "$1" in
# Update /etc/issue for proper spacing
/opt/openslx/scripts/openslx-create_issue
touch "$flag"
- fi # end "network not ready yet"
+ # end "network not ready yet"
+ else
+ # Network already going, make sure we don't change the primary hostname in /etc/hosts
+ hostname=
+ domain=
+ dns_fqdn=
+ fi
# Remove any stray addresses; we expect the primary interface to only have one
# address supplied via DHCP. We do this after adding the new one, obviously.
rem_list=$( ip -o addr show "$interface" | awk '{ for (i=1;i<NF;++i) if ($i == "inet") print $(i+1) }' | grep -v "^${ip}/" )