1
0
mirror of https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git synced 2025-12-15 11:22:43 +03:00

Avoid set empty hostname

Avaoid situation where we end up with an empty /etc/hostname.
This commit is contained in:
Natanael Copa 2023-05-08 21:49:53 +02:00
parent 468407db05
commit 7be3b198fb

View File

@ -198,7 +198,16 @@ init__enable_sshd() {
init__set_hostname() {
local fqdn=$(imds @hostname)
if [ -z "$fqdn" ]; then
log info "No hostname set"
return
fi
local host="${fqdn%%\.*}"
if [ -z "$host" ]; then
log err "$fqdn is not a valid hostname"
return 1
fi
mkdir -p "$ROOT"/etc
echo "$host" > "$ROOT"/etc/hostname