From owner-freebsd-bugs Tue May 16 11:30: 6 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 6257637BACB for ; Tue, 16 May 2000 11:30:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id LAA30733; Tue, 16 May 2000 11:30:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Tue, 16 May 2000 11:30:02 -0700 (PDT) Message-Id: <200005161830.LAA30733@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Brooks Davis Subject: Re: conf/18583: [PATCH] DHCP should be able to override hostname. Reply-To: Brooks Davis Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR conf/18583; it has been noted by GNATS. From: Brooks Davis 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