Skip to content

Commit

Permalink
Merge pull request #213 from tonyskapunk/hostname
Browse files Browse the repository at this point in the history
Hostname
  • Loading branch information
tonyskapunk authored Apr 12, 2019
2 parents 8265605 + 51091b5 commit ab820e8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/recap
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit ab820e8

Please sign in to comment.