On Fri, Nov 29, 2002 at 11:06:02PM +1100, Jim Richardson wrote: > Dave Whiteley <[EMAIL PROTECTED]> writes: > > > What is the polite Debian way of automatically setting the hostname > > after booting using BOOTP/DHCP. > > > > ... /etc/hostname is identical on all > > the machines. The IP addresses are correctly discovered and set. > > > > I know that I could write a script that gets the host IP address, and > > then gets the name associated with that IP, and then updates the > > /etc/hostname; and that I could run this script "somewhere" in the > > bootup process, or even during the login process. ... > > See the man page dhclient-script(8). > > I've had success with a script /etc/dhclient-exit-hooks like this: > > # Set the hostname > if [ x$reason != xBOUND ] && [ x$reason != REBIND ]; then exit; fi > echo dhclient-exit-hooks: IP address is $new_ip_address > hostname=$( host $new_ip_address | sed -ne 's/Name: //p' ) > hostname $hostname > echo dhclient-exit-hooks: hostname is $( hostname ) > > You could update /etc/hostname too if you like. > -- > Jim Richardson > School of Mathematics & Statistics, University of Sydney > [EMAIL PROTECTED] www.maths.usyd.edu.au:8000/jimr.html >
Thanks for that. Just for the record, and for anyone else reading the archives... I found that the most useful value for $reason on the systems I am using was not BOUND or REBIND, but REBOOT. Also, my "host" command obviously returned different text to Jim's, and I needed to change the s/Name: //p to match the different text. (Sorry I do not have easy access to the actual script at the moment, but the changes were not difficult!) Thanks again, Dave -- Dave Whiteley [EMAIL PROTECTED] Phone +44 (0)113 343 2059 School of Electronic and Electrical Engineering The University of Leeds. Leeds, LS2 9JT, UK -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]