From owner-freebsd-current Thu May 11 14:43:08 1995 Return-Path: current-owner Received: (from majordom@localhost) by freefall.cdrom.com (8.6.10/8.6.6) id OAA15324 for current-outgoing; Thu, 11 May 1995 14:43:08 -0700 Received: from gndrsh.aac.dev.com (gndrsh.aac.dev.com [198.145.92.241]) by freefall.cdrom.com (8.6.10/8.6.6) with ESMTP id OAA15315 for ; Thu, 11 May 1995 14:42:58 -0700 Received: (from rgrimes@localhost) by gndrsh.aac.dev.com (8.6.11/8.6.9) id OAA13278; Thu, 11 May 1995 14:42:35 -0700 From: "Rodney W. Grimes" Message-Id: <199505112142.OAA13278@gndrsh.aac.dev.com> Subject: Re: bug in /usr/src/etc/rc (netstart) To: kuku@gilberto.physik.rwth-aachen.de Date: Thu, 11 May 1995 14:42:34 -0700 (PDT) Cc: freebsd-current@freefall.cdrom.com In-Reply-To: <199505112150.XAA16952@gilberto.physik.rwth-aachen.de> from "Christoph Kukulies" at May 11, 95 11:50:13 pm X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Length: 3405 Sender: current-owner@FreeBSD.org Precedence: bulk > > > > > > > > > > > > > > > > > > > > > > > > > netstart is started using sh /etc/netstart (that was a . /etc/netstart > > > > > formerly and it used to work). Now, starting it with sh /etc/netstart > > > > > $hostname is unknown and the consequences are quite unfriendly. > > > > > > > > Hostname should be set by /etc/sysconfig, /etc/sysconfig is .'ed into > > > > /etc/rc. Infact all variables that where set in /etc/netstart should > > > > now be set by /etc/sysconfig. > > > > > > > > Do you infact have /etc/sysconfig 1.11, /etc/rc 1.63 ? > > > > > > I checked again now definitely with both, sysconfig 1.11, rc 1.63 and > > > when I have the sh /etc/netstart in rc the hostname is not being set. > > > How should it ? I don't need to tell you that a sub shell does not inherit > > > variables that are set in the parent unless the subshell is 'sourced'. > > > > > > It works ok if I replace sh with . (source) (which was in some > > > earlier version of rc anyway). > > > > I don't like to repeat myself, but ``Hostname is set by /etc/sysconfig, > > /etc/sysconfig is sourced by /etc/rc''. I know all about sub shell vs > > sourced file and the effects on variables. I have been writting /etc/rc > > files for 15 years. > > I didn't put this in doubt. > > > > > Just where are you setting $hostname at? If your not doing it at about > > Exactly there I'm setting hostname. > > > line 61 of /etc/sysconfig your not doing it the right way!!! > > > > You will note that at line 75 of /etc/rc the file /etc/sysconf is sourced > > into /etc/rc which means $hostname is defined. > > $hostname (the variable) is defined for rc but not for netstart and when the > hostname is set by netstart by the /sbin/hostname $hostname, then > hostname *is* empty the way it is being done currently. Excuse me! > I'm well aware of myname and defaultrouter being gone and I don't have them > any longer. > > rc sources sysconfig. So rc knows $hostname (the variable). > rc shells netstart but the variable $hostname *is* empty in netstart > where the actual hostname is being set via the hostname $hostname command. > > > Let's take this little example: > > let r be rc > let s be sysconfig > let n bet netstart > > -------- r --------- > #!/bin/sh > . s > sh n > -------- s --------- > #!/bin/sh > hostname=foo > -------- n --------- > #!/bin/sh - You missed: . s at line 8, the very first thing done. > echo $hostname > > Now execute r and you will find the the echo in n is empty. > > A sixpack of beer that something is wrong with the current rc/sysconfig/net > start combo. I don't drink, but look at line 8 of /etc/netstart: . /etc/sysconfig > > > > > > You will also note that this is the same way that /etc/netstart now > > gets this value from /etc/sysconfig. > > > > -- > > Rod Grimes rgrimes@gndrsh.aac.dev.com > > Accurate Automation Company Custom computers for FreeBSD > > > > --Chris Christoph P. U. Kukulies kuku@gil.physik.rwth-aachen.de > FreeBSD blues.physik.rwth-aachen.de 2.0-BUILT-19950507 FreeBSD 2.0-BUILT-1995 > 0507 #0: Sun May 7 18:08:05 MET DST 1995 root@blues.physik.rwth-aachen.d > e:/usr/src/sys/compile/BLUESGUS i386 > -- Rod Grimes rgrimes@gndrsh.aac.dev.com Accurate Automation Company Custom computers for FreeBSD