1
0
Fork 0
mirror of https://github.com/hcartiaux/dotfiles.git synced 2024-10-18 17:25:23 +02:00

[bash] Get the FQDN from the HOSTNAME env variable if possible

This commit is contained in:
Hyacinthe Cartiaux 2017-08-24 15:28:20 +02:00
parent 5afcdae976
commit 4f16ae76ee

View file

@ -32,14 +32,12 @@ export LANG LANGUAGE LC_CTYPE LC_ALL
# Get rid of mail notification
unset MAILCHECK
# Configure a set of useful variables
if [[ -e /proc/sys/kernel/hostname ]] ; then
FQDN=$(cat /proc/sys/kernel/hostname)
elif [[ "$(echo "$UNAME" | grep -c -i -e '^.*bsd$')" == "1" ]] ; then
FQDN=$(hostname)
if [[ $(echo $HOSTNAME | grep -c \\.) != 0 ]] ; then
FQDN=$HOSTNAME
else
FQDN=$(hostname -f)
fi
DOMAIN=$(echo "$FQDN" | cut -d '.' -f 2)
# ----------------------------------------------------------------------