Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 May 2002 13:03:14 -0400 (EDT)
From:      John Baldwin <jhb@FreeBSD.org>
To:        qa@FreeBSD.org
Subject:   sysinstall fixups
Message-ID:  <XFMail.20020529130314.jhb@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
I'm making a scripted install for work that is partially interactive and
have run into some nuisances in sysinstall that I've fixed.  The patches
are at www.freebsd.org/~jhb/patches/sysinstall.patch and included below.
I'd like to commit most of this unless there are objections.

Index: disks.c
===================================================================
RCS file: /usr/cvs/src/usr.sbin/sysinstall/disks.c,v
retrieving revision 1.130
diff -u -r1.130 disks.c
--- disks.c     28 Mar 2002 08:23:33 -0000      1.130
+++ disks.c     28 May 2002 19:48:34 -0000
@@ -758,7 +758,8 @@
        /* Some are already selected */
        for (i = 0; i < devcnt; i++) {
            if (devs[i]->enabled) {
-               if (variable_get(VAR_NONINTERACTIVE))
+               if (variable_get(VAR_NONINTERACTIVE) &&
+                 !variable_get(VAR_DISKINTERACTIVE))
                    diskPartitionNonInteractive(devs[i]);
                else
                    diskPartition(devs[i]);
@@ -769,7 +770,8 @@
        /* No disks are selected, fall-back case now */
        if (devcnt == 1) {
            devs[0]->enabled = TRUE;
-           if (variable_get(VAR_NONINTERACTIVE))
+           if (variable_get(VAR_NONINTERACTIVE) &&
+             !variable_get(VAR_DISKINTERACTIVE))
                diskPartitionNonInteractive(devs[0]);
            else
                diskPartition(devs[0]);
Index: label.c
===================================================================
RCS file: /usr/cvs/src/usr.sbin/sysinstall/label.c,v
retrieving revision 1.116
diff -u -r1.116 label.c
--- label.c     29 Jan 2002 22:35:40 -0000      1.116
+++ label.c     28 May 2002 19:51:05 -0000
@@ -163,7 +163,8 @@
     }
     else if (cnt) {
        /* Some are already selected */
-       if (variable_get(VAR_NONINTERACTIVE))
+       if (variable_get(VAR_NONINTERACTIVE) &&
+         !variable_get(VAR_DISKINTERACTIVE))
            i = diskLabelNonInteractive(NULL);
        else
            i = diskLabel(NULL);
@@ -173,7 +174,8 @@
        cnt = deviceCount(devs);
        if (cnt == 1) {
            devs[0]->enabled = TRUE;
-           if (variable_get(VAR_NONINTERACTIVE))
+           if (variable_get(VAR_NONINTERACTIVE) &&
+             !variable_get(VAR_DISKINTERACTIVE))
                i = diskLabelNonInteractive(devs[0]);
            else
                i = diskLabel(devs[0]);

This and the sysinstall.h header add a 'diskInteractive' variable that
can be used to allow for interactive disk setup from a script similar
to netInteractive for tcpMenuSelect().

Index: modules.c
===================================================================
RCS file: /usr/cvs/src/usr.sbin/sysinstall/modules.c,v
retrieving revision 1.2
diff -u -r1.2 modules.c
--- modules.c   12 Oct 2001 22:39:02 -0000      1.2
+++ modules.c   28 May 2002 22:33:03 -0000
@@ -62,6 +62,10 @@
        while ((dp = readdir(dirp))) {
            if (dp->d_namlen < (sizeof(".ko") - 1)) continue;
            if (strcmp(dp->d_name + dp->d_namlen - (sizeof(".ko") - 1), ".ko") == 0) {
+               strcpy(module, dp->d_name);
+               module[dp->d_namlen - (sizeof(".ko") - 1)] = '\0';
+               if (modfind(module) != -1)
+                       continue;
                strcpy(module, MODULESDIR);
                strcat(module, "/");
                strcat(module, dp->d_name);

Not really tested, but this should fix the problem where we bogusly
fail trying to load a module via drivers.conf for a module that was
compiled into the kernel we booted.  We should test this and possibly
put it into 4.6 to make cdboot and Alpha CD installs not emit bogus
warnings when sysinstall runs.

Index: sysinstall.h
===================================================================
RCS file: /usr/cvs/src/usr.sbin/sysinstall/sysinstall.h,v
retrieving revision 1.226
diff -u -r1.226 sysinstall.h
--- sysinstall.h        30 Apr 2002 22:40:06 -0000      1.226
+++ sysinstall.h        28 May 2002 19:49:39 -0000
@@ -93,6 +93,7 @@
 #define VAR_DEBUG                      "debug"
 #define VAR_DESKSTYLE                  "_deskStyle"
 #define VAR_DISK                       "disk"
+#define VAR_DISKINTERACTIVE            "diskInteractive"
 #define VAR_DISTS                      "dists"
 #define VAR_DIST_MAIN                  "distMain"
 #define VAR_DIST_CRYPTO                        "distCRYPTO"
Index: system.c
===================================================================
RCS file: /usr/cvs/src/usr.sbin/sysinstall/system.c,v
retrieving revision 1.119
diff -u -r1.119 system.c
--- system.c    1 Nov 2001 23:32:46 -0000       1.119
+++ system.c    7 Nov 2001 17:27:15 -0000
@@ -141,6 +141,8 @@
     if (!sysctlbyname("debug.boothowto", &boothowto, &i, NULL, NULL) &&
         (i == sizeof(boothowto)) && (boothowto & RB_VERBOSE))
        variable_set2(VAR_DEBUG, "YES", 0);
+    else
+       boothowto = 0;
 
     /* Are we running as init? */
     if (getpid() == 1) {
@@ -149,12 +151,13 @@
        RunningAsInit = 1;
        setsid();
        close(0);
-       fd = open("/dev/ttyv0", O_RDWR);
-       if (fd == -1) {
-           fd = open("/dev/console", O_RDWR);  /* fallback */
+       if (boothowto & RB_SERIAL) {
+           fd = open("/dev/console", O_RDWR);
            variable_set2(VAR_FIXIT_TTY, "serial", 0); /* give fixit a hint */
-       } else
+       } else {
+           fd = open("/dev/ttyv0", O_RDWR);
            OnVTY = TRUE;
+       }
        /*
         * To make _sure_ we're on a VTY and don't have /dev/console switched
         * away to a serial port or something, attempt to set the cursor appearance.

This is an old patch that forces sysinstall to use a serial console if we
booted with '-h' from boot2 or the loader instead of always trying ttyv0 and
only falling back to a serial console if that doesn't work.  Not tested I
think.

Index: tcpip.c
===================================================================
RCS file: /usr/cvs/src/usr.sbin/sysinstall/tcpip.c,v
retrieving revision 1.123
diff -u -r1.123 tcpip.c
--- tcpip.c     29 Mar 2002 23:03:17 -0000      1.123
+++ tcpip.c     28 May 2002 20:42:57 -0000
@@ -349,6 +349,18 @@
     }
     else { /* See if there are any defaults */
        char *cp;
+       char *old_interactive = NULL;
+
+       /*
+        * This is a hack so that the dialogs below are interactive in a
+        * script if we have requested interactive behavior.
+        */
+       if (variable_get(VAR_NONINTERACTIVE) &&
+         variable_get(VAR_NETINTERACTIVE)) {
+           old_interactive = strdup(VAR_NONINTERACTIVE);
+           variable_unset(VAR_NONINTERACTIVE);
+       }
+
 
        /*
         * Try a RTSOL scan if such behavior is desired.
@@ -400,6 +412,12 @@
            }
            else
                use_dhcp = FALSE;
+       }
+
+       /* Restore old VAR_NONINTERACTIVE if needed. */
+       if (old_interactive != NULL) {
+           variable_set2(VAR_NONINTERACTIVE, old_interactive, 0);
+           free(old_interactive);
        }
 
        /* Special hack so it doesn't show up oddly in the tcpip setup menu */

This fixes the interactive network setup from a script to actually ask the IPv6
and DHCP questions when interactive behavior is explicitly requested instead
of using the default answer.

-- 

John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-qa" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20020529130314.jhb>