[Gllug] $HOSTNAME

Lesley lesleyb at herlug.org.uk
Wed Sep 9 11:29:01 UTC 2009


On Wed, Sep 09, 2009 at 09:29:26AM +0100, Hari Sekhon wrote:
> Richard Jones wrote:
> > On Tue, Sep 08, 2009 at 06:47:40PM +0100, John G Walker wrote:
> >   
> >> On Tue, 08 Sep 2009 17:05:24 +0100 Peter Cannon
> >> <peter at cannon-linux.co.uk> wrote:
> >>
> >>     
> >>> John G Walker wrote:
> >>>       
> >>>> I think I'm going off my head.
> >>>>
> >>>> Where is the $HOSTNAME variable set in OpenSUSE 10.1, using KDE3?
> >>>> Surely it's set from etc/HOSTNAME? Except they're suddenly
> >>>> different.
> >>>>
> >>>> It's important because it's used in various scripts of mine
> >>>> (including the backup),
> >>>>
> >>>>         
> >>> /etc/HOSTNAME
> >>>
> >>>       
> >> That what I thought (see above) but it isn't. It's using a different
> >> value to the one on etc/HOSTNAME,
> >>     
> >
> > Older Debian systems had it in /etc/hostname (NB lowercase).
> >
> > I've also seen systems where this comes from a "special" entry in
> > /etc/hosts.  It seems like the second line of /etc/hosts had the form:
> >
> > <eth0-addr>  hostname.example.com hostname
> >
> > and the hostname came from that.
> >   
> I've also observed these differences, an unfortunate lack of consistency 
> among distributions, it's usually due to distro-specific bash scripts at 
> boot time setting the hostname from these different sources. However, 
> they all end up doing the same thing with regards to sourcing from proc 
> for hostname -s, at least this is the case on CentOS and Debian that 
> I've confirmed.
> 
On my Debian Lenny I did a grep -r HOSTNAME * in /etc and found (amongst others)

init.d/hostname.sh:     [ -f /etc/hostname ] && HOSTNAME="$(cat /etc/hostname)"
init.d/hostname.sh:     [ -z "$HOSTNAME" ] && HOSTNAME="$(hostname)"
init.d/hostname.sh:     [ -z "$HOSTNAME" ] && HOSTNAME=localhost
init.d/hostname.sh:     [ "$VERBOSE" != no ] && log_action_begin_msg "Setting hostname to '$HOSTNAME'"
init.d/hostname.sh:     hostname "$HOSTNAME"

you could try the same on your boxen to find where HOSTNAME might be set?

Regards

L.
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list