[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: changing hostname



On Fri, Jun 22, 2001 at 12:16:51PM +0000, Iain Smith wrote:
> I'd suggest:
> 
> find /etc/ -type f |xargs grep $HOSTNAME

Well, that is a really big hammer in fact.  And you will still miss
stuff that is not under /etc, but has a symlink in /etc pointing to it.

I used to do it like this (or much worse even, involving multiple
pneumatic hammers in subshells piped to pathologically eclectic chainsaws)
myself.  Sure, it was fun making lots of noise and it even gave me some
slight of hand at juggling these toys (and parsing yet another manpage
when the balls keep falling on the floor).  :-)

Until I found out about this wonderful "-r" option to gnu grep:

  grep -r myregex /etc 

wants to be your friend too.

> rather than using cat, you'll get the names of any files containing matches 
> back using this method. Also, it may be worth changing the search base to /
> as IIRC a search on a potato box turned up some matches elsewhere on the 
> filesystem...

Watch out for all the rope hanging about in dark corners of /proc and
/dev.  Your point is valid though, but I doubt that you'll find
much of importance outside of /var.  And then most of what is in /var
should probably change itself when daemons restart or should just stay
like it was, like your archived logfiles.

Your best point above is the most subtle one:  try not to hardcode any
"local" information in scripts, when you can use self-healing constructs
offered to you by the system, like a $HOSTNAME environment variable, if
there is one.  Or by figuring it from a "$(hostname)" subshell call.

If all the scripts and configuration files could use this (of course that
is not a reasonable assumption in reality), one would ideally only have
to change one file, /etc/hostname.  But then you grow sick of all the 
stupid dns queries for your own hostname and you fix /etc/hosts.  And then
it turns out that pithy app foo doesn't understand any fancy $whatever
stuff in its config file.  Oh well.

Cheers,


Joost



Reply to: