mirror of
https://gitlab.alpinelinux.org/alpine/cloud/tiny-cloud.git
synced 2025-12-16 03:42:44 +03:00
Avoid set empty hostname
Avaoid situation where we end up with an empty /etc/hostname.
This commit is contained in:
parent
468407db05
commit
7be3b198fb
@ -198,7 +198,16 @@ init__enable_sshd() {
|
|||||||
|
|
||||||
init__set_hostname() {
|
init__set_hostname() {
|
||||||
local fqdn=$(imds @hostname)
|
local fqdn=$(imds @hostname)
|
||||||
|
if [ -z "$fqdn" ]; then
|
||||||
|
log info "No hostname set"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
local host="${fqdn%%\.*}"
|
local host="${fqdn%%\.*}"
|
||||||
|
if [ -z "$host" ]; then
|
||||||
|
log err "$fqdn is not a valid hostname"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "$ROOT"/etc
|
mkdir -p "$ROOT"/etc
|
||||||
echo "$host" > "$ROOT"/etc/hostname
|
echo "$host" > "$ROOT"/etc/hostname
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user