exoscale: Fix assigning domain name

The whole hostname was used as domain name because there
was no . in it where the string could have been split.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2020-09-29 13:47:09 +00:00
parent 898d6d87a2
commit df8920100d

View File

@@ -33,10 +33,13 @@ import_exoscale_configuration() {
# Set domainname
if ! grep -q "^DOMAINNAME=" /var/ipfire/main/settings; then
local domainname="${hostname#*.}"
local domainname="localdomain"
# Fall back to localdomain
[ -z "${domainname}" ] && domainname="localdomain"
# If the hostname contains a dot we strip the last
# part and use it as our domain name
if [[ ${hostname} =~ "\." ]]; then
domainname="${hostname#*.}"
fi
echo "DOMAINNAME=${domainname}" >> /var/ipfire/main/settings
fi