Subject: Re: mysql: hostname
To: Thimble Smith <tim@desert.net>
From: Tom T. Thai <tomthai@future.net>
List: current-users
Date: 11/16/1998 16:50:54
On Mon, 16 Nov 1998, Thimble Smith wrote:

> On Mon, Nov 16, 1998 at 10:53:48PM +0200, Michael Widenius wrote:
> > Any ideas how to do this portable ?
> 
> I think `hostname` is about as good as it gets.  I was mistaken
> when I said his /etc/hosts file is to blame (although that might
> be the problem on some versions of UNIX).  In some startup script
> (rc.network, maybe?), the hostname is set using 'hostname predict'
> when it should be set using 'hostname predict.future.net'.  That's
> just for Tom's case.

actually my NetBSD system has both variables in rc.conf for hostname and
domainname. And if they are not set in rc.conf then they use the settings
in /etc/myname and /etc/defaultdomain

from rc.conf:
...
# Basic network configuration
hostname=""                             # if blank, use /etc/myname
domainname=""                           # if blank, use /etc/defaultdomain
defaultroute=""                         # if blank, use /etc/mygate
...

# cat /etc/myname
predict
# cat /etc/defaultdomain
future.net

> In general I think it's smart for the system administrator to make
> sure that `hostname` returns a FQDN.  Otherwise you're going to

I'm not sure if I agree with the fact that `hostname` should return a
FQDN.  Is there and RFC somewhere I can look at?  I don't mean to start
any religious OS war, since I would rather focus on using NetBSD and
MySQL.  I've cc: this to the netbsd's group, maybe they can shed some
light on how NetBSD uses `hostname` or maybe I didn't config my system
right.

> wind up calling ifconfig -a, finding the UP interfaces that have
> IP addresses, resolving those addresses, picking one?.  And that
> sounds even less portable.  The problem is that the machine host

agree, that doesn't sound very portable.

> name isn't required to be in DNS or anything, so `hostname` doesn't
> have any REAL relationship to the (dns) host name at all.

my /etc/hosts has this line:

204.130.134.9 predict.future.net predict

does that make a difference if FQDN comes first?  I don't think so, but
maybe?

> That's why I suggested a command line argument.  If the argument is
> supplied, then use it.  Otherwise, try `hostname` (install_db could
> check the resolveip `hostname` to see if it's valid), or just print
> a warning and only insert the 'localhost' entry.
> 
> hostname=`hostname`
> resolved=`resolveip $hostname 2>&1`
> 
> if [ $? = 0 ]; then
>     echo "OK: $resolved"
> else
>     cat <<EOS
> Sorry, the host '$hostname' could not be looked up.
> Please specify a host on the command line:
>     mysql_install_db --with-hostname=you.host.name
> or
>     mysql_install_db --without-hostname
> EOS
> exit 1;
> fi
> 
> Something like that?

or you can use uname to check the platform and grep `hostname` return
value to see if it has a dotted notation (dirty?), if not then do a case
in mysql_install_db on each case that we know their `hostname` doesn't
return a FQDN and ask them to input the domain name for FQDN.