diff --git a/src/recap b/src/recap index 8d20a30..ef6ff9a 100755 --- a/src/recap +++ b/src/recap @@ -545,7 +545,16 @@ if [[ "$(id -u)" != "0" ]]; then fi # Grab the server's host name -HOSTNAME="$( hostname )" +HOSTNAME="$( hostnamectl --static 2>/dev/null || + hostname 2>/dev/null || + echo 'Unknown' )" + +# Workaround for ubuntu14 as --static has no effect when printing values +if grep -q 'hostname:' <<<"${HOSTNAME}"; then + HOSTNAME=$( awk -F: \ + '/hostname/ {gsub("\\s*","",$2) + print $2}' <<<"${HOSTNAME}" ) +fi # Start logging log INFO "${banner_start}"