From ddd74b5d971a734c7e88cda3764f7e059f163b51 Mon Sep 17 00:00:00 2001 From: Pavel Zhukov Date: Jul 14 2021 10:26:33 +0000 Subject: Add fallback to hostname determination Use hostname in case if hostnamectl is not available/not functional. fallback to uname in case if both hostname and hostnamectl are missed (in containers) Reference:https://pagure.io/setup/c/ddd74b5d971a734c7e88cda3764f7e059f163b51 Conflict:Adjusting the command execution sequence and add a prompt. --- diff --git a/profile b/profile index 783fe17..542add4 100644 --- a/profile +++ b/profile @@ -42,7 +42,10 @@ else pathmunge /usr/sbin after fi -HOSTNAME=`/usr/bin/hostnamectl --transient 2>/dev/null` +HOSTNAME=$(/usr/bin/hostname 2>/dev/null) || \ +HOSTNAME=$(/usr/bin/uname -n 2>/dev/null) || \ +HOSTNAME=$(/usr/bin/hostnamectl --transient 2>/dev/null) || echo "System commands: hostname uname and hostnamectl, which do not exist." + HISTSIZE=1000 if [ "$HISTCONTROL" = "ignorespace" ] ; then export HISTCONTROL=ignoreboth -- 2.27.0