Hello,

As suggested by Okuji, I have added the option `--with-configfile' to
`bootp' allowing the automatic loading of the configuration file as given by
the BOOTP/DHCP server. Okuji was right : it is more clean, and, BTW, quite
simple.

Please note that there is no straightforward way to avoid endless loops
(firt menu.lst with `bootp --with-configfile' calling another file with this
very same command etc...), because the filename must be combined to the
`root' partition in order to be uniquely defined (you can call first say
(hd0,0)/grub/menu.lst and give "/grub/menu.lst/" as the second filename,
which can be another file if root is not (hd0,0)).

Here is the proposed ChangeLog entry :

        * stage2/builtins.c (bootp_func): added option `--with-configfile'
          instructing GRUB to load the config file given by the BOOTP/DHCP
          server via the tag 150;
          added prototype for configfile_func
        * docs/grub.texi (netboot): added explanations about this

Regards,        
-- 
Thierry LARONDE, Centre de Ressources Informatiques, Archamps - France
http://www.cri74.org
PingOO, serveur de com sur distribution GNU/Linux: http://www.pingoo.org
diff -rpu grub/docs/grub.texi grub-alpha/docs/grub.texi
--- grub/docs/grub.texi Tue Feb 27 11:23:55 2001
+++ grub/docs/grub.texi Tue Mar  6 11:52:00 2001
@@ -1156,11 +1156,12 @@ see @file{netboot/README.netboot} in the
 @node General usage of network support
 @section How to set up your network
 
-GRUB requires a file server and optionally a server that will assign an
-IP address to the machine on which GRUB is running. For the former, only
-TFTP is supported at the moment. The latter is either BOOTP, DHCP or a
-RARP server@footnote{RARP is deprecated, since it cannot serve much
-information}. It is not necessary to run both the servers on one
+To use a network, GRUB requires a file server and/or a server that will 
+assign an IP address to the machine on which GRUB is running. Depending on
+what you want to do, either one is needed or both.
+For the former, only TFTP is supported at the moment. The latter is either 
+BOOTP, DHCP or a RARP server@footnote{RARP is deprecated, since it cannot 
+serve much information}. It is not necessary to run both the servers on one
 computer. How to configure these servers is beyond the scope of this
 document, so please refer to the manuals specific to those
 protocols/servers.
@@ -1204,6 +1205,18 @@ grub> @kbd{boot}
 @end group
 @end example
 
+Optionaly, by giving the option @code{--with-configfile} to @command{bootp}, 
+you can instruct GRUB to load the configuration file specified via the tag
+@samp{150} for BOOTP/DHCP servers (for explanations, see @ref{Diskless}).
+This allows a dynamic configuration of GRUB. 
+For example, the @file{menu.lst} used at boot time can specify the sole line 
+@code{bootp --with-configfile} in order to instruct GRUB to retrieve the
+configuration file specified by the BOOTP/DHCP server. 
+
+Please note that the name given by the server is @strong{not} supposed to be the
+name of a remote file. That is, you can specify @file{(hd0,0)/grub/menu.lst} to
+tell GRUB to load a _local_ file. If no device is specified, the filename
+given will be relative to the `root' set.
 
 @node Diskless
 @section Booting from a network
diff -rpu grub/stage2/builtins.c grub-alpha/stage2/builtins.c
--- grub/stage2/builtins.c      Thu Mar  1 11:31:41 2001
+++ grub/stage2/builtins.c      Tue Mar  6 15:16:22 2001
@@ -80,6 +80,11 @@ int show_menu = 1;
 /* The BIOS drive map.  */
 static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1];
 
+/* Prototypes for allowing straightfoward calling of builtins functions
+ * inside other functions */
+
+static int configfile_func (char *arg, int flags);
+
 /* Initialize the data for builtins.  */
 void
 init_builtins (void)
@@ -349,6 +354,18 @@ static struct builtin builtin_boot =
 static int
 bootp_func (char *arg, int flags)
 {
+  int with_configfile = 0;
+       
+  /* For sanity, we parse the options first */
+  while (1)
+   {
+     if (grub_memcmp (arg, "--with-configfile", 17) == 0)
+       with_configfile = 1;
+     else
+       break;
+     arg = skip_to (0, arg);
+   }   
+
   if (! bootp ())
     {
       if (errnum == ERR_NONE)
@@ -359,6 +376,15 @@ bootp_func (char *arg, int flags)
 
   /* Notify the configuration.  */
   print_network_configuration ();
+  /* It's the responsability of the administrator to correctly configure the
+   * bootp/dhcp server. CAUTION : there might be an endless loop if the menu
+   * file loaded just tells `bootp --with-configfile'. But to be sure that
+   * the config file name has changed is not enough : the whole name is
+   * built from the `root' AND the filename. So a simple test on the
+   * filename wouldn't be sufficient. So...*/  
+  if (with_configfile)
+    configfile_func (config_file, BUILTIN_CMDLINE);
+  
   return 0;
 }
 
@@ -367,8 +393,10 @@ static struct builtin builtin_bootp =
   "bootp",
   bootp_func,
   BUILTIN_CMDLINE | BUILTIN_MENU,
-  "bootp",
-  "Initialize a network device via BOOTP."
+  "bootp [--with-configfile]",
+  "Initialize a network device via BOOTP. If the option \"--with-configfile\""
+  "is given, try to get a remote configfile specified via the 150 vendor TAG,"
+  " and loads it as a new configfile."
 };
 #endif /* SUPPORT_NETBOOT */
 

Reply via email to