view admin/guess-hostname @ 262:fc1c6425c024

s/EXIT_SUCCESS/0/ && s/EXIT_FAILURE/1/ The constants are all to bulky. We should have different, meaningful exit codes anyway.
author markus schnalke <meillo@marmaro.de>
date Thu, 02 Dec 2010 17:11:25 -0300
parents cab46cefa4ce
children
line wrap: on
line source

#!/bin/sh
#
# try several ways to guess the hostname
# earlier output lines are probably better

(

# this is what Debian uses
cat /etc/mailname

# probably a good value on GNU/Linux
hostname -f

# this is often the short hostname
cat /etc/hostname

# often the short hostname, but widely available
hostname

# this file was mentioned on the Internet
cat /etc/HOSTNAME

) 2>/dev/null | uniq

exit 0