Date: Tue, 16 May 2000 11:30:02 -0700 (PDT) From: Brooks Davis <brooks@one-eyed-alien.net> To: freebsd-bugs@FreeBSD.org Subject: Re: conf/18583: [PATCH] DHCP should be able to override hostname. Message-ID: <200005161830.LAA30733@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR conf/18583; it has been noted by GNATS. From: Brooks Davis <brooks@one-eyed-alien.net> To: brooks@one-eyed-alien.net Cc: FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: conf/18583: [PATCH] DHCP should be able to override hostname. Date: Tue, 16 May 2000 11:23:12 -0700 The following is an improved patch which does not supper from the problem of adding a new script to /sbin. Thanks to Garrett Wollman for pointing me in the right direction (using a subshell.) -- Brooks Index: contrib/isc-dhcp/client/scripts/freebsd =================================================================== RCS file: /home/ncvs/src/contrib/isc-dhcp/client/scripts/freebsd,v retrieving revision 1.9 diff -u -r1.9 freebsd --- contrib/isc-dhcp/client/scripts/freebsd 2000/01/15 22:46:40 1.9 +++ contrib/isc-dhcp/client/scripts/freebsd 2000/05/16 18:19:45 @@ -8,6 +8,17 @@ LOGGER=echo fi +get_rc_conf_var() { + (if [ -r /etc/defaults/rc.conf ]; then + . /etc/defaults/rc.conf + source_rc_confs + elif [ -r /etc/rc.conf ]; then + . /etc/rc.conf + fi + + eval echo \$${1}) +} + make_resolv_conf() { echo search $new_domain_name >/etc/resolv.conf for nameserver in $new_domain_name_servers; do @@ -76,7 +87,7 @@ if [ x$reason = xBOUND ] || [ x$reason = xRENEW ] || \ [ x$reason = xREBIND ] || [ x$reason = xREBOOT ]; then current_hostname=`/bin/hostname` - if [ x$current_hostname = x ] || \ + if [ x$current_hostname = x`get_rc_conf_var default_hostname` ] || \ [ x$current_hostname = x$old_host_name ]; then if [ x$new_host_name != x$old_host_name ]; then $LOGGER "New Hostname: $new_host_name" Index: etc//rc.network =================================================================== RCS file: /home/ncvs/src/etc/rc.network,v retrieving revision 1.79 diff -u -r1.79 rc.network --- etc//rc.network 2000/05/16 06:52:11 1.79 +++ etc//rc.network 2000/05/16 18:12:19 @@ -16,8 +16,13 @@ # Set the host name if it is not already set # if [ -z "`hostname -s`" ]; then - hostname ${hostname} - echo -n ' hostname' + if [ -n "${hostname}" ]; then + hostname ${hostname} + echo -n ' hostname' + elif [ -n "${default_hostname}" ]; then + hostname ${default_hostname} + echo -n ' default_hostname' + fi fi # Set the domainname if we're using NIS Index: etc//defaults/rc.conf =================================================================== RCS file: /home/ncvs/src/etc/defaults/rc.conf,v retrieving revision 1.61 diff -u -r1.61 rc.conf --- etc//defaults/rc.conf 2000/05/16 06:52:11 1.61 +++ etc//defaults/rc.conf 2000/05/16 18:15:46 @@ -39,6 +39,8 @@ ### Basic network options: ### hostname="" # Set this! +default_hostname="" # ...or this to get a hostname from DHCP. + # NOTE: Only set one of these. nisdomainname="NO" # Set to NIS domain if using NIS (or NO). dhcp_program="/sbin/dhclient" # Path to dhcp client program. dhcp_flags="" # Additional flags to pass to dhcp client. -- Any statement of the form "X is the one, true Y" is FALSE. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200005161830.LAA30733>