Skip to content

Commit 5bc672a

Browse files
committed
Yet another tweak for get_fqdn()
1 parent 496e385 commit 5bc672a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Diff for: lib/hostname.sh

+10-8
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ get_fqdn() {
1414
# Extract the domain using awk
1515
domain=$(grep "^Domains=" /etc/systemd/resolved.conf | awk -F= '{print $2}')
1616
fi
17-
fi
1817

19-
# Construct the FQDN
20-
if [ -n "$domain" ]; then
21-
fqdn="${hostname}.${domain}"
18+
# Construct the FQDN
19+
if [ -n "$domain" ]; then
20+
fqdn="${hostname}.${domain}"
21+
else
22+
fqdn="$hostname" # Default to just the hostname if no domain is set
23+
fi
24+
25+
# Convert to lowercase (as you did with tr 'A-Z' 'a-z')
26+
fqdn=$(echo "$fqdn" | tr 'A-Z' 'a-z')
2227
else
23-
fqdn="$hostname" # Default to just the hostname if no domain is set
28+
fqdn=$(/usr/bin/hostname "$@")
2429
fi
2530

26-
# Convert to lowercase (as you did with tr 'A-Z' 'a-z')
27-
fqdn=$(echo "$fqdn" | tr 'A-Z' 'a-z')
28-
2931
echo "$fqdn"
3032
}
3133

0 commit comments

Comments
 (0)