Fix hostname detection when hostname binary not present

This commit is contained in:
Kovid Goyal 2022-03-04 07:22:59 +05:30
parent ef9adc92c8
commit 3f3efab221
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -18,8 +18,13 @@ trap 'cleanup_on_bootstrap_exit' EXIT
data_started="n"
data_complete="n"
if [ -z "$HOSTNAME" ]; then
hostname=$(hostname)
if [ -z "$hostname" ]; then hostname="_"; fi
hostname=$(hostname 2> /dev/null)
if [ -z "$hostname" ]; then
hostname=$(hostnamectl hostname 2> /dev/null)
if [ -z "$hostname" ]; then
hostname="_";
fi
fi
else
hostname="$HOSTNAME"
fi