diff options
author | jkh <jkh@FreeBSD.org> | 1997-09-08 11:09:11 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1997-09-08 11:09:11 +0000 |
commit | 140da238550bc7f41ac21e3cd32cf0b847fe4d50 (patch) | |
tree | e89d834605956319edc985c70f3f5e88f609a9e5 /release/sysinstall | |
parent | 4fcbd35c019dc4ad198f15d50a682c6c76e7d614 (diff) | |
download | FreeBSD-src-140da238550bc7f41ac21e3cd32cf0b847fe4d50.zip FreeBSD-src-140da238550bc7f41ac21e3cd32cf0b847fe4d50.tar.gz |
Make upgrade potentially a little less interactive.
Add and document new loadConfig function (sort of like a script #include).
Make TCP/IP setup far less chatty when it doesn't need to be.
Diffstat (limited to 'release/sysinstall')
-rw-r--r-- | release/sysinstall/dispatch.c | 35 | ||||
-rw-r--r-- | release/sysinstall/installUpgrade.c | 140 | ||||
-rw-r--r-- | release/sysinstall/sysinstall.8 | 11 | ||||
-rw-r--r-- | release/sysinstall/tcpip.c | 16 |
4 files changed, 190 insertions, 12 deletions
diff --git a/release/sysinstall/dispatch.c b/release/sysinstall/dispatch.c index 1f096a4..fc0f72d 100644 --- a/release/sysinstall/dispatch.c +++ b/release/sysinstall/dispatch.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: dispatch.c,v 1.20 1997/07/16 05:22:40 jkh Exp $ + * $Id: dispatch.c,v 1.21 1997/08/11 13:08:18 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -39,7 +39,8 @@ static int _shutdown(dialogMenuItem *unused); static int _systemExecute(dialogMenuItem *unused); - +static int _loadConfig(dialogMenuItem *unused); + static struct _word { char *name; int (*handler)(dialogMenuItem *self); @@ -82,6 +83,7 @@ static struct _word { { "installFixitFloppy", installFixitFloppy }, { "installFilesystems", installFilesystems }, { "installVarDefaults", installVarDefaults }, + { "loadConfig", _loadConfig }, { "mediaSetCDROM", mediaSetCDROM }, { "mediaSetFloppy", mediaSetFloppy }, { "mediaSetDOS", mediaSetDOS }, @@ -140,6 +142,35 @@ _systemExecute(dialogMenuItem *unused) return DITEM_FAILURE; } +static int +_loadConfig(dialogMenuItem *unused) +{ + FILE *fp; + char *cp, buf[BUFSIZ]; + int i = DITEM_SUCCESS; + + cp = variable_get("file"); + if ((!cp || (fp = fopen(cp, "r")) == NULL) && + (fp = fopen("install.cfg", "r")) == NULL && + (fp = fopen("/stand/install.cfg", "r")) == NULL && + (fp = fopen("/tmp/install.cfg", "r")) == NULL) { + msgConfirm("Unable to locate an install.cfg file in $CWD, /stand or /tmp."); + i = DITEM_FAILURE; + } + else { + variable_set2(VAR_NONINTERACTIVE, "YES"); + while (fgets(buf, sizeof buf, fp)) { + if ((i = DITEM_STATUS(dispatchCommand(buf))) != DITEM_SUCCESS) { + msgDebug("Command `%s' failed - rest of script aborted.\n", buf); + break; + } + } + } + fclose(fp); + variable_unset(VAR_NONINTERACTIVE); + return i; +} + /* For a given string, call it or spit out an undefined command diagnostic */ int dispatchCommand(char *str) diff --git a/release/sysinstall/installUpgrade.c b/release/sysinstall/installUpgrade.c index f8eda8f..d997533 100644 --- a/release/sysinstall/installUpgrade.c +++ b/release/sysinstall/installUpgrade.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: installUpgrade.c,v 1.48 1997/04/28 10:31:14 jkh Exp $ + * $Id: installUpgrade.c,v 1.49 1997/05/09 07:44:19 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -45,6 +45,8 @@ #include <unistd.h> #include <sys/mount.h> +static int installUpgradeNonInteractive(dialogMenuItem *self); + typedef struct _hitList { enum { JUST_COPY, CALL_HANDLER } action ; char *name; @@ -153,6 +155,9 @@ installUpgrade(dialogMenuItem *self) char *saved_etc; Boolean extractingBin = TRUE; + if (variable_get(VAR_NONINTERACTIVE)) + return installUpgradeNonInteractive(self); + variable_set2(SYSTEM_STATE, "upgrade"); systemDisplayHelp("upgrade"); @@ -276,7 +281,7 @@ media: if (saved_etc) { msgNotify("Preserving /etc directory.."); - if (vsystem("tar -cf - -C /etc . | tar -xpf - -C %s", saved_etc)) + if (vsystem("tar -cBpf - -C /etc . | tar -xBpf - -C %s", saved_etc)) if (msgYesNo("Unable to backup your /etc into %s.\n" "Do you want to continue anyway?", saved_etc) != 0) return DITEM_FAILURE | DITEM_RESTORE; @@ -351,3 +356,134 @@ media: "the new system, just exit the installation."); return DITEM_SUCCESS | DITEM_REDRAW; } + +static int +installUpgradeNonInteractive(dialogMenuItem *self) +{ + char *saved_etc; + Boolean extractingBin = TRUE; + + variable_set2(SYSTEM_STATE, "upgrade"); + + /* Make sure at least BIN is selected */ + Dists |= DIST_BIN; + + if (RunningAsInit) { + Device **devs; + int i, cnt; + char *cp; + + cp = variable_get(VAR_DISK); + devs = deviceFind(cp, DEVICE_TYPE_DISK); + cnt = deviceCount(devs); + if (!cnt) { + msgConfirm("No disks found! Please verify that your disk controller is being\n" + "properly probed at boot time. See the Hardware Guide on the\n" + "Documentation menu for clues on diagnosing this type of problem."); + return DITEM_FAILURE; + } + else { + /* Enable all the drives befor we start */ + for (i = 0; i < cnt; i++) + devs[i]->enabled = TRUE; + } + + msgConfirm("OK. First, we're going to go to the disk label editor. In this editor\n" + "you will be expected to Mount any partitions you're interested in\n" + "upgrading. DO NOT set the Newfs flag to Y on anything in the label editor\n" + "unless you're absolutely sure you know what you're doing! In this\n" + "instance, you'll be using the label editor as little more than a fancy\n" + "screen-oriented partition mounting tool.\n\n" + "Once you're done in the label editor, press Q to return here for the next\n" + "step."); + + if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE) { + msgConfirm("The disk label editor returned an error status. Upgrade operation\n" + "aborted."); + return DITEM_FAILURE | DITEM_RESTORE; + } + + /* Don't write out MBR info */ + variable_set2(DISK_PARTITIONED, "written"); + if (DITEM_STATUS(diskLabelCommit(self)) == DITEM_FAILURE) { + msgConfirm("Not all file systems were properly mounted. Upgrade operation\n" + "aborted."); + variable_unset(DISK_PARTITIONED); + return DITEM_FAILURE | DITEM_RESTORE; + } + + if (extractingBin) { + msgNotify("chflags'ing old binaries - please wait."); + (void)vsystem("chflags -R noschg /mnt/"); + } + msgNotify("Updating /stand on root filesystem"); + (void)vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity()); + + if (DITEM_STATUS(chroot("/mnt")) == DITEM_FAILURE) { + msgConfirm("Unable to chroot to /mnt - something is wrong with the\n" + "root partition or the way it's mounted if this doesn't work."); + variable_unset(DISK_PARTITIONED); + return DITEM_FAILURE | DITEM_RESTORE; + } + chdir("/"); + systemCreateHoloshell(); + } + + if (!mediaVerify() || !mediaDevice->init(mediaDevice)) { + msgNotify("Upgrade: Couldn't initialize media."); + return DITEM_FAILURE | DITEM_RESTORE; + } + + saved_etc = "/usr/tmp/etc"; + Mkdir(saved_etc); + msgNotify("Preserving /etc directory.."); + if (vsystem("tar -cpBf - -C /etc . | tar -xpBf - -C %s", saved_etc)) { + msgNotify("Unable to backup your /etc into %s.", saved_etc); + return DITEM_FAILURE | DITEM_RESTORE; + } + + if (file_readable("/kernel")) { + msgNotify("Moving old kernel to /kernel.prev"); + system("chflags noschg /kernel && mv /kernel /kernel.prev"); + } + + msgNotify("Beginning extraction of distributions.."); + if (DITEM_STATUS(distExtractAll(self)) == DITEM_FAILURE) { + msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n" + "should be considered a failure and started from the beginning, sorry!\n" + "The system will reboot now."); + dialog_clear(); + systemShutdown(1); + } + else if (Dists) { + if (!(Dists & DIST_BIN)) { + msgNotify("The extraction process seems to have had some problems, but we got most\n" + "of the essentials. We'll treat this as a warning since it may have been\n" + "only non-essential distributions which failed to upgrade."); + } + else { + msgConfirm("Hmmmm. We couldn't even extract the bin distribution. This upgrade\n" + "should be considered a failure and started from the beginning, sorry!\n" + "The system will reboot now."); + dialog_clear(); + systemShutdown(1); + } + } + + msgNotify("OK, now it's time to go pound on your root a little bit to create all the\n" + "/dev entries and such that a new system expects to see. I'll also perform a\n" + "few \"fixup\" operations to repair the effects of splatting a bin distribution\n" + "on top of an existing system.."); + if (DITEM_STATUS(installFixup(self)) == DITEM_FAILURE) { + msgNotify("Hmmmmm. The fixups don't seem to have been very happy.\n" + "You may wish to examine the system a little more closely when\n" + "it comes time to merge your /etc customizations back."); + } + + msgNotify("First stage of upgrade completed successfully."); + if (vsystem("tar -cpBf - -C %s . | tar --unlink -xpBf - -C /etc", saved_etc)) { + msgNotify("Unable to resurrect your old /etc!"); + return DITEM_FAILURE | DITEM_RESTORE; + } + return DITEM_SUCCESS | DITEM_REDRAW; +} diff --git a/release/sysinstall/sysinstall.8 b/release/sysinstall/sysinstall.8 index 465c719..ba6064a 100644 --- a/release/sysinstall/sysinstall.8 +++ b/release/sysinstall/sysinstall.8 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $Id: sysinstall.8,v 1.2 1997/08/11 13:20:38 jkh Exp $ +.\" $Id: sysinstall.8,v 1.3 1997/08/18 21:10:26 jkh Exp $ .\" .Dd August 9, 1997 .Dt SYSINSTALL 8 @@ -608,6 +608,15 @@ Initialize all variables to their defaults, overriding any previous settings. .Pp \fBVariables:\fR None +.It loadConfig +Sort of like an #include statement, it allows you to load one +configuration file from another. +.Pp +\fBVariables:\fR +.Bl -tag -width indent +.It file +The fully pathname of the file to load. +.El .It mediaSetCDROM Select a FreeBSD CDROM as the installation media. .Pp diff --git a/release/sysinstall/tcpip.c b/release/sysinstall/tcpip.c index d0d2015..33c7f307 100644 --- a/release/sysinstall/tcpip.c +++ b/release/sysinstall/tcpip.c @@ -1,5 +1,5 @@ /* - * $Id: tcpip.c,v 1.68 1997/06/12 09:01:38 jkh Exp $ + * $Id: tcpip.c,v 1.69 1997/06/18 05:11:37 jkh Exp $ * * Copyright (c) 1995 * Gary J Palmer. All rights reserved. @@ -156,10 +156,6 @@ tcpOpenDialog(Device *devp) char *tmp; char title[80]; - if (!RunningAsInit) { - if (!msgYesNo("Running multi-user, assume that the network is already configured?")) - return DITEM_SUCCESS; - } /* Initialise vars from previous device values */ if (devp->private) { DevInfo *di = (DevInfo *)devp->private; @@ -346,9 +342,15 @@ tcpDeviceSelect(void) cnt = deviceCount(devs); rval = NULL; - if (!cnt) + if (!cnt) { msgConfirm("No network devices available!"); - else if (cnt == 1) { + return NULL; + } + else if (!RunningAsInit) { + if (!msgYesNo("Running multi-user, assume that the network is already configured?")) + return devs[0]; + } + if (cnt == 1) { if (DITEM_STATUS(tcpOpenDialog(devs[0]) == DITEM_SUCCESS)) rval = devs[0]; } |