Replace unsafe characters in SET_HOSTNAME.

When setting the hostname from $SET_HOSTNAME, replace any characters
not allowed in hostnames (as specified in RFC 952) with a hyphen.
This is enables a VM template to safely use the VM's name as the
hostname (by setting the context variable SET_HOSTNAME=$NAME).
pull/28/head
Jamie Taylor 9 years ago
parent bbcadaa59d
commit 1c335c690b

@ -20,7 +20,7 @@ function get_dns_name() {
}
if [ -n "$SET_HOSTNAME" ]; then
set_hostname $SET_HOSTNAME
set_hostname $(echo "$SET_HOSTNAME" | sed -e 's/[^-a-zA-Z0-9]/-/g')
elif [ -n "$DNS_HOSTNAME" ]; then
set_hostname $(get_dns_name)
fi

@ -22,7 +22,7 @@ function get_dns_name() {
}
if [ -n "$SET_HOSTNAME" ]; then
set_hostname $SET_HOSTNAME
set_hostname $(echo "$SET_HOSTNAME" | sed -e 's/[^-a-zA-Z0-9]/-/g')
elif [ -n "$DNS_HOSTNAME" ]; then
set_hostname $(get_dns_name)
fi

@ -23,7 +23,7 @@ function get_dns_name() {
}
if [ -n "$SET_HOSTNAME" ]; then
set_hostname $SET_HOSTNAME
set_hostname $(echo "$SET_HOSTNAME" | sed -e 's/[^-a-zA-Z0-9]/-/g')
elif [ -n "$DNS_HOSTNAME" ]; then
set_hostname $(get_dns_name)
fi

Loading…
Cancel
Save