From owner-freebsd-hackers Wed Aug 21 15:21:38 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 65DE737B40A for ; Wed, 21 Aug 2002 15:21:26 -0700 (PDT) Received: from is2.mh.itc.u-tokyo.ac.jp (is2.mh.itc.u-tokyo.ac.jp [133.11.205.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7464843E6A for ; Wed, 21 Aug 2002 15:21:25 -0700 (PDT) (envelope-from tamaru@myn.rcast.u-tokyo.ac.jp) Received: from is2.mh.itc.u-tokyo.ac.jp (is2.mh.itc.u-tokyo.ac.jp [127.0.0.1]) by is2.mh.itc.u-tokyo.ac.jp (Postfix) with ESMTP id BA9BD3780DD for ; Thu, 22 Aug 2002 07:21:24 +0900 (JST) Received: from mailhosting.itc.u-tokyo.ac.jp (IDENT:mirapoint@mailhosting.itc.u-tokyo.ac.jp [133.11.205.3]) by is2.mh.itc.u-tokyo.ac.jp (8.11.3/8.11.3) with ESMTP id g7LMLOx18276; Thu, 22 Aug 2002 07:21:24 +0900 Received: from gin.myn.rcast.u-tokyo.ac.jp (cognac.myn.rcast.u-tokyo.ac.jp [157.82.66.106]) by mailhosting.itc.u-tokyo.ac.jp (Mirapoint Messaging Server MOS 2.9.3.2) with ESMTP id AGW22612; Thu, 22 Aug 2002 07:21:24 +0900 (JST) Date: Thu, 22 Aug 2002 07:21:23 +0900 Message-ID: From: Hiroharu Tamaru To: freebsd-hackers@FreeBSD.ORG Cc: dirkx@covalent.net, tamaru@myn.rcast.u-tokyo.ac.jp Subject: Re: forth/kernel name with a variable. In-Reply-To: Your message of "Sun, 16 Jun 2002 23:20:55 +0200 (CEST)". References: User-Agent: Wanderlust/2.8.1 (Something) SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (Unebigoryae) APEL/10.3 Emacs/20.7 (i386--freebsd) MULE/4.0 (HANANOEN) MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Hi, On Sun, 16 Jun 2002 23:20:55 +0200 (CEST), dirkx@covalent.net wrote: > During a diskless boot (i.e. after the PXE stage); I'd like to get to load > (or try to load) a configuration file which is machine specific; e.g. > something along the lines of: > > # >> /mboot/boot/defaults/loader.conf > # > .... > loader_conf_files="/boot/device.hints /boot/loader.conf > /boot/loader.conf.local /boot/\\${boot.netif.ip}.conf > /boot/nextboot.conf" > .... > > where at least an attempt is made to get a machine specific file (in this > case to define a kernel boot file which is specific to that machine) - as > this would allow me to reduce the footprint on the boot/dhcp/tftp server > considerably. > > Any hints ? (The above does not get substituted). > > Dw > -- > Dirk-Willem van Gulik I was looking for the same feature, and could not come up with a Right Way either. Since I wanted to hack as little as possible, and also not to touch files that are updated so often in the repository, I ended up with the following hack: 1) patch loader.rc --- loader.rc- Fri Dec 28 21:05:23 2001 +++ loader.rc Thu May 16 06:55:45 2002 @@ -5,7 +5,26 @@ include /boot/loader.4th \ Reads and processes loader.rc -start +\ start + +only forth also support-functions definitions + +\ This is for use in 10.0.0.100.rc files +: initialize_name ( addr len -- ) + strdup conf_files .len ! conf_files .addr ! +; + +\ Need to compile a word to use 'catch' feature +: mystart + s" /boot/defaults/loader.conf" initialize include_conf_files + s" include /boot/${boot.netif.ip}.rc" ['] evaluate catch + any_conf_read? if + load_kernel + load_modules + then +; + +mystart \ Tests for password -- executes autoboot first if a password was defined check-password 2) say your IP is 10.0.0.100, then create a file /boot/10.0.0.100.rc that has a one line content like this (the position and the number of the spaces seems to count): s" /boot/10.0.0.100.conf" initialize_name include_conf_files 3) write your favorite config in /boot/10.0.0.100.conf in the same syntax as loader.conf 4) Things should work as desired. NOTE: the order the files are read are: /boot/defaults/loader.conf /boot/device.hints /boot/loader.conf /boot/loader.conf.local /boot/10.0.0.100.conf Oh, and by the way, this was a 4.5-STABLE box when I did the hack; I guess what you are playing with is a -CURRENT box. YMMV. I wanted to avoid the 10.0.0.100.rc file, but could hardly read nor write the 4th language. I wish someone with a 4th expertise would write a real solution and commit it to -CURRENT and -STABLE. The diskless stuffs are hard to live with without this feature if you have a heterogeneous environment where you need to switch the kernel image themselves according to the boxes' h/w. P.S. Please keep me in the CC line, I'm not subscribed to this list; I found the original message in the archives. -- Hiroharu Tamaru To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message