diff options
author | jkh <jkh@FreeBSD.org> | 1995-05-29 11:01:42 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1995-05-29 11:01:42 +0000 |
commit | 4bc5a2dda3322237aff9d99c18e2080f78559ba4 (patch) | |
tree | f98b313f289088a0f9384387c68ec7516031cc7e | |
parent | 56df30b7c63bbeceb73f75bc2eb45c0e1c271e5e (diff) | |
download | FreeBSD-src-4bc5a2dda3322237aff9d99c18e2080f78559ba4.zip FreeBSD-src-4bc5a2dda3322237aff9d99c18e2080f78559ba4.tar.gz |
Sync up my work for the night. This should implement ALL possible
installation methods and provide a fairly robust set of menu options.
This should also fix a few more bugs on Poul-Henning's latest gripe
list.
50 files changed, 1005 insertions, 464 deletions
diff --git a/release/sysinstall/cdrom.c b/release/sysinstall/cdrom.c index 63831c0..b67406a 100644 --- a/release/sysinstall/cdrom.c +++ b/release/sysinstall/cdrom.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: cdrom.c,v 1.3 1995/05/28 03:04:46 jkh Exp $ + * $Id: cdrom.c,v 1.4 1995/05/28 07:05:21 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -72,6 +72,7 @@ mediaInitCDROM(Device *dev) if (Mkdir("/cdrom", NULL)) return FALSE; + bzero(&args, sizeof(args)); args.fspec = dev->devname; args.flags = 0; diff --git a/release/sysinstall/command.c b/release/sysinstall/command.c index 1728964..57f6213 100644 --- a/release/sysinstall/command.c +++ b/release/sysinstall/command.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: command.c,v 1.8 1995/05/19 21:30:32 jkh Exp $ + * $Id: command.c,v 1.9 1995/05/20 13:24:33 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -167,14 +167,16 @@ command_execute(void) if (commandStack[i]->cmds[j].type == CMD_SHELL) { msgNotify("Doing %s", commandStack[i]->cmds[j].ptr); ret = vsystem((char *)commandStack[i]->cmds[j].ptr); - msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret); + if (isDebug()) + msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret); } else { /* It's a function pointer - call it with the key and the data */ func = (commandFunc)commandStack[i]->cmds[j].ptr; msgNotify("%x: Execute(%s, %s)", func, commandStack[i]->key, commandStack[i]->cmds[j].data); ret = (*func)(commandStack[i]->key, commandStack[i]->cmds[j].data); - msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret); + if (isDebug()) + msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret); } } } diff --git a/release/sysinstall/config.c b/release/sysinstall/config.c index c791550..a51f996 100644 --- a/release/sysinstall/config.c +++ b/release/sysinstall/config.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: config.c,v 1.11 1995/05/28 09:31:29 jkh Exp $ + * $Id: config.c,v 1.12 1995/05/28 20:28:07 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -174,7 +174,7 @@ configFstab(void) } /* Go for the burn */ - msgDebug("Generating /etc/fstab file"); + msgDebug("Generating /etc/fstab file\n"); for (i = 0; i < nchunks; i++) { fprintf(fstab, "/dev/%s\t\t\t%s\t\t%s %s %d %d\n", nameof(chunk_list[i]), mount_point(chunk_list[i]), fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), @@ -351,7 +351,7 @@ configPackages(char *str) i = (pid == -1) ? -1 : WEXITSTATUS(pstat); } } - if (i != 0) + if (i != 0 && isDebug()) msgDebug("pkg_manage returns status of %d\n", i); return 0; } diff --git a/release/sysinstall/devices.c b/release/sysinstall/devices.c index 77dd090..48c10e4 100644 --- a/release/sysinstall/devices.c +++ b/release/sysinstall/devices.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: devices.c,v 1.32 1995/05/27 23:52:55 jkh Exp $ + * $Id: devices.c,v 1.33 1995/05/28 09:31:31 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -183,15 +183,28 @@ deviceGetAll(void) int i; for (i = 0; names[i]; i++) { + Chunk *c1; Disk *d; d = Open_Disk(names[i]); if (!d) msgFatal("Unable to open disk %s", names[i]); - (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, - mediaInitUFS, mediaGetUFS, NULL, deviceDiskFree, d); + (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, NULL, NULL, NULL, NULL, d); msgDebug("Found a device of type disk named: %s\n", names[i]); + + /* Look for existing DOS partitions to register */ + for (c1 = d->chunks->part; c1; c1 = c1->next) { + if (c1->type == fat) { + Device *dev; + + /* Got one! */ + dev = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DOS, TRUE, + mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL); + dev->private = c1; + msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name); + } + } } free(names); } diff --git a/release/sysinstall/dist.c b/release/sysinstall/dist.c index fe809bb..75ff6fa 100644 --- a/release/sysinstall/dist.c +++ b/release/sysinstall/dist.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: dist.c,v 1.30 1995/05/28 09:43:36 jkh Exp $ + * $Id: dist.c,v 1.31 1995/05/28 20:28:11 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -250,7 +250,8 @@ distExtract(char *parent, Distribution *me) snprintf(buf, 512, "%s/%s.tgz", path, dist); fd = (*mediaDevice->get)(buf); if (fd != -1) { - status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd); + msgNotify("Extracting %s into %s directory...", me[i].my_name, me[i].my_dir); + status = mediaExtractDist(me[i].my_dir, fd); if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); else @@ -260,14 +261,16 @@ distExtract(char *parent, Distribution *me) snprintf(buf, sizeof buf, "/stand/info/%s/%s.inf", path, dist); if (!access(buf, R_OK)) { - msgDebug("Parsing attributes file for %s\n", dist); + if (isDebug()) + msgDebug("Parsing attributes file for %s\n", dist); dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); if (attr_parse(&dist_attr, buf) == 0) { msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); return FALSE; } - msgDebug("Looking for attribute `pieces'\n"); + if (isDebug()) + msgDebug("Looking for attribute `pieces'\n"); tmp = attr_match(dist_attr, "pieces"); if (tmp) numchunks = atoi(tmp); @@ -277,7 +280,8 @@ distExtract(char *parent, Distribution *me) else numchunks = 0; - msgDebug("Attempting to extract distribution from %u chunks.\n", numchunks); + if (isDebug()) + msgDebug("Attempting to extract distribution from %u chunks.\n", numchunks); if (numchunks < 2 ) { snprintf(buf, 512, "%s/%s", path, dist); @@ -287,7 +291,8 @@ distExtract(char *parent, Distribution *me) if (fd == -1) { status = FALSE; } else { - status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd); + msgNotify("Extracting %s into %s directory...", me[i].my_name, me[i].my_dir); + status = mediaExtractDist(me[i].my_dir, fd); if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); else @@ -296,9 +301,11 @@ distExtract(char *parent, Distribution *me) goto done; } - mediaExtractDistBegin(dist, me[i].my_dir, &fd2, &zpid, &cpid); + mediaExtractDistBegin(me[i].my_dir, &fd2, &zpid, &cpid); + dialog_clear(); for (chunk = 0; chunk < numchunks; chunk++) { int n, retval; + char prompt[80]; snprintf(buf, 512, "%s/%s.%c%c", path, dist, (chunk / 26) + 'a', (chunk % 26) + 'a'); fd = (*mediaDevice->get)(buf); @@ -306,6 +313,8 @@ distExtract(char *parent, Distribution *me) msgConfirm("failed to retreive piece file %s!\nAborting the transfer", buf); goto punt; } + snprintf(prompt, 80, "Extracting %s into %s directory...", me[i].my_name, me[i].my_dir); + dialog_gauge(" Progress ", prompt, 8, 10, 10, 40, (numchunks / (chunk + 1))); while ((n = read(fd, buf, sizeof buf)) > 0) { retval = write(fd2, buf, n); if (retval != n) @@ -354,5 +363,6 @@ distExtract(char *parent, Distribution *me) void distExtractAll(void) { - distExtract(NULL, DistTable); + while (Dists) + distExtract(NULL, DistTable); } diff --git a/release/sysinstall/dos.c b/release/sysinstall/dos.c index 2204bae..9cf2cd3 100644 --- a/release/sysinstall/dos.c +++ b/release/sysinstall/dos.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: dos.c,v 1.2 1995/05/27 23:39:28 phk Exp $ + * $Id: dos.c,v 1.3 1995/05/28 03:04:54 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -69,6 +69,7 @@ mediaInitDOS(Device *dev) if (Mkdir("/dos", NULL)) return FALSE; + bzero(&args, sizeof(args)); args.fspec = dev->devname; args.uid = args.gid = 0; @@ -85,7 +86,10 @@ mediaGetDOS(char *file) { char buf[PATH_MAX]; - snprintf(buf, PATH_MAX, "/dos/%s", file); + snprintf(buf, PATH_MAX, "/dos/freebsd/%s", file); + if (!access(buf, R_OK)) + return open(buf, O_RDONLY); + snprintf(buf, PATH_MAX, "/dos/freebsd/dists/%s", file); return open(buf, O_RDONLY); } @@ -97,7 +101,8 @@ mediaShutdownDOS(Device *dev) msgDebug("Unmounting /dos\n"); if (unmount("/dos", 0) != 0) msgConfirm("Could not unmount the DOS partition: %s\n", strerror(errno)); - msgDebug("Unmount returned\n"); + if (isDebug()) + msgDebug("Unmount returned\n"); DOSMounted = FALSE; return; } diff --git a/release/sysinstall/floppy.c b/release/sysinstall/floppy.c index 229b630..865a635 100644 --- a/release/sysinstall/floppy.c +++ b/release/sysinstall/floppy.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: floppy.c,v 1.3 1995/05/28 03:04:56 jkh Exp $ + * $Id: floppy.c,v 1.4 1995/05/29 00:50:01 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -142,7 +142,6 @@ mediaGetFloppy(char *file) char buf[PATH_MAX]; snprintf(buf, PATH_MAX, "/mnt/%s", file); - return open(buf, O_RDONLY); } diff --git a/release/sysinstall/ftp.c b/release/sysinstall/ftp.c index 317e8a8..59060b6 100644 --- a/release/sysinstall/ftp.c +++ b/release/sysinstall/ftp.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: ftp.c,v 1.10 1995/05/26 19:28:01 jkh Exp $ + * $Id: ftp.c,v 1.11 1995/05/27 06:19:59 phk Exp $ * */ @@ -48,7 +48,8 @@ debug(FTP_t ftp, const char *fmt, ...) #ifdef STANDALONE_FTP write(ftp->fd_debug,p,strlen(p)); #else - msgDebug(p); + if (isDebug()) + msgDebug(p); #endif } diff --git a/release/sysinstall/ftp_strat.c b/release/sysinstall/ftp_strat.c index 19c4ac3..b6fa553 100644 --- a/release/sysinstall/ftp_strat.c +++ b/release/sysinstall/ftp_strat.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: ftp_strat.c,v 1.3 1995/05/27 21:18:07 jkh Exp $ + * $Id: ftp_strat.c,v 1.4 1995/05/27 23:39:30 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -84,13 +84,16 @@ mediaInitFTP(Device *dev) return FALSE; } strncpy(url, cp, BUFSIZ); - msgDebug("Using URL `%s'\n", url); + if (isDebug()) + msgDebug("Using URL `%s'\n", url); hostname = url + 6; if ((dir = index(hostname, '/')) != NULL) *(dir++) = '\0'; strcpy(dev->name, hostname); - msgDebug("hostname = `%s'\n", hostname); - msgDebug("dir = `%s'\n", dir ? dir : "/"); + if (isDebug()) { + msgDebug("hostname = `%s'\n", hostname); + msgDebug("dir = `%s'\n", dir ? dir : "/"); + } msgNotify("Looking up host %s..", hostname); if ((gethostbyname(hostname) == NULL) && (inet_addr(hostname) == INADDR_NONE)) { msgConfirm("Cannot resolve hostname `%s'! Are you sure your name server\nand/or gateway values are set properly?", hostname); @@ -98,7 +101,8 @@ mediaInitFTP(Device *dev) } snprintf(email, BUFSIZ, "installer@%s", my_name); - msgDebug("Using fake e-mail `%s'\n", email); + if (isDebug()) + msgDebug("Using fake e-mail `%s'\n", email); msgNotify("Logging in as anonymous."); if ((i = FtpOpen(ftp, hostname, "anonymous", email)) != 0) { @@ -113,7 +117,8 @@ mediaInitFTP(Device *dev) msgNotify("CD to distribution in ~ftp/%s", dir); FtpChdir(ftp, dir); } - msgDebug("leaving mediaInitFTP!\n"); + if (isDebug()) + msgDebug("leaving mediaInitFTP!\n"); ftpInitted = TRUE; return TRUE; } diff --git a/release/sysinstall/install.c b/release/sysinstall/install.c index 6f94a83..f501494 100644 --- a/release/sysinstall/install.c +++ b/release/sysinstall/install.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: install.c,v 1.65 1995/05/28 23:12:05 jkh Exp $ + * $Id: install.c,v 1.66 1995/05/29 00:50:02 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -254,6 +254,10 @@ installCommit(char *str) fclose(fp); hostsModified = TRUE; } + /* If there's no kernel but there is a kernel.GENERIC, link it over */ + if (access("/kernel", R_OK)) + vsystem("ln -f /kernel.GENERIC /kernel"); + msgConfirm("Installation completed successfully.\nHit return now to go back to the main menu."); SystemWasInstalled = TRUE; return 0; @@ -379,7 +383,7 @@ copy_self(void) msgConfirm("Copy returned error status of %d!", i); /* Copy the /etc files into their rightful place */ - (void)vsystem("(cd /stand; find etc) | cpio -pdmv /mnt"); + (void)vsystem("cd /mnt/stand; find etc | cpio -pdmv /mnt"); } static void loop_on_root_floppy(); @@ -391,7 +395,7 @@ root_extract(void) if (OnCDROM) { fd = open("/floppies/root.flp", O_RDONLY); - (void)mediaExtractDist("root.flp", "/", fd); + (void)mediaExtractDist("/", fd); return; } if (mediaDevice) { @@ -408,7 +412,7 @@ root_extract(void) fd = (*mediaDevice->get)("floppies/root.flp"); if (fd != -1) { msgNotify("Loading root floppy from %s", mediaDevice->name); - (void)mediaExtractDist("root.flp", "/", fd); + (void)mediaExtractDist("/", fd); if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); else @@ -416,12 +420,14 @@ root_extract(void) if (mediaDevice->shutdown) (*mediaDevice->shutdown)(mediaDevice); } else { + msgConfirm("Couldn't get root floppy image from %s\n, falling back to floppy.", mediaDevice->name); if (mediaDevice->shutdown) (*mediaDevice->shutdown)(mediaDevice); loop_on_root_floppy(); } break; + case DEVICE_TYPE_TAPE: case DEVICE_TYPE_FLOPPY: default: loop_on_root_floppy(); @@ -437,7 +443,11 @@ loop_on_root_floppy(void) { int fd; - fd = getRootFloppy(); - if (fd != -1) - mediaExtractDist("root.flp", "/", fd); + while (1) { + fd = getRootFloppy(); + if (fd != -1) { + mediaExtractDist("/", fd); + break; + } + } } diff --git a/release/sysinstall/media.c b/release/sysinstall/media.c index 17cce51..384e419 100644 --- a/release/sysinstall/media.c +++ b/release/sysinstall/media.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: media.c,v 1.20 1995/05/27 23:39:31 phk Exp $ + * $Id: media.c,v 1.21 1995/05/28 03:04:58 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -164,13 +164,15 @@ int mediaSetDOS(char *str) { Device **devs; - Disk *d; - Chunk *c1; - int i, cnt; + int cnt; devs = deviceFind(NULL, DEVICE_TYPE_DOS); cnt = deviceCount(devs); - if (cnt > 1) { + if (!cnt) { + msgConfirm("No DOS primary partitions found! This installation method is unavailable"); + return 0; + } + else if (cnt > 1) { DMenu *menu; menu = deviceCreateMenu(&MenuMediaDOS, DEVICE_TYPE_DOS, DOSHook); @@ -179,34 +181,8 @@ mediaSetDOS(char *str) dmenuOpenSimple(menu); free(menu); } - else if (cnt) { + else mediaDevice = devs[0]; - return 1; - } - else { - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("No disk devices found!"); - return 0; - } - /* Now go chewing through looking for a DOS FAT partition */ - for (i = 0; devs[i]; i++) { - d = (Disk *)devs[i]->private; - /* Now try to find a DOS partition */ - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->type == fat) { - /* Got one! */ - mediaDevice = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DOS, TRUE, - mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL); - mediaDevice->private = c1; - msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name); - break; - } - } - } - } - if (!mediaDevice) - msgConfirm("No DOS primary partitions found! This installation method is unavailable"); return mediaDevice ? 1 : 0; } @@ -280,25 +256,49 @@ mediaSetFTP(char *str) return 1; } -/* - * Return 0 if we successfully found and set the installation type to - * be some sort of mounted filesystem (it's also mounted at this point) - */ int -mediaSetFS(char *str) +mediaSetUFS(char *str) +{ + static Device ufsDevice; + char *val; + + val = msgGetInput(NULL, "Enter a fully qualified pathname for the directory\ncontaining the FreeBSD distribtion files:"); + if (!val) + return 0; + strcpy(ufsDevice.name, "ufs"); + ufsDevice.type = DEVICE_TYPE_UFS; + ufsDevice.get = mediaGetUFS; + ufsDevice.private = strdup(val); + mediaDevice = &ufsDevice; + return 1; +} + +int +mediaSetNFS(char *str) { - return 0; + static Device nfsDevice; + char *val; + + val = msgGetInput(NULL, "Please enter the full NFS file specification for the remote\nhost and directory containing the FreeBSD distribution files.\nThis should be in the format: hostname:/some/freebsd/dir"); + if (!val) + return 0; + strcpy(nfsDevice.name, "nfs"); + nfsDevice.type = DEVICE_TYPE_NFS; + nfsDevice.init = mediaInitNFS; + nfsDevice.get = mediaGetNFS; + nfsDevice.shutdown = mediaShutdownNFS; + nfsDevice.private = strdup(val); + mediaDevice = &nfsDevice; + return 1; } Boolean -mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpid) +mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpid) { int i, pfd[2],qfd[2]; if (!dir) dir = "/"; - msgWeHaveOutput("Extracting %s into %s directory..", distname, dir); - Mkdir(dir, NULL); chdir(dir); pipe(pfd); @@ -316,7 +316,8 @@ mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpid) close(qfd[1]); close(pfd[0]); i = execl("/stand/gunzip", "/stand/gunzip", 0); - msgDebug("/stand/gunzip command returns %d status\n", i); + if (isDebug()) + msgDebug("/stand/gunzip command returns %d status\n", i); exit(i); } *fd = qfd[1]; @@ -335,7 +336,8 @@ mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpid) dup2(1, 2); } i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0); - msgDebug("/stand/cpio command returns %d status\n", i); + if (isDebug()) + msgDebug("/stand/cpio command returns %d status\n", i); exit(i); } close(pfd[0]); @@ -351,13 +353,15 @@ mediaExtractDistEnd(int zpid, int cpid) i = waitpid(zpid, &j, 0); if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */ dialog_clear(); - msgDebug("wait for gunzip returned status of %d!\n", i); + if (isDebug()) + msgDebug("wait for gunzip returned status of %d!\n", i); return FALSE; } i = waitpid(cpid, &j, 0); if (i < 0 || WEXITSTATUS(j)) { dialog_clear(); - msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); + if (isDebug()) + msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); return FALSE; } return TRUE; @@ -365,13 +369,12 @@ mediaExtractDistEnd(int zpid, int cpid) Boolean -mediaExtractDist(char *distname, char *dir, int fd) +mediaExtractDist(char *dir, int fd) { int i, j, zpid, cpid, pfd[2]; if (!dir) dir = "/"; - msgWeHaveOutput("Extracting %s into %s directory..", distname, dir); Mkdir(dir, NULL); chdir(dir); @@ -388,7 +391,8 @@ mediaExtractDist(char *distname, char *dir, int fd) } close(pfd[0]); i = execl("/stand/gunzip", "/stand/gunzip", 0); - msgDebug("/stand/gunzip command returns %d status\n", i); + if (isDebug()) + msgDebug("/stand/gunzip command returns %d status\n", i); exit(i); } cpid = fork(); @@ -405,7 +409,8 @@ mediaExtractDist(char *distname, char *dir, int fd) dup2(1, 2); } i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0); - msgDebug("/stand/cpio command returns %d status\n", i); + if (isDebug()) + msgDebug("/stand/cpio command returns %d status\n", i); exit(i); } close(pfd[0]); @@ -414,13 +419,15 @@ mediaExtractDist(char *distname, char *dir, int fd) i = waitpid(zpid, &j, 0); if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */ dialog_clear(); - msgDebug("wait for gunzip returned status of %d!\n", i); + if (isDebug()) + msgDebug("wait for gunzip returned status of %d!\n", i); return FALSE; } i = waitpid(cpid, &j, 0); if (i < 0 || WEXITSTATUS(j)) { dialog_clear(); - msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); + if (isDebug()) + msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); return FALSE; } return TRUE; diff --git a/release/sysinstall/menus.c b/release/sysinstall/menus.c index 83b47c2..a2cd6c3 100644 --- a/release/sysinstall/menus.c +++ b/release/sysinstall/menus.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: menus.c,v 1.36 1995/05/28 23:12:07 jkh Exp $ + * $Id: menus.c,v 1.37 1995/05/29 01:43:17 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -302,12 +302,14 @@ method.", DMENU_CALL, mediaSetCDROM, 0, 0 }, { "DOS", "Install from a DOS partition", DMENU_CALL, mediaSetDOS, 0, 0 }, - { "File System", "Install from a UFS or NFS mounted distribution", - DMENU_CALL, mediaSetFS, 0, 0 }, + { "File System", "Install from a mounted filesystem", + DMENU_CALL, mediaSetUFS, 0, 0 }, { "Floppy", "Install from a floppy disk set", DMENU_CALL, mediaSetFloppy, 0, 0 }, { "FTP", "Install from an Internet FTP server", DMENU_CALL, mediaSetFTP, 0, 0 }, + { "NFS", "Install over NFS", + DMENU_CALL, mediaSetNFS, 0, 0 }, { "Tape", "Install from SCSI or QIC tape", DMENU_CALL, mediaSetTape, 0, 0 }, { NULL } }, @@ -642,7 +644,7 @@ When you're done, select Cancel", "Press F1 for more information on these options", "configure.hlp", { { "Add User", "Add users to the system", - DMENU_SYSTEM_COMMAND, "adduser", 0, 0 }, + DMENU_SYSTEM_COMMAND, "adduser -silent", 0, 0 }, { "Console", "Customize system console behavior", DMENU_SUBMENU, &MenuSyscons, 0, 0 }, { "Networking", "Configure additional network services", @@ -700,11 +702,11 @@ close to you to have your system time syncronized accordingly.", DMENU_SET_VARIABLE, "ntpdate=canon.inria.fr", 0, 0 }, { "Germany", "ntps1-{0,1,2}.uni-erlangen.de (GPS)", DMENU_SET_VARIABLE, "ntpdate=ntps1-0.uni-erlangen.de", 0, 0 }, - { "Germany", "ntps1-0.cs.tu-berlin.de (GPS)", + { "Germany #2", "ntps1-0.cs.tu-berlin.de (GPS)", DMENU_SET_VARIABLE, "ntpdate=ntps1-0.cs.tu-berlin.de", 0, 0 }, { "Japan", "clock.nc.fukuoka-u.ac.jp (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=clock.nc.fukuoka-u.ac.jp", 0, 0}, - { "Japan", "clock.tl.fukuoka-u.ac.jp (GPS clock)", + { "Japan #2", "clock.tl.fukuoka-u.ac.jp (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=clock.tl.fukuoka-u.ac.jp", 0, 0}, { "Netherlands", "ntp0.nl.net (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=ntp0.nl.net", 0, 0 }, @@ -716,20 +718,20 @@ close to you to have your system time syncronized accordingly.", DMENU_SET_VARIABLE, "ntpdate=swisstime.ethz.ch", 0, 0 }, { "U.S. East Coast", "bitsy.mit.edu (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=bitsy.mit.edu", 0, 0 }, - { "U.S. East Coast", "otc1.psu.edu (WWV clock)", + { "U.S. East Coast #2", "otc1.psu.edu (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=otc1.psu.edu", 0, 0 }, { "U.S. West Coast", "apple.com (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=apple.com", 0, 0 }, - { "U.S. West Coast", "clepsydra.dec.com (GOES clock)", + { "U.S. West Coast #2", "clepsydra.dec.com (GOES clock)", DMENU_SET_VARIABLE, "ntpdate=clepsydra.dec.com", 0, 0 }, - { "U.S. West Coast", "clock.llnl.gov (WWVB clock)", - DMENU_SET_VARIABLE, "ntpdate=clock.llnl.gov", 0, 0 }, + { "U.S. West Coast #3", "clock.llnl.gov (WWVB clock)", + DMENU_SET_VARIABLE, "ntpdate=clock.llnl.gov", 0, 0 }, { "U.S. Midwest", "ncar.ucar.edu (WWVB clock)", - DMENU_SET_VARIABLE, "ntpdate=ncar.ucar.edu", 0, 0 }, + DMENU_SET_VARIABLE, "ntpdate=ncar.ucar.edu", 0, 0 }, { "U.S. Pacific", "chantry.hawaii.net (WWV/H clock)", DMENU_SET_VARIABLE, "ntpdate=chantry.hawaii.net", 0, 0 }, { "U.S. Southwest", "shorty.chpc.utexas.edu (WWV clock)", - DMENU_SET_VARIABLE, "ntpdate=shorty.chpc.utexas.edu", 0, 0 }, + DMENU_SET_VARIABLE, "ntpdate=shorty.chpc.utexas.edu", 0, 0 }, { NULL } }, }; @@ -738,9 +740,9 @@ DMenu MenuSyscons = { "System Console Configuration", "The default system console driver for FreeBSD (syscons) has a\n\ number of configuration options which may be set according to\n\ -your preference. When you are done setting configuration options,\n\ -select Cancel.", - "Configure your screen saver settings", +your preference.\n\n\ +When you are done setting configuration options, select Cancel.", + "Configure your system console settings", NULL, { { "Keymap", "Choose an alternate keyboard map", DMENU_SUBMENU, &MenuSysconsKeymap, 0, 0 }, @@ -798,9 +800,9 @@ when held down.", NULL, { { "Slow", "Slow keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=slow", 0, 0 }, - { "Normal", "\"normal\" keyboard repeat rate", + { "Normal", "\"Normal\" keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=normal", 0, 0 }, - { "Fast", "fast keyboard repeat rate", + { "Fast", "Fast keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=fast", 0, 0 }, { "Default", "Use default keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=NO", 0, 0 }, @@ -818,11 +820,11 @@ probably enable one of these screen savers to prevent phosphor burn-in.", NULL, { { "blank", "Simply blank the screen", DMENU_SET_VARIABLE, "saver=star", 0, 0 }, - { "Green", "\"green\" power saving mode (if supported by monitor)", + { "Green", "\"Green\" power saving mode (if supported by monitor)", DMENU_SET_VARIABLE, "saver=snake", 0, 0 }, { "Snake", "Draw a FreeBSD \"snake\" on your screen", DMENU_SET_VARIABLE, "saver=snake", 0, 0 }, - { "Star", "\"twinkling stars\" effect", + { "Star", "A \"twinkling stars\" effect", DMENU_SET_VARIABLE, "saver=star", 0, 0 }, { "Timeout", "Set the screen saver timeout interval", DMENU_CALL, configSaverTimeout, 0, 0 }, diff --git a/release/sysinstall/misc.c b/release/sysinstall/misc.c index a2ab20f..f1b8066 100644 --- a/release/sysinstall/misc.c +++ b/release/sysinstall/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id: misc.c,v 1.8 1995/05/23 18:06:15 jkh Exp $ + * $Id: misc.c,v 1.9 1995/05/25 01:22:19 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -183,7 +183,8 @@ Mkdir(char *ipath, void *data) return 0; path = strdup(ipath); - msgDebug("mkdir(%s)\n", path); + if (isDebug()) + msgDebug("mkdir(%s)\n", path); p = path; if (p[0] == '/') /* Skip leading '/'. */ ++p; @@ -198,7 +199,8 @@ Mkdir(char *ipath, void *data) msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno)); return 1; } - msgDebug("mkdir(%s..)\n", path); + if (isDebug()) + msgDebug("mkdir(%s..)\n", path); if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { msgConfirm("Couldn't create directory %s: %s", path,strerror(errno)); return 1; @@ -231,7 +233,9 @@ Mount(char *mountp, void *dev) msgConfirm("Unable to make directory mountpoint for %s!", mountpoint); return 1; } - msgDebug("mount %s %s\n", device, mountpoint); + if (isDebug()) + msgDebug("mount %s %s\n", device, mountpoint); + bzero(&ufsargs, sizeof(ufsargs)); ufsargs.fspec = device; if (mount(MOUNT_UFS, mountpoint, 0, (caddr_t)&ufsargs) == -1) { msgConfirm("Error mounting %s on %s : %s\n", device, mountpoint, strerror(errno)); diff --git a/release/sysinstall/msg.c b/release/sysinstall/msg.c index e9b2ae6..5930d14 100644 --- a/release/sysinstall/msg.c +++ b/release/sysinstall/msg.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: msg.c,v 1.25 1995/05/29 00:50:04 jkh Exp $ + * $Id: msg.c,v 1.26 1995/05/29 01:43:18 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -49,6 +49,17 @@ #define VTY_STATLINE 24 #define TTY_STATLINE 23 +Boolean +isDebug(void) +{ + char *cp; + + cp = getenv("debug"); + if (cp && !strcmp(cp, "yes")) + return TRUE; + return FALSE; +} + /* Whack up an informational message on the status line, in stand-out */ void msgYap(char *fmt, ...) @@ -105,7 +116,8 @@ msgInfo(char *fmt, ...) move(OnVTY ? VTY_STATLINE : TTY_STATLINE, 79); refresh(); if (OnVTY) { - msgDebug("Information: `%s'\n", errstr); + if (isDebug()) + msgDebug("Information: `%s'\n", errstr); msgInfo(NULL); } free(errstr); @@ -130,7 +142,7 @@ msgWarn(char *fmt, ...) mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr); attrset(attrs); refresh(); - if (OnVTY) + if (OnVTY && isDebug()) msgDebug("Warning message `%s'\n", errstr); free(errstr); } @@ -154,7 +166,7 @@ msgError(char *fmt, ...) mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr); attrset(attrs); refresh(); - if (OnVTY) + if (OnVTY && isDebug()) msgDebug("Error message `%s'\n", errstr); free(errstr); } @@ -231,7 +243,8 @@ msgNotify(char *fmt, ...) va_end(args); use_helpline(NULL); use_helpfile(NULL); - msgDebug("Notify: %s\n", errstr); + if (isDebug()) + msgDebug("Notify: %s\n", errstr); dialog_clear(); dialog_msgbox("Information Dialog", errstr, -1, -1, 0); free(errstr); @@ -254,8 +267,8 @@ msgYesNo(char *fmt, ...) use_helpfile(NULL); w = dupwin(newscr); if (OnVTY) { + msgDebug("Switching back to VTY 0\n"); ioctl(0, VT_RELDISP, 1); /* Switch back */ - msgDebug("User decision requested (type ALT-F1)\n"); msgInfo(NULL); } ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1); diff --git a/release/sysinstall/network.c b/release/sysinstall/network.c index 83e849b..2258162 100644 --- a/release/sysinstall/network.c +++ b/release/sysinstall/network.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: network.c,v 1.3 1995/05/28 09:31:38 jkh Exp $ + * $Id: network.c,v 1.4 1995/05/29 01:43:20 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -47,6 +47,7 @@ #include "sysinstall.h" #include <sys/fcntl.h> +#include <sys/stat.h> static Boolean networkInitialized; static Boolean startPPP(Device *devp); @@ -68,8 +69,22 @@ mediaInitNetwork(Device *dev) return FALSE; } } - else - msgConfirm("Warning: SLIP is rather poorly supported in this revision\nof the installation due to the lack of a dialing utility.\nIf you can use PPP for this instead then you're much better\noff doing so, otherwise SLIP works fairly well for *hardwired*\nlinks. Use the shell on the 4TH screen (ALT-F4) to run slattach\nand otherwise set the link up, then hit return here to continue."); + else { + char *val; + char attach[256]; + + /* Cheesy slip attach */ + snprintf(attach, 256, "slattach -a -h -l -s 9600 %s", dev->devname); + val = msgGetInput(attach, "Warning: SLIP is rather poorly supported in this revision\nof the installation due to the lack of a dialing utility.\nIf you can use PPP for this instead then you're much better\noff doing so, otherwise SLIP works fairly well for *hardwired*\nlinks. Please edit the following slattach command for\ncorrectness (default here is VJ compression, Hardware flow-control,\nignore carrier and 9600 baud data rate) and hit return to execute it."); + if (!val) + return FALSE; + else if (!vsystem(attach)) + return TRUE; + else { + msgConfirm("slattach returned a bad status! Please verify that\nthe command is correct and try again."); + return FALSE; + } + } } else { char *cp, ifconfig[64]; diff --git a/release/sysinstall/nfs.c b/release/sysinstall/nfs.c index b9ab534..2ed22f6 100644 --- a/release/sysinstall/nfs.c +++ b/release/sysinstall/nfs.c @@ -1,21 +1,97 @@ +/* + * The new sysinstall program. + * + * This is probably the last attempt in the `sysinstall' line, the next + * generation being slated to essentially a complete rewrite. + * + * $Id: media.c,v 1.21 1995/05/28 03:04:58 jkh Exp $ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + #include "sysinstall.h" -#include <stdio.h> -#include <ctype.h> -#include <sys/stat.h> #include <sys/errno.h> -#include <sys/file.h> -#include <sys/types.h> -#include <sys/wait.h> +#include <sys/fcntl.h> +#include <sys/syslimits.h> #include <sys/param.h> -#include <sys/dkbad.h> -#include <sys/mman.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#include "ftp.h" - -#define NFS #include <sys/mount.h> -#undef NFS +Boolean NFSMounted; + +Boolean +mediaInitNFS(Device *dev) +{ + if (NFSMounted) + return TRUE; + + if (Mkdir("/nfs", NULL)) + return FALSE; + + if (!vsystem("mount_nfs %s %s %s /nfs", getenv("nfsSlowPC") ? "-r 1024 -w 1024" : "", + getenv("nfsServerSecure") ? "-P" : "", dev->private)) + return TRUE; + else { + msgConfirm("Error mounting %s on /nfs: %s (%u)\n", dev->private, strerror(errno), errno); + return FALSE; + } + NFSMounted = TRUE; + return TRUE; +} + +int +mediaGetNFS(char *file) +{ + char buf[PATH_MAX]; + + snprintf(buf, PATH_MAX, "/nfs/%s", file); + if (!access(buf, R_OK)) + return open(buf, O_RDONLY); + snprintf(buf, PATH_MAX, "/nfs/dists/%s", file); + return open(buf, O_RDONLY); +} + +void +mediaShutdownNFS(Device *dev) +{ + if (!NFSMounted) + return; + msgDebug("Unmounting /nfs\n"); + if (unmount("/nfs", 0) != 0) + msgConfirm("Could not unmount the NFS partition: %s\n", strerror(errno)); + if (isDebug()) + msgDebug("Unmount returned\n"); + NFSMounted = FALSE; + return; +} diff --git a/release/sysinstall/sysinstall.h b/release/sysinstall/sysinstall.h index a9466f0..42da9c4 100644 --- a/release/sysinstall/sysinstall.h +++ b/release/sysinstall/sysinstall.h @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: sysinstall.h,v 1.38 1995/05/28 03:05:03 jkh Exp $ + * $Id: sysinstall.h,v 1.39 1995/05/28 09:31:39 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -160,6 +160,8 @@ typedef enum { DEVICE_TYPE_CDROM, DEVICE_TYPE_TAPE, DEVICE_TYPE_DOS, + DEVICE_TYPE_UFS, + DEVICE_TYPE_NFS, DEVICE_TYPE_ANY, } DeviceType; @@ -378,10 +380,11 @@ extern int mediaSetFloppy(char *str); extern int mediaSetDOS(char *str); extern int mediaSetTape(char *str); extern int mediaSetFTP(char *str); -extern int mediaSetFS(char *str); +extern int mediaSetUFS(char *str); +extern int mediaSetNFS(char *str); extern Boolean mediaGetType(void); -extern Boolean mediaExtractDist(char *distname, char *dir, int fd); -extern Boolean mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpic); +extern Boolean mediaExtractDist(char *dir, int fd); +extern Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpic); extern Boolean mediaExtractDistEnd(int zpid, int cpid); extern Boolean mediaVerify(void); @@ -403,6 +406,7 @@ extern int Mount(char *, void *data); extern int Mount_DOS(char *, void *data); /* msg.c */ +extern Boolean isDebug(void); extern void msgInfo(char *fmt, ...); extern void msgYap(char *fmt, ...); extern void msgWarn(char *fmt, ...); @@ -420,6 +424,11 @@ extern Boolean mediaInitNetwork(Device *dev); extern void mediaShutdownNetwork(Device *dev); extern int configRoutedFlags(char *str); +/* nfs.c */ +extern Boolean mediaInitNFS(Device *dev); +extern int mediaGetNFS(char *file); +extern void mediaShutdownNFS(Device *dev); + /* system.c */ extern void systemInitialize(int argc, char **argv); extern void systemShutdown(void); @@ -448,6 +457,7 @@ extern int tcpDeviceSelect(char *str); extern int set_termcap(void); /* ufs.c */ +extern void mediaShutdownUFS(Device *dev); extern Boolean mediaInitUFS(Device *dev); extern int mediaGetUFS(char *file); diff --git a/release/sysinstall/system.c b/release/sysinstall/system.c index 6aaea42..2e55385 100644 --- a/release/sysinstall/system.c +++ b/release/sysinstall/system.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: system.c,v 1.40 1995/05/29 00:50:05 jkh Exp $ + * $Id: system.c,v 1.41 1995/05/29 02:13:31 phk Exp $ * * Jordan Hubbard * @@ -102,10 +102,8 @@ systemShutdown(void) } /* REALLY exit! */ if (RunningAsInit) { - int fd, on = 1; - /* Put the console back */ - ioctl(0, VT_RELDISP, 1); + ioctl(DebugFD, VT_RELDISP, 1); reboot(RB_HALT); } else @@ -187,7 +185,6 @@ systemDisplayFile(char *file) use_helpline(NULL); w = dupwin(newscr); dialog_textbox(file, fname, LINES, COLS); - unlink(fname); touchwin(w); wrefresh(w); delwin(w); @@ -199,24 +196,45 @@ char * systemHelpFile(char *file, char *buf) { char *cp; + static char oldfile[64]; /* Should be FILENAME_MAX but I don't feel like wasting that much space */ if (!file) return NULL; if ((cp = getenv("LANG")) != NULL) { snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); - vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s",buf); + if (oldfile[0]) { + if (!strcmp(buf, oldfile)) + return oldfile; + else { + unlink(oldfile); + oldfile[0] = '\0'; + } + } + vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s > /dev/null 2>&1",buf); snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); - if (file_readable(buf)) + if (file_readable(buf)) { + strcpy(oldfile, buf); return buf; + } } /* Fall back to normal imperialistic mode :-) */ cp = "en_US.ISO8859-1"; snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); - vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s",buf); + if (oldfile[0]) { + if (!strcmp(buf, oldfile)) + return oldfile; + else { + unlink(oldfile); + oldfile[0] = '\0'; + } + } + vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s > /dev/null 2>&1",buf); snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); - if (file_readable(buf)) + if (file_readable(buf)) { + strcpy(oldfile, buf); return buf; + } return NULL; } @@ -290,11 +308,14 @@ vsystem(char *fmt, ...) va_start(args, fmt); vsnprintf(cmd, FILENAME_MAX, fmt, args); va_end(args); + /* Find out if this command needs the wizardry of the shell */ for (p="<>|'`=\"()" ; *p; p++) - if (strchr(cmd,*p)) magic++; + if (strchr(cmd, *p)) + magic++; omask = sigblock(sigmask(SIGCHLD)); - msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic); + if (isDebug()) + msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic); switch(pid = fork()) { case -1: /* error */ (void)sigsetmask(omask); @@ -303,7 +324,7 @@ vsystem(char *fmt, ...) case 0: /* child */ (void)sigsetmask(omask); if (DebugFD != -1) { - if (OnVTY) + if (OnVTY && isDebug()) msgInfo("Command output is on debugging screen - type ALT-F2 to see it"); dup2(DebugFD, 0); dup2(DebugFD, 1); @@ -311,29 +332,29 @@ vsystem(char *fmt, ...) } #ifdef NOT_A_GOOD_IDEA_CRUNCHED_BINARY if (magic) { - char *argv[100]; - i = 0; - argv[i++] = "crunch"; - argv[i++] = "sh"; - argv[i++] = "-c"; - argv[i++] = cmd; - argv[i] = 0; - exit(crunched_main(i,argv)); + char *argv[100]; + i = 0; + argv[i++] = "crunch"; + argv[i++] = "sh"; + argv[i++] = "-c"; + argv[i++] = cmd; + argv[i] = 0; + exit(crunched_main(i,argv)); } else { - char *argv[100]; - i = 0; - argv[i++] = "crunch"; - while (cmd && *cmd) { - argv[i] = strsep(&cmd," \t"); - if (*argv[i]) - i++; - } - argv[i] = 0; - if (crunched_here(argv[1])) - exit(crunched_main(i,argv)); - else - execvp(argv[1],argv+1); - kill(getpid(),9); + char *argv[100]; + i = 0; + argv[i++] = "crunch"; + while (cmd && *cmd) { + argv[i] = strsep(&cmd," \t"); + if (*argv[i]) + i++; + } + argv[i] = 0; + if (crunched_here(argv[1])) + exit(crunched_main(i,argv)); + else + execvp(argv[1],argv+1); + kill(getpid(),9); } #else /* !CRUNCHED_BINARY */ execl("/stand/sh", "sh", "-c", cmd, (char *)NULL); @@ -347,7 +368,8 @@ vsystem(char *fmt, ...) (void)signal(SIGINT, intsave); (void)signal(SIGQUIT, quitsave); i = (pid == -1) ? -1 : WEXITSTATUS(pstat); - msgDebug("Command `%s' returns status of %d\n", cmd, i); + if (isDebug()) + msgDebug("Command `%s' returns status of %d\n", cmd, i); free(cmd); return i; } diff --git a/release/sysinstall/tape.c b/release/sysinstall/tape.c index 48088a7..ac288b5 100644 --- a/release/sysinstall/tape.c +++ b/release/sysinstall/tape.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: tape.c,v 1.2 1995/05/27 23:39:33 phk Exp $ + * $Id: tape.c,v 1.3 1995/05/28 03:05:04 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -46,21 +46,59 @@ /* These routines deal with getting things off of tape media */ #include "sysinstall.h" +#include <sys/fcntl.h> +#include <sys/param.h> + +static Boolean tapeInitted; Boolean mediaInitTape(Device *dev) { - return TRUE; + int i; + + if (tapeInitted) + return TRUE; + + Mkdir("/usr/tmp/tape", NULL); + if (chdir("/usr/tmp/tape")) { + Mkdir("/var/tmp/tape", NULL); + if (chdir("/var/tmp/tape")) + return FALSE; + } + msgConfirm("Insert tape into %s and press return", dev->description); + if (!strcmp(dev->name, "ft0")) + i = vsystem("ft | tar xvf -"); + else + i = vsystem("tar xvf %s", dev->devname); + if (!i) { + tapeInitted = TRUE; + return TRUE; + } + else + msgConfirm("Tape extract command failed with status %d!", i); + return FALSE; } int mediaGetTape(char *file) { - return -1; + char buf[PATH_MAX]; + + sprintf(buf, "/usr/tmp/tape/%s", file); + if (!access(buf, R_OK)) + return open(buf, O_RDONLY); + sprintf(buf, "/var/tmp/tape/%s", file); + return open(buf, O_RDONLY); } void mediaShutdownTape(Device *dev) { - return; + if (!tapeInitted) + return; + if (!access("/usr/tmp/tape", X_OK)) + (void)vsystem("rm -rf /usr/tmp/tape"); + else if (!access("/var/tmp/tape", X_OK)) + (void)vsystem("rm -rf /var/tmp/tape"); + tapeInitted = FALSE; } diff --git a/release/sysinstall/tcpip.c b/release/sysinstall/tcpip.c index 04166c7..13dcdbc 100644 --- a/release/sysinstall/tcpip.c +++ b/release/sysinstall/tcpip.c @@ -1,5 +1,5 @@ /* - * $Id: tcpip.c,v 1.25 1995/05/28 09:31:44 jkh Exp $ + * $Id: tcpip.c,v 1.26 1995/05/28 23:12:09 jkh Exp $ * * Copyright (c) 1995 * Gary J Palmer. All rights reserved. @@ -196,12 +196,12 @@ tcpOpenDialog(Device *devp) /* Setup a nice screen for us to splat stuff onto */ draw_box(ds_win, TCP_DIALOG_Y, TCP_DIALOG_X, TCP_DIALOG_HEIGHT, TCP_DIALOG_WIDTH, dialog_attr, border_attr); wattrset(ds_win, dialog_attr); - sprintf(title, " Interface %s ", devp->name); - mvwaddstr(ds_win, TCP_DIALOG_Y, TCP_DIALOG_X + 22, title); + mvwaddstr(ds_win, TCP_DIALOG_Y, TCP_DIALOG_X + 15, " Network Configuration "); draw_box(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 8, TCP_DIALOG_HEIGHT - 13, TCP_DIALOG_WIDTH - 17, dialog_attr, border_attr); wattrset(ds_win, dialog_attr); - mvwaddstr(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 16, " Per Interface Configuration "); + sprintf(title, " Configuration for Interface %s ", devp->name); + mvwaddstr(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 14, title); /* Initialise vars from previous device values */ if (devp->private) { diff --git a/release/sysinstall/ufs.c b/release/sysinstall/ufs.c index 1fd9d4e..55a2701 100644 --- a/release/sysinstall/ufs.c +++ b/release/sysinstall/ufs.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: ufs.c,v 1.1 1995/05/27 10:39:04 jkh Exp $ + * $Id: ufs.c,v 1.2 1995/05/27 23:39:35 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -44,17 +44,19 @@ */ #include "sysinstall.h" +#include <sys/fcntl.h> +#include <sys/param.h> -Boolean -mediaInitUFS(Device *dev) -{ - return TRUE; -} +/* No init or shutdown routines necessary - all done in mediaSetUFS() */ int mediaGetUFS(char *file) { - return -1; -} + char buf[PATH_MAX]; -/* UFS has no Shutdown routine since this is handled at the device level */ + snprintf(buf, PATH_MAX, "%s/%s", (char *)mediaDevice->private, file); + if (!access(buf, R_OK)) + return open(buf, O_RDONLY); + snprintf(buf, PATH_MAX, "%s/dists/%s", (char *)mediaDevice->private, file); + return open(buf, O_RDONLY); +} diff --git a/usr.sbin/sade/command.c b/usr.sbin/sade/command.c index 1728964..57f6213 100644 --- a/usr.sbin/sade/command.c +++ b/usr.sbin/sade/command.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: command.c,v 1.8 1995/05/19 21:30:32 jkh Exp $ + * $Id: command.c,v 1.9 1995/05/20 13:24:33 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -167,14 +167,16 @@ command_execute(void) if (commandStack[i]->cmds[j].type == CMD_SHELL) { msgNotify("Doing %s", commandStack[i]->cmds[j].ptr); ret = vsystem((char *)commandStack[i]->cmds[j].ptr); - msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret); + if (isDebug()) + msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret); } else { /* It's a function pointer - call it with the key and the data */ func = (commandFunc)commandStack[i]->cmds[j].ptr; msgNotify("%x: Execute(%s, %s)", func, commandStack[i]->key, commandStack[i]->cmds[j].data); ret = (*func)(commandStack[i]->key, commandStack[i]->cmds[j].data); - msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret); + if (isDebug()) + msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret); } } } diff --git a/usr.sbin/sade/config.c b/usr.sbin/sade/config.c index c791550..a51f996 100644 --- a/usr.sbin/sade/config.c +++ b/usr.sbin/sade/config.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: config.c,v 1.11 1995/05/28 09:31:29 jkh Exp $ + * $Id: config.c,v 1.12 1995/05/28 20:28:07 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -174,7 +174,7 @@ configFstab(void) } /* Go for the burn */ - msgDebug("Generating /etc/fstab file"); + msgDebug("Generating /etc/fstab file\n"); for (i = 0; i < nchunks; i++) { fprintf(fstab, "/dev/%s\t\t\t%s\t\t%s %s %d %d\n", nameof(chunk_list[i]), mount_point(chunk_list[i]), fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), @@ -351,7 +351,7 @@ configPackages(char *str) i = (pid == -1) ? -1 : WEXITSTATUS(pstat); } } - if (i != 0) + if (i != 0 && isDebug()) msgDebug("pkg_manage returns status of %d\n", i); return 0; } diff --git a/usr.sbin/sade/devices.c b/usr.sbin/sade/devices.c index 77dd090..48c10e4 100644 --- a/usr.sbin/sade/devices.c +++ b/usr.sbin/sade/devices.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: devices.c,v 1.32 1995/05/27 23:52:55 jkh Exp $ + * $Id: devices.c,v 1.33 1995/05/28 09:31:31 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -183,15 +183,28 @@ deviceGetAll(void) int i; for (i = 0; names[i]; i++) { + Chunk *c1; Disk *d; d = Open_Disk(names[i]); if (!d) msgFatal("Unable to open disk %s", names[i]); - (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, - mediaInitUFS, mediaGetUFS, NULL, deviceDiskFree, d); + (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, NULL, NULL, NULL, NULL, d); msgDebug("Found a device of type disk named: %s\n", names[i]); + + /* Look for existing DOS partitions to register */ + for (c1 = d->chunks->part; c1; c1 = c1->next) { + if (c1->type == fat) { + Device *dev; + + /* Got one! */ + dev = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DOS, TRUE, + mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL); + dev->private = c1; + msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name); + } + } } free(names); } diff --git a/usr.sbin/sade/install.c b/usr.sbin/sade/install.c index 6f94a83..f501494 100644 --- a/usr.sbin/sade/install.c +++ b/usr.sbin/sade/install.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: install.c,v 1.65 1995/05/28 23:12:05 jkh Exp $ + * $Id: install.c,v 1.66 1995/05/29 00:50:02 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -254,6 +254,10 @@ installCommit(char *str) fclose(fp); hostsModified = TRUE; } + /* If there's no kernel but there is a kernel.GENERIC, link it over */ + if (access("/kernel", R_OK)) + vsystem("ln -f /kernel.GENERIC /kernel"); + msgConfirm("Installation completed successfully.\nHit return now to go back to the main menu."); SystemWasInstalled = TRUE; return 0; @@ -379,7 +383,7 @@ copy_self(void) msgConfirm("Copy returned error status of %d!", i); /* Copy the /etc files into their rightful place */ - (void)vsystem("(cd /stand; find etc) | cpio -pdmv /mnt"); + (void)vsystem("cd /mnt/stand; find etc | cpio -pdmv /mnt"); } static void loop_on_root_floppy(); @@ -391,7 +395,7 @@ root_extract(void) if (OnCDROM) { fd = open("/floppies/root.flp", O_RDONLY); - (void)mediaExtractDist("root.flp", "/", fd); + (void)mediaExtractDist("/", fd); return; } if (mediaDevice) { @@ -408,7 +412,7 @@ root_extract(void) fd = (*mediaDevice->get)("floppies/root.flp"); if (fd != -1) { msgNotify("Loading root floppy from %s", mediaDevice->name); - (void)mediaExtractDist("root.flp", "/", fd); + (void)mediaExtractDist("/", fd); if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); else @@ -416,12 +420,14 @@ root_extract(void) if (mediaDevice->shutdown) (*mediaDevice->shutdown)(mediaDevice); } else { + msgConfirm("Couldn't get root floppy image from %s\n, falling back to floppy.", mediaDevice->name); if (mediaDevice->shutdown) (*mediaDevice->shutdown)(mediaDevice); loop_on_root_floppy(); } break; + case DEVICE_TYPE_TAPE: case DEVICE_TYPE_FLOPPY: default: loop_on_root_floppy(); @@ -437,7 +443,11 @@ loop_on_root_floppy(void) { int fd; - fd = getRootFloppy(); - if (fd != -1) - mediaExtractDist("root.flp", "/", fd); + while (1) { + fd = getRootFloppy(); + if (fd != -1) { + mediaExtractDist("/", fd); + break; + } + } } diff --git a/usr.sbin/sade/menus.c b/usr.sbin/sade/menus.c index 83b47c2..a2cd6c3 100644 --- a/usr.sbin/sade/menus.c +++ b/usr.sbin/sade/menus.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: menus.c,v 1.36 1995/05/28 23:12:07 jkh Exp $ + * $Id: menus.c,v 1.37 1995/05/29 01:43:17 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -302,12 +302,14 @@ method.", DMENU_CALL, mediaSetCDROM, 0, 0 }, { "DOS", "Install from a DOS partition", DMENU_CALL, mediaSetDOS, 0, 0 }, - { "File System", "Install from a UFS or NFS mounted distribution", - DMENU_CALL, mediaSetFS, 0, 0 }, + { "File System", "Install from a mounted filesystem", + DMENU_CALL, mediaSetUFS, 0, 0 }, { "Floppy", "Install from a floppy disk set", DMENU_CALL, mediaSetFloppy, 0, 0 }, { "FTP", "Install from an Internet FTP server", DMENU_CALL, mediaSetFTP, 0, 0 }, + { "NFS", "Install over NFS", + DMENU_CALL, mediaSetNFS, 0, 0 }, { "Tape", "Install from SCSI or QIC tape", DMENU_CALL, mediaSetTape, 0, 0 }, { NULL } }, @@ -642,7 +644,7 @@ When you're done, select Cancel", "Press F1 for more information on these options", "configure.hlp", { { "Add User", "Add users to the system", - DMENU_SYSTEM_COMMAND, "adduser", 0, 0 }, + DMENU_SYSTEM_COMMAND, "adduser -silent", 0, 0 }, { "Console", "Customize system console behavior", DMENU_SUBMENU, &MenuSyscons, 0, 0 }, { "Networking", "Configure additional network services", @@ -700,11 +702,11 @@ close to you to have your system time syncronized accordingly.", DMENU_SET_VARIABLE, "ntpdate=canon.inria.fr", 0, 0 }, { "Germany", "ntps1-{0,1,2}.uni-erlangen.de (GPS)", DMENU_SET_VARIABLE, "ntpdate=ntps1-0.uni-erlangen.de", 0, 0 }, - { "Germany", "ntps1-0.cs.tu-berlin.de (GPS)", + { "Germany #2", "ntps1-0.cs.tu-berlin.de (GPS)", DMENU_SET_VARIABLE, "ntpdate=ntps1-0.cs.tu-berlin.de", 0, 0 }, { "Japan", "clock.nc.fukuoka-u.ac.jp (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=clock.nc.fukuoka-u.ac.jp", 0, 0}, - { "Japan", "clock.tl.fukuoka-u.ac.jp (GPS clock)", + { "Japan #2", "clock.tl.fukuoka-u.ac.jp (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=clock.tl.fukuoka-u.ac.jp", 0, 0}, { "Netherlands", "ntp0.nl.net (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=ntp0.nl.net", 0, 0 }, @@ -716,20 +718,20 @@ close to you to have your system time syncronized accordingly.", DMENU_SET_VARIABLE, "ntpdate=swisstime.ethz.ch", 0, 0 }, { "U.S. East Coast", "bitsy.mit.edu (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=bitsy.mit.edu", 0, 0 }, - { "U.S. East Coast", "otc1.psu.edu (WWV clock)", + { "U.S. East Coast #2", "otc1.psu.edu (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=otc1.psu.edu", 0, 0 }, { "U.S. West Coast", "apple.com (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=apple.com", 0, 0 }, - { "U.S. West Coast", "clepsydra.dec.com (GOES clock)", + { "U.S. West Coast #2", "clepsydra.dec.com (GOES clock)", DMENU_SET_VARIABLE, "ntpdate=clepsydra.dec.com", 0, 0 }, - { "U.S. West Coast", "clock.llnl.gov (WWVB clock)", - DMENU_SET_VARIABLE, "ntpdate=clock.llnl.gov", 0, 0 }, + { "U.S. West Coast #3", "clock.llnl.gov (WWVB clock)", + DMENU_SET_VARIABLE, "ntpdate=clock.llnl.gov", 0, 0 }, { "U.S. Midwest", "ncar.ucar.edu (WWVB clock)", - DMENU_SET_VARIABLE, "ntpdate=ncar.ucar.edu", 0, 0 }, + DMENU_SET_VARIABLE, "ntpdate=ncar.ucar.edu", 0, 0 }, { "U.S. Pacific", "chantry.hawaii.net (WWV/H clock)", DMENU_SET_VARIABLE, "ntpdate=chantry.hawaii.net", 0, 0 }, { "U.S. Southwest", "shorty.chpc.utexas.edu (WWV clock)", - DMENU_SET_VARIABLE, "ntpdate=shorty.chpc.utexas.edu", 0, 0 }, + DMENU_SET_VARIABLE, "ntpdate=shorty.chpc.utexas.edu", 0, 0 }, { NULL } }, }; @@ -738,9 +740,9 @@ DMenu MenuSyscons = { "System Console Configuration", "The default system console driver for FreeBSD (syscons) has a\n\ number of configuration options which may be set according to\n\ -your preference. When you are done setting configuration options,\n\ -select Cancel.", - "Configure your screen saver settings", +your preference.\n\n\ +When you are done setting configuration options, select Cancel.", + "Configure your system console settings", NULL, { { "Keymap", "Choose an alternate keyboard map", DMENU_SUBMENU, &MenuSysconsKeymap, 0, 0 }, @@ -798,9 +800,9 @@ when held down.", NULL, { { "Slow", "Slow keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=slow", 0, 0 }, - { "Normal", "\"normal\" keyboard repeat rate", + { "Normal", "\"Normal\" keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=normal", 0, 0 }, - { "Fast", "fast keyboard repeat rate", + { "Fast", "Fast keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=fast", 0, 0 }, { "Default", "Use default keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=NO", 0, 0 }, @@ -818,11 +820,11 @@ probably enable one of these screen savers to prevent phosphor burn-in.", NULL, { { "blank", "Simply blank the screen", DMENU_SET_VARIABLE, "saver=star", 0, 0 }, - { "Green", "\"green\" power saving mode (if supported by monitor)", + { "Green", "\"Green\" power saving mode (if supported by monitor)", DMENU_SET_VARIABLE, "saver=snake", 0, 0 }, { "Snake", "Draw a FreeBSD \"snake\" on your screen", DMENU_SET_VARIABLE, "saver=snake", 0, 0 }, - { "Star", "\"twinkling stars\" effect", + { "Star", "A \"twinkling stars\" effect", DMENU_SET_VARIABLE, "saver=star", 0, 0 }, { "Timeout", "Set the screen saver timeout interval", DMENU_CALL, configSaverTimeout, 0, 0 }, diff --git a/usr.sbin/sade/misc.c b/usr.sbin/sade/misc.c index a2ab20f..f1b8066 100644 --- a/usr.sbin/sade/misc.c +++ b/usr.sbin/sade/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id: misc.c,v 1.8 1995/05/23 18:06:15 jkh Exp $ + * $Id: misc.c,v 1.9 1995/05/25 01:22:19 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -183,7 +183,8 @@ Mkdir(char *ipath, void *data) return 0; path = strdup(ipath); - msgDebug("mkdir(%s)\n", path); + if (isDebug()) + msgDebug("mkdir(%s)\n", path); p = path; if (p[0] == '/') /* Skip leading '/'. */ ++p; @@ -198,7 +199,8 @@ Mkdir(char *ipath, void *data) msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno)); return 1; } - msgDebug("mkdir(%s..)\n", path); + if (isDebug()) + msgDebug("mkdir(%s..)\n", path); if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { msgConfirm("Couldn't create directory %s: %s", path,strerror(errno)); return 1; @@ -231,7 +233,9 @@ Mount(char *mountp, void *dev) msgConfirm("Unable to make directory mountpoint for %s!", mountpoint); return 1; } - msgDebug("mount %s %s\n", device, mountpoint); + if (isDebug()) + msgDebug("mount %s %s\n", device, mountpoint); + bzero(&ufsargs, sizeof(ufsargs)); ufsargs.fspec = device; if (mount(MOUNT_UFS, mountpoint, 0, (caddr_t)&ufsargs) == -1) { msgConfirm("Error mounting %s on %s : %s\n", device, mountpoint, strerror(errno)); diff --git a/usr.sbin/sade/msg.c b/usr.sbin/sade/msg.c index e9b2ae6..5930d14 100644 --- a/usr.sbin/sade/msg.c +++ b/usr.sbin/sade/msg.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: msg.c,v 1.25 1995/05/29 00:50:04 jkh Exp $ + * $Id: msg.c,v 1.26 1995/05/29 01:43:18 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -49,6 +49,17 @@ #define VTY_STATLINE 24 #define TTY_STATLINE 23 +Boolean +isDebug(void) +{ + char *cp; + + cp = getenv("debug"); + if (cp && !strcmp(cp, "yes")) + return TRUE; + return FALSE; +} + /* Whack up an informational message on the status line, in stand-out */ void msgYap(char *fmt, ...) @@ -105,7 +116,8 @@ msgInfo(char *fmt, ...) move(OnVTY ? VTY_STATLINE : TTY_STATLINE, 79); refresh(); if (OnVTY) { - msgDebug("Information: `%s'\n", errstr); + if (isDebug()) + msgDebug("Information: `%s'\n", errstr); msgInfo(NULL); } free(errstr); @@ -130,7 +142,7 @@ msgWarn(char *fmt, ...) mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr); attrset(attrs); refresh(); - if (OnVTY) + if (OnVTY && isDebug()) msgDebug("Warning message `%s'\n", errstr); free(errstr); } @@ -154,7 +166,7 @@ msgError(char *fmt, ...) mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr); attrset(attrs); refresh(); - if (OnVTY) + if (OnVTY && isDebug()) msgDebug("Error message `%s'\n", errstr); free(errstr); } @@ -231,7 +243,8 @@ msgNotify(char *fmt, ...) va_end(args); use_helpline(NULL); use_helpfile(NULL); - msgDebug("Notify: %s\n", errstr); + if (isDebug()) + msgDebug("Notify: %s\n", errstr); dialog_clear(); dialog_msgbox("Information Dialog", errstr, -1, -1, 0); free(errstr); @@ -254,8 +267,8 @@ msgYesNo(char *fmt, ...) use_helpfile(NULL); w = dupwin(newscr); if (OnVTY) { + msgDebug("Switching back to VTY 0\n"); ioctl(0, VT_RELDISP, 1); /* Switch back */ - msgDebug("User decision requested (type ALT-F1)\n"); msgInfo(NULL); } ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1); diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index a9466f0..42da9c4 100644 --- a/usr.sbin/sade/sade.h +++ b/usr.sbin/sade/sade.h @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: sysinstall.h,v 1.38 1995/05/28 03:05:03 jkh Exp $ + * $Id: sysinstall.h,v 1.39 1995/05/28 09:31:39 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -160,6 +160,8 @@ typedef enum { DEVICE_TYPE_CDROM, DEVICE_TYPE_TAPE, DEVICE_TYPE_DOS, + DEVICE_TYPE_UFS, + DEVICE_TYPE_NFS, DEVICE_TYPE_ANY, } DeviceType; @@ -378,10 +380,11 @@ extern int mediaSetFloppy(char *str); extern int mediaSetDOS(char *str); extern int mediaSetTape(char *str); extern int mediaSetFTP(char *str); -extern int mediaSetFS(char *str); +extern int mediaSetUFS(char *str); +extern int mediaSetNFS(char *str); extern Boolean mediaGetType(void); -extern Boolean mediaExtractDist(char *distname, char *dir, int fd); -extern Boolean mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpic); +extern Boolean mediaExtractDist(char *dir, int fd); +extern Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpic); extern Boolean mediaExtractDistEnd(int zpid, int cpid); extern Boolean mediaVerify(void); @@ -403,6 +406,7 @@ extern int Mount(char *, void *data); extern int Mount_DOS(char *, void *data); /* msg.c */ +extern Boolean isDebug(void); extern void msgInfo(char *fmt, ...); extern void msgYap(char *fmt, ...); extern void msgWarn(char *fmt, ...); @@ -420,6 +424,11 @@ extern Boolean mediaInitNetwork(Device *dev); extern void mediaShutdownNetwork(Device *dev); extern int configRoutedFlags(char *str); +/* nfs.c */ +extern Boolean mediaInitNFS(Device *dev); +extern int mediaGetNFS(char *file); +extern void mediaShutdownNFS(Device *dev); + /* system.c */ extern void systemInitialize(int argc, char **argv); extern void systemShutdown(void); @@ -448,6 +457,7 @@ extern int tcpDeviceSelect(char *str); extern int set_termcap(void); /* ufs.c */ +extern void mediaShutdownUFS(Device *dev); extern Boolean mediaInitUFS(Device *dev); extern int mediaGetUFS(char *file); diff --git a/usr.sbin/sade/system.c b/usr.sbin/sade/system.c index 6aaea42..2e55385 100644 --- a/usr.sbin/sade/system.c +++ b/usr.sbin/sade/system.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: system.c,v 1.40 1995/05/29 00:50:05 jkh Exp $ + * $Id: system.c,v 1.41 1995/05/29 02:13:31 phk Exp $ * * Jordan Hubbard * @@ -102,10 +102,8 @@ systemShutdown(void) } /* REALLY exit! */ if (RunningAsInit) { - int fd, on = 1; - /* Put the console back */ - ioctl(0, VT_RELDISP, 1); + ioctl(DebugFD, VT_RELDISP, 1); reboot(RB_HALT); } else @@ -187,7 +185,6 @@ systemDisplayFile(char *file) use_helpline(NULL); w = dupwin(newscr); dialog_textbox(file, fname, LINES, COLS); - unlink(fname); touchwin(w); wrefresh(w); delwin(w); @@ -199,24 +196,45 @@ char * systemHelpFile(char *file, char *buf) { char *cp; + static char oldfile[64]; /* Should be FILENAME_MAX but I don't feel like wasting that much space */ if (!file) return NULL; if ((cp = getenv("LANG")) != NULL) { snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); - vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s",buf); + if (oldfile[0]) { + if (!strcmp(buf, oldfile)) + return oldfile; + else { + unlink(oldfile); + oldfile[0] = '\0'; + } + } + vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s > /dev/null 2>&1",buf); snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); - if (file_readable(buf)) + if (file_readable(buf)) { + strcpy(oldfile, buf); return buf; + } } /* Fall back to normal imperialistic mode :-) */ cp = "en_US.ISO8859-1"; snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); - vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s",buf); + if (oldfile[0]) { + if (!strcmp(buf, oldfile)) + return oldfile; + else { + unlink(oldfile); + oldfile[0] = '\0'; + } + } + vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s > /dev/null 2>&1",buf); snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); - if (file_readable(buf)) + if (file_readable(buf)) { + strcpy(oldfile, buf); return buf; + } return NULL; } @@ -290,11 +308,14 @@ vsystem(char *fmt, ...) va_start(args, fmt); vsnprintf(cmd, FILENAME_MAX, fmt, args); va_end(args); + /* Find out if this command needs the wizardry of the shell */ for (p="<>|'`=\"()" ; *p; p++) - if (strchr(cmd,*p)) magic++; + if (strchr(cmd, *p)) + magic++; omask = sigblock(sigmask(SIGCHLD)); - msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic); + if (isDebug()) + msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic); switch(pid = fork()) { case -1: /* error */ (void)sigsetmask(omask); @@ -303,7 +324,7 @@ vsystem(char *fmt, ...) case 0: /* child */ (void)sigsetmask(omask); if (DebugFD != -1) { - if (OnVTY) + if (OnVTY && isDebug()) msgInfo("Command output is on debugging screen - type ALT-F2 to see it"); dup2(DebugFD, 0); dup2(DebugFD, 1); @@ -311,29 +332,29 @@ vsystem(char *fmt, ...) } #ifdef NOT_A_GOOD_IDEA_CRUNCHED_BINARY if (magic) { - char *argv[100]; - i = 0; - argv[i++] = "crunch"; - argv[i++] = "sh"; - argv[i++] = "-c"; - argv[i++] = cmd; - argv[i] = 0; - exit(crunched_main(i,argv)); + char *argv[100]; + i = 0; + argv[i++] = "crunch"; + argv[i++] = "sh"; + argv[i++] = "-c"; + argv[i++] = cmd; + argv[i] = 0; + exit(crunched_main(i,argv)); } else { - char *argv[100]; - i = 0; - argv[i++] = "crunch"; - while (cmd && *cmd) { - argv[i] = strsep(&cmd," \t"); - if (*argv[i]) - i++; - } - argv[i] = 0; - if (crunched_here(argv[1])) - exit(crunched_main(i,argv)); - else - execvp(argv[1],argv+1); - kill(getpid(),9); + char *argv[100]; + i = 0; + argv[i++] = "crunch"; + while (cmd && *cmd) { + argv[i] = strsep(&cmd," \t"); + if (*argv[i]) + i++; + } + argv[i] = 0; + if (crunched_here(argv[1])) + exit(crunched_main(i,argv)); + else + execvp(argv[1],argv+1); + kill(getpid(),9); } #else /* !CRUNCHED_BINARY */ execl("/stand/sh", "sh", "-c", cmd, (char *)NULL); @@ -347,7 +368,8 @@ vsystem(char *fmt, ...) (void)signal(SIGINT, intsave); (void)signal(SIGQUIT, quitsave); i = (pid == -1) ? -1 : WEXITSTATUS(pstat); - msgDebug("Command `%s' returns status of %d\n", cmd, i); + if (isDebug()) + msgDebug("Command `%s' returns status of %d\n", cmd, i); free(cmd); return i; } diff --git a/usr.sbin/sysinstall/cdrom.c b/usr.sbin/sysinstall/cdrom.c index 63831c0..b67406a 100644 --- a/usr.sbin/sysinstall/cdrom.c +++ b/usr.sbin/sysinstall/cdrom.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: cdrom.c,v 1.3 1995/05/28 03:04:46 jkh Exp $ + * $Id: cdrom.c,v 1.4 1995/05/28 07:05:21 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -72,6 +72,7 @@ mediaInitCDROM(Device *dev) if (Mkdir("/cdrom", NULL)) return FALSE; + bzero(&args, sizeof(args)); args.fspec = dev->devname; args.flags = 0; diff --git a/usr.sbin/sysinstall/command.c b/usr.sbin/sysinstall/command.c index 1728964..57f6213 100644 --- a/usr.sbin/sysinstall/command.c +++ b/usr.sbin/sysinstall/command.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: command.c,v 1.8 1995/05/19 21:30:32 jkh Exp $ + * $Id: command.c,v 1.9 1995/05/20 13:24:33 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -167,14 +167,16 @@ command_execute(void) if (commandStack[i]->cmds[j].type == CMD_SHELL) { msgNotify("Doing %s", commandStack[i]->cmds[j].ptr); ret = vsystem((char *)commandStack[i]->cmds[j].ptr); - msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret); + if (isDebug()) + msgDebug("Command `%s' returns status %d\n", commandStack[i]->cmds[j].ptr, ret); } else { /* It's a function pointer - call it with the key and the data */ func = (commandFunc)commandStack[i]->cmds[j].ptr; msgNotify("%x: Execute(%s, %s)", func, commandStack[i]->key, commandStack[i]->cmds[j].data); ret = (*func)(commandStack[i]->key, commandStack[i]->cmds[j].data); - msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret); + if (isDebug()) + msgDebug("Function @ %x returns status %d\n", commandStack[i]->cmds[j].ptr, ret); } } } diff --git a/usr.sbin/sysinstall/config.c b/usr.sbin/sysinstall/config.c index c791550..a51f996 100644 --- a/usr.sbin/sysinstall/config.c +++ b/usr.sbin/sysinstall/config.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: config.c,v 1.11 1995/05/28 09:31:29 jkh Exp $ + * $Id: config.c,v 1.12 1995/05/28 20:28:07 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -174,7 +174,7 @@ configFstab(void) } /* Go for the burn */ - msgDebug("Generating /etc/fstab file"); + msgDebug("Generating /etc/fstab file\n"); for (i = 0; i < nchunks; i++) { fprintf(fstab, "/dev/%s\t\t\t%s\t\t%s %s %d %d\n", nameof(chunk_list[i]), mount_point(chunk_list[i]), fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), @@ -351,7 +351,7 @@ configPackages(char *str) i = (pid == -1) ? -1 : WEXITSTATUS(pstat); } } - if (i != 0) + if (i != 0 && isDebug()) msgDebug("pkg_manage returns status of %d\n", i); return 0; } diff --git a/usr.sbin/sysinstall/devices.c b/usr.sbin/sysinstall/devices.c index 77dd090..48c10e4 100644 --- a/usr.sbin/sysinstall/devices.c +++ b/usr.sbin/sysinstall/devices.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: devices.c,v 1.32 1995/05/27 23:52:55 jkh Exp $ + * $Id: devices.c,v 1.33 1995/05/28 09:31:31 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -183,15 +183,28 @@ deviceGetAll(void) int i; for (i = 0; names[i]; i++) { + Chunk *c1; Disk *d; d = Open_Disk(names[i]); if (!d) msgFatal("Unable to open disk %s", names[i]); - (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, - mediaInitUFS, mediaGetUFS, NULL, deviceDiskFree, d); + (void)deviceRegister(names[i], names[i], d->name, DEVICE_TYPE_DISK, FALSE, NULL, NULL, NULL, NULL, d); msgDebug("Found a device of type disk named: %s\n", names[i]); + + /* Look for existing DOS partitions to register */ + for (c1 = d->chunks->part; c1; c1 = c1->next) { + if (c1->type == fat) { + Device *dev; + + /* Got one! */ + dev = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DOS, TRUE, + mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL); + dev->private = c1; + msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name); + } + } } free(names); } diff --git a/usr.sbin/sysinstall/dist.c b/usr.sbin/sysinstall/dist.c index fe809bb..75ff6fa 100644 --- a/usr.sbin/sysinstall/dist.c +++ b/usr.sbin/sysinstall/dist.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: dist.c,v 1.30 1995/05/28 09:43:36 jkh Exp $ + * $Id: dist.c,v 1.31 1995/05/28 20:28:11 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -250,7 +250,8 @@ distExtract(char *parent, Distribution *me) snprintf(buf, 512, "%s/%s.tgz", path, dist); fd = (*mediaDevice->get)(buf); if (fd != -1) { - status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd); + msgNotify("Extracting %s into %s directory...", me[i].my_name, me[i].my_dir); + status = mediaExtractDist(me[i].my_dir, fd); if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); else @@ -260,14 +261,16 @@ distExtract(char *parent, Distribution *me) snprintf(buf, sizeof buf, "/stand/info/%s/%s.inf", path, dist); if (!access(buf, R_OK)) { - msgDebug("Parsing attributes file for %s\n", dist); + if (isDebug()) + msgDebug("Parsing attributes file for %s\n", dist); dist_attr = safe_malloc(sizeof(Attribs) * MAX_ATTRIBS); if (attr_parse(&dist_attr, buf) == 0) { msgConfirm("Cannot load information file for %s distribution!\nPlease verify that your media is valid and try again.", dist); return FALSE; } - msgDebug("Looking for attribute `pieces'\n"); + if (isDebug()) + msgDebug("Looking for attribute `pieces'\n"); tmp = attr_match(dist_attr, "pieces"); if (tmp) numchunks = atoi(tmp); @@ -277,7 +280,8 @@ distExtract(char *parent, Distribution *me) else numchunks = 0; - msgDebug("Attempting to extract distribution from %u chunks.\n", numchunks); + if (isDebug()) + msgDebug("Attempting to extract distribution from %u chunks.\n", numchunks); if (numchunks < 2 ) { snprintf(buf, 512, "%s/%s", path, dist); @@ -287,7 +291,8 @@ distExtract(char *parent, Distribution *me) if (fd == -1) { status = FALSE; } else { - status = mediaExtractDist(me[i].my_name, me[i].my_dir, fd); + msgNotify("Extracting %s into %s directory...", me[i].my_name, me[i].my_dir); + status = mediaExtractDist(me[i].my_dir, fd); if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); else @@ -296,9 +301,11 @@ distExtract(char *parent, Distribution *me) goto done; } - mediaExtractDistBegin(dist, me[i].my_dir, &fd2, &zpid, &cpid); + mediaExtractDistBegin(me[i].my_dir, &fd2, &zpid, &cpid); + dialog_clear(); for (chunk = 0; chunk < numchunks; chunk++) { int n, retval; + char prompt[80]; snprintf(buf, 512, "%s/%s.%c%c", path, dist, (chunk / 26) + 'a', (chunk % 26) + 'a'); fd = (*mediaDevice->get)(buf); @@ -306,6 +313,8 @@ distExtract(char *parent, Distribution *me) msgConfirm("failed to retreive piece file %s!\nAborting the transfer", buf); goto punt; } + snprintf(prompt, 80, "Extracting %s into %s directory...", me[i].my_name, me[i].my_dir); + dialog_gauge(" Progress ", prompt, 8, 10, 10, 40, (numchunks / (chunk + 1))); while ((n = read(fd, buf, sizeof buf)) > 0) { retval = write(fd2, buf, n); if (retval != n) @@ -354,5 +363,6 @@ distExtract(char *parent, Distribution *me) void distExtractAll(void) { - distExtract(NULL, DistTable); + while (Dists) + distExtract(NULL, DistTable); } diff --git a/usr.sbin/sysinstall/dos.c b/usr.sbin/sysinstall/dos.c index 2204bae..9cf2cd3 100644 --- a/usr.sbin/sysinstall/dos.c +++ b/usr.sbin/sysinstall/dos.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: dos.c,v 1.2 1995/05/27 23:39:28 phk Exp $ + * $Id: dos.c,v 1.3 1995/05/28 03:04:54 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -69,6 +69,7 @@ mediaInitDOS(Device *dev) if (Mkdir("/dos", NULL)) return FALSE; + bzero(&args, sizeof(args)); args.fspec = dev->devname; args.uid = args.gid = 0; @@ -85,7 +86,10 @@ mediaGetDOS(char *file) { char buf[PATH_MAX]; - snprintf(buf, PATH_MAX, "/dos/%s", file); + snprintf(buf, PATH_MAX, "/dos/freebsd/%s", file); + if (!access(buf, R_OK)) + return open(buf, O_RDONLY); + snprintf(buf, PATH_MAX, "/dos/freebsd/dists/%s", file); return open(buf, O_RDONLY); } @@ -97,7 +101,8 @@ mediaShutdownDOS(Device *dev) msgDebug("Unmounting /dos\n"); if (unmount("/dos", 0) != 0) msgConfirm("Could not unmount the DOS partition: %s\n", strerror(errno)); - msgDebug("Unmount returned\n"); + if (isDebug()) + msgDebug("Unmount returned\n"); DOSMounted = FALSE; return; } diff --git a/usr.sbin/sysinstall/floppy.c b/usr.sbin/sysinstall/floppy.c index 229b630..865a635 100644 --- a/usr.sbin/sysinstall/floppy.c +++ b/usr.sbin/sysinstall/floppy.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: floppy.c,v 1.3 1995/05/28 03:04:56 jkh Exp $ + * $Id: floppy.c,v 1.4 1995/05/29 00:50:01 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -142,7 +142,6 @@ mediaGetFloppy(char *file) char buf[PATH_MAX]; snprintf(buf, PATH_MAX, "/mnt/%s", file); - return open(buf, O_RDONLY); } diff --git a/usr.sbin/sysinstall/ftp.c b/usr.sbin/sysinstall/ftp.c index 317e8a8..59060b6 100644 --- a/usr.sbin/sysinstall/ftp.c +++ b/usr.sbin/sysinstall/ftp.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: ftp.c,v 1.10 1995/05/26 19:28:01 jkh Exp $ + * $Id: ftp.c,v 1.11 1995/05/27 06:19:59 phk Exp $ * */ @@ -48,7 +48,8 @@ debug(FTP_t ftp, const char *fmt, ...) #ifdef STANDALONE_FTP write(ftp->fd_debug,p,strlen(p)); #else - msgDebug(p); + if (isDebug()) + msgDebug(p); #endif } diff --git a/usr.sbin/sysinstall/install.c b/usr.sbin/sysinstall/install.c index 6f94a83..f501494 100644 --- a/usr.sbin/sysinstall/install.c +++ b/usr.sbin/sysinstall/install.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: install.c,v 1.65 1995/05/28 23:12:05 jkh Exp $ + * $Id: install.c,v 1.66 1995/05/29 00:50:02 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -254,6 +254,10 @@ installCommit(char *str) fclose(fp); hostsModified = TRUE; } + /* If there's no kernel but there is a kernel.GENERIC, link it over */ + if (access("/kernel", R_OK)) + vsystem("ln -f /kernel.GENERIC /kernel"); + msgConfirm("Installation completed successfully.\nHit return now to go back to the main menu."); SystemWasInstalled = TRUE; return 0; @@ -379,7 +383,7 @@ copy_self(void) msgConfirm("Copy returned error status of %d!", i); /* Copy the /etc files into their rightful place */ - (void)vsystem("(cd /stand; find etc) | cpio -pdmv /mnt"); + (void)vsystem("cd /mnt/stand; find etc | cpio -pdmv /mnt"); } static void loop_on_root_floppy(); @@ -391,7 +395,7 @@ root_extract(void) if (OnCDROM) { fd = open("/floppies/root.flp", O_RDONLY); - (void)mediaExtractDist("root.flp", "/", fd); + (void)mediaExtractDist("/", fd); return; } if (mediaDevice) { @@ -408,7 +412,7 @@ root_extract(void) fd = (*mediaDevice->get)("floppies/root.flp"); if (fd != -1) { msgNotify("Loading root floppy from %s", mediaDevice->name); - (void)mediaExtractDist("root.flp", "/", fd); + (void)mediaExtractDist("/", fd); if (mediaDevice->close) (*mediaDevice->close)(mediaDevice, fd); else @@ -416,12 +420,14 @@ root_extract(void) if (mediaDevice->shutdown) (*mediaDevice->shutdown)(mediaDevice); } else { + msgConfirm("Couldn't get root floppy image from %s\n, falling back to floppy.", mediaDevice->name); if (mediaDevice->shutdown) (*mediaDevice->shutdown)(mediaDevice); loop_on_root_floppy(); } break; + case DEVICE_TYPE_TAPE: case DEVICE_TYPE_FLOPPY: default: loop_on_root_floppy(); @@ -437,7 +443,11 @@ loop_on_root_floppy(void) { int fd; - fd = getRootFloppy(); - if (fd != -1) - mediaExtractDist("root.flp", "/", fd); + while (1) { + fd = getRootFloppy(); + if (fd != -1) { + mediaExtractDist("/", fd); + break; + } + } } diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c index 17cce51..384e419 100644 --- a/usr.sbin/sysinstall/media.c +++ b/usr.sbin/sysinstall/media.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: media.c,v 1.20 1995/05/27 23:39:31 phk Exp $ + * $Id: media.c,v 1.21 1995/05/28 03:04:58 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -164,13 +164,15 @@ int mediaSetDOS(char *str) { Device **devs; - Disk *d; - Chunk *c1; - int i, cnt; + int cnt; devs = deviceFind(NULL, DEVICE_TYPE_DOS); cnt = deviceCount(devs); - if (cnt > 1) { + if (!cnt) { + msgConfirm("No DOS primary partitions found! This installation method is unavailable"); + return 0; + } + else if (cnt > 1) { DMenu *menu; menu = deviceCreateMenu(&MenuMediaDOS, DEVICE_TYPE_DOS, DOSHook); @@ -179,34 +181,8 @@ mediaSetDOS(char *str) dmenuOpenSimple(menu); free(menu); } - else if (cnt) { + else mediaDevice = devs[0]; - return 1; - } - else { - devs = deviceFind(NULL, DEVICE_TYPE_DISK); - if (!devs) { - msgConfirm("No disk devices found!"); - return 0; - } - /* Now go chewing through looking for a DOS FAT partition */ - for (i = 0; devs[i]; i++) { - d = (Disk *)devs[i]->private; - /* Now try to find a DOS partition */ - for (c1 = d->chunks->part; c1; c1 = c1->next) { - if (c1->type == fat) { - /* Got one! */ - mediaDevice = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DOS, TRUE, - mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL); - mediaDevice->private = c1; - msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name); - break; - } - } - } - } - if (!mediaDevice) - msgConfirm("No DOS primary partitions found! This installation method is unavailable"); return mediaDevice ? 1 : 0; } @@ -280,25 +256,49 @@ mediaSetFTP(char *str) return 1; } -/* - * Return 0 if we successfully found and set the installation type to - * be some sort of mounted filesystem (it's also mounted at this point) - */ int -mediaSetFS(char *str) +mediaSetUFS(char *str) +{ + static Device ufsDevice; + char *val; + + val = msgGetInput(NULL, "Enter a fully qualified pathname for the directory\ncontaining the FreeBSD distribtion files:"); + if (!val) + return 0; + strcpy(ufsDevice.name, "ufs"); + ufsDevice.type = DEVICE_TYPE_UFS; + ufsDevice.get = mediaGetUFS; + ufsDevice.private = strdup(val); + mediaDevice = &ufsDevice; + return 1; +} + +int +mediaSetNFS(char *str) { - return 0; + static Device nfsDevice; + char *val; + + val = msgGetInput(NULL, "Please enter the full NFS file specification for the remote\nhost and directory containing the FreeBSD distribution files.\nThis should be in the format: hostname:/some/freebsd/dir"); + if (!val) + return 0; + strcpy(nfsDevice.name, "nfs"); + nfsDevice.type = DEVICE_TYPE_NFS; + nfsDevice.init = mediaInitNFS; + nfsDevice.get = mediaGetNFS; + nfsDevice.shutdown = mediaShutdownNFS; + nfsDevice.private = strdup(val); + mediaDevice = &nfsDevice; + return 1; } Boolean -mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpid) +mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpid) { int i, pfd[2],qfd[2]; if (!dir) dir = "/"; - msgWeHaveOutput("Extracting %s into %s directory..", distname, dir); - Mkdir(dir, NULL); chdir(dir); pipe(pfd); @@ -316,7 +316,8 @@ mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpid) close(qfd[1]); close(pfd[0]); i = execl("/stand/gunzip", "/stand/gunzip", 0); - msgDebug("/stand/gunzip command returns %d status\n", i); + if (isDebug()) + msgDebug("/stand/gunzip command returns %d status\n", i); exit(i); } *fd = qfd[1]; @@ -335,7 +336,8 @@ mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpid) dup2(1, 2); } i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0); - msgDebug("/stand/cpio command returns %d status\n", i); + if (isDebug()) + msgDebug("/stand/cpio command returns %d status\n", i); exit(i); } close(pfd[0]); @@ -351,13 +353,15 @@ mediaExtractDistEnd(int zpid, int cpid) i = waitpid(zpid, &j, 0); if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */ dialog_clear(); - msgDebug("wait for gunzip returned status of %d!\n", i); + if (isDebug()) + msgDebug("wait for gunzip returned status of %d!\n", i); return FALSE; } i = waitpid(cpid, &j, 0); if (i < 0 || WEXITSTATUS(j)) { dialog_clear(); - msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); + if (isDebug()) + msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); return FALSE; } return TRUE; @@ -365,13 +369,12 @@ mediaExtractDistEnd(int zpid, int cpid) Boolean -mediaExtractDist(char *distname, char *dir, int fd) +mediaExtractDist(char *dir, int fd) { int i, j, zpid, cpid, pfd[2]; if (!dir) dir = "/"; - msgWeHaveOutput("Extracting %s into %s directory..", distname, dir); Mkdir(dir, NULL); chdir(dir); @@ -388,7 +391,8 @@ mediaExtractDist(char *distname, char *dir, int fd) } close(pfd[0]); i = execl("/stand/gunzip", "/stand/gunzip", 0); - msgDebug("/stand/gunzip command returns %d status\n", i); + if (isDebug()) + msgDebug("/stand/gunzip command returns %d status\n", i); exit(i); } cpid = fork(); @@ -405,7 +409,8 @@ mediaExtractDist(char *distname, char *dir, int fd) dup2(1, 2); } i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0); - msgDebug("/stand/cpio command returns %d status\n", i); + if (isDebug()) + msgDebug("/stand/cpio command returns %d status\n", i); exit(i); } close(pfd[0]); @@ -414,13 +419,15 @@ mediaExtractDist(char *distname, char *dir, int fd) i = waitpid(zpid, &j, 0); if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */ dialog_clear(); - msgDebug("wait for gunzip returned status of %d!\n", i); + if (isDebug()) + msgDebug("wait for gunzip returned status of %d!\n", i); return FALSE; } i = waitpid(cpid, &j, 0); if (i < 0 || WEXITSTATUS(j)) { dialog_clear(); - msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); + if (isDebug()) + msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); return FALSE; } return TRUE; diff --git a/usr.sbin/sysinstall/menus.c b/usr.sbin/sysinstall/menus.c index 83b47c2..a2cd6c3 100644 --- a/usr.sbin/sysinstall/menus.c +++ b/usr.sbin/sysinstall/menus.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: menus.c,v 1.36 1995/05/28 23:12:07 jkh Exp $ + * $Id: menus.c,v 1.37 1995/05/29 01:43:17 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -302,12 +302,14 @@ method.", DMENU_CALL, mediaSetCDROM, 0, 0 }, { "DOS", "Install from a DOS partition", DMENU_CALL, mediaSetDOS, 0, 0 }, - { "File System", "Install from a UFS or NFS mounted distribution", - DMENU_CALL, mediaSetFS, 0, 0 }, + { "File System", "Install from a mounted filesystem", + DMENU_CALL, mediaSetUFS, 0, 0 }, { "Floppy", "Install from a floppy disk set", DMENU_CALL, mediaSetFloppy, 0, 0 }, { "FTP", "Install from an Internet FTP server", DMENU_CALL, mediaSetFTP, 0, 0 }, + { "NFS", "Install over NFS", + DMENU_CALL, mediaSetNFS, 0, 0 }, { "Tape", "Install from SCSI or QIC tape", DMENU_CALL, mediaSetTape, 0, 0 }, { NULL } }, @@ -642,7 +644,7 @@ When you're done, select Cancel", "Press F1 for more information on these options", "configure.hlp", { { "Add User", "Add users to the system", - DMENU_SYSTEM_COMMAND, "adduser", 0, 0 }, + DMENU_SYSTEM_COMMAND, "adduser -silent", 0, 0 }, { "Console", "Customize system console behavior", DMENU_SUBMENU, &MenuSyscons, 0, 0 }, { "Networking", "Configure additional network services", @@ -700,11 +702,11 @@ close to you to have your system time syncronized accordingly.", DMENU_SET_VARIABLE, "ntpdate=canon.inria.fr", 0, 0 }, { "Germany", "ntps1-{0,1,2}.uni-erlangen.de (GPS)", DMENU_SET_VARIABLE, "ntpdate=ntps1-0.uni-erlangen.de", 0, 0 }, - { "Germany", "ntps1-0.cs.tu-berlin.de (GPS)", + { "Germany #2", "ntps1-0.cs.tu-berlin.de (GPS)", DMENU_SET_VARIABLE, "ntpdate=ntps1-0.cs.tu-berlin.de", 0, 0 }, { "Japan", "clock.nc.fukuoka-u.ac.jp (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=clock.nc.fukuoka-u.ac.jp", 0, 0}, - { "Japan", "clock.tl.fukuoka-u.ac.jp (GPS clock)", + { "Japan #2", "clock.tl.fukuoka-u.ac.jp (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=clock.tl.fukuoka-u.ac.jp", 0, 0}, { "Netherlands", "ntp0.nl.net (GPS clock)", DMENU_SET_VARIABLE, "ntpdate=ntp0.nl.net", 0, 0 }, @@ -716,20 +718,20 @@ close to you to have your system time syncronized accordingly.", DMENU_SET_VARIABLE, "ntpdate=swisstime.ethz.ch", 0, 0 }, { "U.S. East Coast", "bitsy.mit.edu (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=bitsy.mit.edu", 0, 0 }, - { "U.S. East Coast", "otc1.psu.edu (WWV clock)", + { "U.S. East Coast #2", "otc1.psu.edu (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=otc1.psu.edu", 0, 0 }, { "U.S. West Coast", "apple.com (WWV clock)", DMENU_SET_VARIABLE, "ntpdate=apple.com", 0, 0 }, - { "U.S. West Coast", "clepsydra.dec.com (GOES clock)", + { "U.S. West Coast #2", "clepsydra.dec.com (GOES clock)", DMENU_SET_VARIABLE, "ntpdate=clepsydra.dec.com", 0, 0 }, - { "U.S. West Coast", "clock.llnl.gov (WWVB clock)", - DMENU_SET_VARIABLE, "ntpdate=clock.llnl.gov", 0, 0 }, + { "U.S. West Coast #3", "clock.llnl.gov (WWVB clock)", + DMENU_SET_VARIABLE, "ntpdate=clock.llnl.gov", 0, 0 }, { "U.S. Midwest", "ncar.ucar.edu (WWVB clock)", - DMENU_SET_VARIABLE, "ntpdate=ncar.ucar.edu", 0, 0 }, + DMENU_SET_VARIABLE, "ntpdate=ncar.ucar.edu", 0, 0 }, { "U.S. Pacific", "chantry.hawaii.net (WWV/H clock)", DMENU_SET_VARIABLE, "ntpdate=chantry.hawaii.net", 0, 0 }, { "U.S. Southwest", "shorty.chpc.utexas.edu (WWV clock)", - DMENU_SET_VARIABLE, "ntpdate=shorty.chpc.utexas.edu", 0, 0 }, + DMENU_SET_VARIABLE, "ntpdate=shorty.chpc.utexas.edu", 0, 0 }, { NULL } }, }; @@ -738,9 +740,9 @@ DMenu MenuSyscons = { "System Console Configuration", "The default system console driver for FreeBSD (syscons) has a\n\ number of configuration options which may be set according to\n\ -your preference. When you are done setting configuration options,\n\ -select Cancel.", - "Configure your screen saver settings", +your preference.\n\n\ +When you are done setting configuration options, select Cancel.", + "Configure your system console settings", NULL, { { "Keymap", "Choose an alternate keyboard map", DMENU_SUBMENU, &MenuSysconsKeymap, 0, 0 }, @@ -798,9 +800,9 @@ when held down.", NULL, { { "Slow", "Slow keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=slow", 0, 0 }, - { "Normal", "\"normal\" keyboard repeat rate", + { "Normal", "\"Normal\" keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=normal", 0, 0 }, - { "Fast", "fast keyboard repeat rate", + { "Fast", "Fast keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=fast", 0, 0 }, { "Default", "Use default keyboard repeat rate", DMENU_SET_VARIABLE, "keyrate=NO", 0, 0 }, @@ -818,11 +820,11 @@ probably enable one of these screen savers to prevent phosphor burn-in.", NULL, { { "blank", "Simply blank the screen", DMENU_SET_VARIABLE, "saver=star", 0, 0 }, - { "Green", "\"green\" power saving mode (if supported by monitor)", + { "Green", "\"Green\" power saving mode (if supported by monitor)", DMENU_SET_VARIABLE, "saver=snake", 0, 0 }, { "Snake", "Draw a FreeBSD \"snake\" on your screen", DMENU_SET_VARIABLE, "saver=snake", 0, 0 }, - { "Star", "\"twinkling stars\" effect", + { "Star", "A \"twinkling stars\" effect", DMENU_SET_VARIABLE, "saver=star", 0, 0 }, { "Timeout", "Set the screen saver timeout interval", DMENU_CALL, configSaverTimeout, 0, 0 }, diff --git a/usr.sbin/sysinstall/misc.c b/usr.sbin/sysinstall/misc.c index a2ab20f..f1b8066 100644 --- a/usr.sbin/sysinstall/misc.c +++ b/usr.sbin/sysinstall/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id: misc.c,v 1.8 1995/05/23 18:06:15 jkh Exp $ + * $Id: misc.c,v 1.9 1995/05/25 01:22:19 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -183,7 +183,8 @@ Mkdir(char *ipath, void *data) return 0; path = strdup(ipath); - msgDebug("mkdir(%s)\n", path); + if (isDebug()) + msgDebug("mkdir(%s)\n", path); p = path; if (p[0] == '/') /* Skip leading '/'. */ ++p; @@ -198,7 +199,8 @@ Mkdir(char *ipath, void *data) msgConfirm("Couldn't stat directory %s: %s", path, strerror(errno)); return 1; } - msgDebug("mkdir(%s..)\n", path); + if (isDebug()) + msgDebug("mkdir(%s..)\n", path); if (mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) < 0) { msgConfirm("Couldn't create directory %s: %s", path,strerror(errno)); return 1; @@ -231,7 +233,9 @@ Mount(char *mountp, void *dev) msgConfirm("Unable to make directory mountpoint for %s!", mountpoint); return 1; } - msgDebug("mount %s %s\n", device, mountpoint); + if (isDebug()) + msgDebug("mount %s %s\n", device, mountpoint); + bzero(&ufsargs, sizeof(ufsargs)); ufsargs.fspec = device; if (mount(MOUNT_UFS, mountpoint, 0, (caddr_t)&ufsargs) == -1) { msgConfirm("Error mounting %s on %s : %s\n", device, mountpoint, strerror(errno)); diff --git a/usr.sbin/sysinstall/msg.c b/usr.sbin/sysinstall/msg.c index e9b2ae6..5930d14 100644 --- a/usr.sbin/sysinstall/msg.c +++ b/usr.sbin/sysinstall/msg.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: msg.c,v 1.25 1995/05/29 00:50:04 jkh Exp $ + * $Id: msg.c,v 1.26 1995/05/29 01:43:18 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -49,6 +49,17 @@ #define VTY_STATLINE 24 #define TTY_STATLINE 23 +Boolean +isDebug(void) +{ + char *cp; + + cp = getenv("debug"); + if (cp && !strcmp(cp, "yes")) + return TRUE; + return FALSE; +} + /* Whack up an informational message on the status line, in stand-out */ void msgYap(char *fmt, ...) @@ -105,7 +116,8 @@ msgInfo(char *fmt, ...) move(OnVTY ? VTY_STATLINE : TTY_STATLINE, 79); refresh(); if (OnVTY) { - msgDebug("Information: `%s'\n", errstr); + if (isDebug()) + msgDebug("Information: `%s'\n", errstr); msgInfo(NULL); } free(errstr); @@ -130,7 +142,7 @@ msgWarn(char *fmt, ...) mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr); attrset(attrs); refresh(); - if (OnVTY) + if (OnVTY && isDebug()) msgDebug("Warning message `%s'\n", errstr); free(errstr); } @@ -154,7 +166,7 @@ msgError(char *fmt, ...) mvaddstr(OnVTY ? VTY_STATLINE : TTY_STATLINE, 0, errstr); attrset(attrs); refresh(); - if (OnVTY) + if (OnVTY && isDebug()) msgDebug("Error message `%s'\n", errstr); free(errstr); } @@ -231,7 +243,8 @@ msgNotify(char *fmt, ...) va_end(args); use_helpline(NULL); use_helpfile(NULL); - msgDebug("Notify: %s\n", errstr); + if (isDebug()) + msgDebug("Notify: %s\n", errstr); dialog_clear(); dialog_msgbox("Information Dialog", errstr, -1, -1, 0); free(errstr); @@ -254,8 +267,8 @@ msgYesNo(char *fmt, ...) use_helpfile(NULL); w = dupwin(newscr); if (OnVTY) { + msgDebug("Switching back to VTY 0\n"); ioctl(0, VT_RELDISP, 1); /* Switch back */ - msgDebug("User decision requested (type ALT-F1)\n"); msgInfo(NULL); } ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1); diff --git a/usr.sbin/sysinstall/network.c b/usr.sbin/sysinstall/network.c index 83e849b..2258162 100644 --- a/usr.sbin/sysinstall/network.c +++ b/usr.sbin/sysinstall/network.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: network.c,v 1.3 1995/05/28 09:31:38 jkh Exp $ + * $Id: network.c,v 1.4 1995/05/29 01:43:20 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -47,6 +47,7 @@ #include "sysinstall.h" #include <sys/fcntl.h> +#include <sys/stat.h> static Boolean networkInitialized; static Boolean startPPP(Device *devp); @@ -68,8 +69,22 @@ mediaInitNetwork(Device *dev) return FALSE; } } - else - msgConfirm("Warning: SLIP is rather poorly supported in this revision\nof the installation due to the lack of a dialing utility.\nIf you can use PPP for this instead then you're much better\noff doing so, otherwise SLIP works fairly well for *hardwired*\nlinks. Use the shell on the 4TH screen (ALT-F4) to run slattach\nand otherwise set the link up, then hit return here to continue."); + else { + char *val; + char attach[256]; + + /* Cheesy slip attach */ + snprintf(attach, 256, "slattach -a -h -l -s 9600 %s", dev->devname); + val = msgGetInput(attach, "Warning: SLIP is rather poorly supported in this revision\nof the installation due to the lack of a dialing utility.\nIf you can use PPP for this instead then you're much better\noff doing so, otherwise SLIP works fairly well for *hardwired*\nlinks. Please edit the following slattach command for\ncorrectness (default here is VJ compression, Hardware flow-control,\nignore carrier and 9600 baud data rate) and hit return to execute it."); + if (!val) + return FALSE; + else if (!vsystem(attach)) + return TRUE; + else { + msgConfirm("slattach returned a bad status! Please verify that\nthe command is correct and try again."); + return FALSE; + } + } } else { char *cp, ifconfig[64]; diff --git a/usr.sbin/sysinstall/nfs.c b/usr.sbin/sysinstall/nfs.c index b9ab534..2ed22f6 100644 --- a/usr.sbin/sysinstall/nfs.c +++ b/usr.sbin/sysinstall/nfs.c @@ -1,21 +1,97 @@ +/* + * The new sysinstall program. + * + * This is probably the last attempt in the `sysinstall' line, the next + * generation being slated to essentially a complete rewrite. + * + * $Id: media.c,v 1.21 1995/05/28 03:04:58 jkh Exp $ + * + * Copyright (c) 1995 + * Jordan Hubbard. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer, + * verbatim and that no modifications are made prior to this + * point in the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Jordan Hubbard + * for the FreeBSD Project. + * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + #include "sysinstall.h" -#include <stdio.h> -#include <ctype.h> -#include <sys/stat.h> #include <sys/errno.h> -#include <sys/file.h> -#include <sys/types.h> -#include <sys/wait.h> +#include <sys/fcntl.h> +#include <sys/syslimits.h> #include <sys/param.h> -#include <sys/dkbad.h> -#include <sys/mman.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <netdb.h> -#include "ftp.h" - -#define NFS #include <sys/mount.h> -#undef NFS +Boolean NFSMounted; + +Boolean +mediaInitNFS(Device *dev) +{ + if (NFSMounted) + return TRUE; + + if (Mkdir("/nfs", NULL)) + return FALSE; + + if (!vsystem("mount_nfs %s %s %s /nfs", getenv("nfsSlowPC") ? "-r 1024 -w 1024" : "", + getenv("nfsServerSecure") ? "-P" : "", dev->private)) + return TRUE; + else { + msgConfirm("Error mounting %s on /nfs: %s (%u)\n", dev->private, strerror(errno), errno); + return FALSE; + } + NFSMounted = TRUE; + return TRUE; +} + +int +mediaGetNFS(char *file) +{ + char buf[PATH_MAX]; + + snprintf(buf, PATH_MAX, "/nfs/%s", file); + if (!access(buf, R_OK)) + return open(buf, O_RDONLY); + snprintf(buf, PATH_MAX, "/nfs/dists/%s", file); + return open(buf, O_RDONLY); +} + +void +mediaShutdownNFS(Device *dev) +{ + if (!NFSMounted) + return; + msgDebug("Unmounting /nfs\n"); + if (unmount("/nfs", 0) != 0) + msgConfirm("Could not unmount the NFS partition: %s\n", strerror(errno)); + if (isDebug()) + msgDebug("Unmount returned\n"); + NFSMounted = FALSE; + return; +} diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index a9466f0..42da9c4 100644 --- a/usr.sbin/sysinstall/sysinstall.h +++ b/usr.sbin/sysinstall/sysinstall.h @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: sysinstall.h,v 1.38 1995/05/28 03:05:03 jkh Exp $ + * $Id: sysinstall.h,v 1.39 1995/05/28 09:31:39 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -160,6 +160,8 @@ typedef enum { DEVICE_TYPE_CDROM, DEVICE_TYPE_TAPE, DEVICE_TYPE_DOS, + DEVICE_TYPE_UFS, + DEVICE_TYPE_NFS, DEVICE_TYPE_ANY, } DeviceType; @@ -378,10 +380,11 @@ extern int mediaSetFloppy(char *str); extern int mediaSetDOS(char *str); extern int mediaSetTape(char *str); extern int mediaSetFTP(char *str); -extern int mediaSetFS(char *str); +extern int mediaSetUFS(char *str); +extern int mediaSetNFS(char *str); extern Boolean mediaGetType(void); -extern Boolean mediaExtractDist(char *distname, char *dir, int fd); -extern Boolean mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpic); +extern Boolean mediaExtractDist(char *dir, int fd); +extern Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpic); extern Boolean mediaExtractDistEnd(int zpid, int cpid); extern Boolean mediaVerify(void); @@ -403,6 +406,7 @@ extern int Mount(char *, void *data); extern int Mount_DOS(char *, void *data); /* msg.c */ +extern Boolean isDebug(void); extern void msgInfo(char *fmt, ...); extern void msgYap(char *fmt, ...); extern void msgWarn(char *fmt, ...); @@ -420,6 +424,11 @@ extern Boolean mediaInitNetwork(Device *dev); extern void mediaShutdownNetwork(Device *dev); extern int configRoutedFlags(char *str); +/* nfs.c */ +extern Boolean mediaInitNFS(Device *dev); +extern int mediaGetNFS(char *file); +extern void mediaShutdownNFS(Device *dev); + /* system.c */ extern void systemInitialize(int argc, char **argv); extern void systemShutdown(void); @@ -448,6 +457,7 @@ extern int tcpDeviceSelect(char *str); extern int set_termcap(void); /* ufs.c */ +extern void mediaShutdownUFS(Device *dev); extern Boolean mediaInitUFS(Device *dev); extern int mediaGetUFS(char *file); diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c index 6aaea42..2e55385 100644 --- a/usr.sbin/sysinstall/system.c +++ b/usr.sbin/sysinstall/system.c @@ -4,7 +4,7 @@ * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * - * $Id: system.c,v 1.40 1995/05/29 00:50:05 jkh Exp $ + * $Id: system.c,v 1.41 1995/05/29 02:13:31 phk Exp $ * * Jordan Hubbard * @@ -102,10 +102,8 @@ systemShutdown(void) } /* REALLY exit! */ if (RunningAsInit) { - int fd, on = 1; - /* Put the console back */ - ioctl(0, VT_RELDISP, 1); + ioctl(DebugFD, VT_RELDISP, 1); reboot(RB_HALT); } else @@ -187,7 +185,6 @@ systemDisplayFile(char *file) use_helpline(NULL); w = dupwin(newscr); dialog_textbox(file, fname, LINES, COLS); - unlink(fname); touchwin(w); wrefresh(w); delwin(w); @@ -199,24 +196,45 @@ char * systemHelpFile(char *file, char *buf) { char *cp; + static char oldfile[64]; /* Should be FILENAME_MAX but I don't feel like wasting that much space */ if (!file) return NULL; if ((cp = getenv("LANG")) != NULL) { snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); - vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s",buf); + if (oldfile[0]) { + if (!strcmp(buf, oldfile)) + return oldfile; + else { + unlink(oldfile); + oldfile[0] = '\0'; + } + } + vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s > /dev/null 2>&1",buf); snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); - if (file_readable(buf)) + if (file_readable(buf)) { + strcpy(oldfile, buf); return buf; + } } /* Fall back to normal imperialistic mode :-) */ cp = "en_US.ISO8859-1"; snprintf(buf, FILENAME_MAX, "%s/%s", cp, file); - vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s",buf); + if (oldfile[0]) { + if (!strcmp(buf, oldfile)) + return oldfile; + else { + unlink(oldfile); + oldfile[0] = '\0'; + } + } + vsystem("cd /stand && zcat help.tgz | cpio --format=tar -idv %s > /dev/null 2>&1",buf); snprintf(buf, FILENAME_MAX, "/stand/%s/%s", cp, file); - if (file_readable(buf)) + if (file_readable(buf)) { + strcpy(oldfile, buf); return buf; + } return NULL; } @@ -290,11 +308,14 @@ vsystem(char *fmt, ...) va_start(args, fmt); vsnprintf(cmd, FILENAME_MAX, fmt, args); va_end(args); + /* Find out if this command needs the wizardry of the shell */ for (p="<>|'`=\"()" ; *p; p++) - if (strchr(cmd,*p)) magic++; + if (strchr(cmd, *p)) + magic++; omask = sigblock(sigmask(SIGCHLD)); - msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic); + if (isDebug()) + msgDebug("Executing command `%s' (Magic=%d)\n", cmd, magic); switch(pid = fork()) { case -1: /* error */ (void)sigsetmask(omask); @@ -303,7 +324,7 @@ vsystem(char *fmt, ...) case 0: /* child */ (void)sigsetmask(omask); if (DebugFD != -1) { - if (OnVTY) + if (OnVTY && isDebug()) msgInfo("Command output is on debugging screen - type ALT-F2 to see it"); dup2(DebugFD, 0); dup2(DebugFD, 1); @@ -311,29 +332,29 @@ vsystem(char *fmt, ...) } #ifdef NOT_A_GOOD_IDEA_CRUNCHED_BINARY if (magic) { - char *argv[100]; - i = 0; - argv[i++] = "crunch"; - argv[i++] = "sh"; - argv[i++] = "-c"; - argv[i++] = cmd; - argv[i] = 0; - exit(crunched_main(i,argv)); + char *argv[100]; + i = 0; + argv[i++] = "crunch"; + argv[i++] = "sh"; + argv[i++] = "-c"; + argv[i++] = cmd; + argv[i] = 0; + exit(crunched_main(i,argv)); } else { - char *argv[100]; - i = 0; - argv[i++] = "crunch"; - while (cmd && *cmd) { - argv[i] = strsep(&cmd," \t"); - if (*argv[i]) - i++; - } - argv[i] = 0; - if (crunched_here(argv[1])) - exit(crunched_main(i,argv)); - else - execvp(argv[1],argv+1); - kill(getpid(),9); + char *argv[100]; + i = 0; + argv[i++] = "crunch"; + while (cmd && *cmd) { + argv[i] = strsep(&cmd," \t"); + if (*argv[i]) + i++; + } + argv[i] = 0; + if (crunched_here(argv[1])) + exit(crunched_main(i,argv)); + else + execvp(argv[1],argv+1); + kill(getpid(),9); } #else /* !CRUNCHED_BINARY */ execl("/stand/sh", "sh", "-c", cmd, (char *)NULL); @@ -347,7 +368,8 @@ vsystem(char *fmt, ...) (void)signal(SIGINT, intsave); (void)signal(SIGQUIT, quitsave); i = (pid == -1) ? -1 : WEXITSTATUS(pstat); - msgDebug("Command `%s' returns status of %d\n", cmd, i); + if (isDebug()) + msgDebug("Command `%s' returns status of %d\n", cmd, i); free(cmd); return i; } diff --git a/usr.sbin/sysinstall/tape.c b/usr.sbin/sysinstall/tape.c index 48088a7..ac288b5 100644 --- a/usr.sbin/sysinstall/tape.c +++ b/usr.sbin/sysinstall/tape.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: tape.c,v 1.2 1995/05/27 23:39:33 phk Exp $ + * $Id: tape.c,v 1.3 1995/05/28 03:05:04 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -46,21 +46,59 @@ /* These routines deal with getting things off of tape media */ #include "sysinstall.h" +#include <sys/fcntl.h> +#include <sys/param.h> + +static Boolean tapeInitted; Boolean mediaInitTape(Device *dev) { - return TRUE; + int i; + + if (tapeInitted) + return TRUE; + + Mkdir("/usr/tmp/tape", NULL); + if (chdir("/usr/tmp/tape")) { + Mkdir("/var/tmp/tape", NULL); + if (chdir("/var/tmp/tape")) + return FALSE; + } + msgConfirm("Insert tape into %s and press return", dev->description); + if (!strcmp(dev->name, "ft0")) + i = vsystem("ft | tar xvf -"); + else + i = vsystem("tar xvf %s", dev->devname); + if (!i) { + tapeInitted = TRUE; + return TRUE; + } + else + msgConfirm("Tape extract command failed with status %d!", i); + return FALSE; } int mediaGetTape(char *file) { - return -1; + char buf[PATH_MAX]; + + sprintf(buf, "/usr/tmp/tape/%s", file); + if (!access(buf, R_OK)) + return open(buf, O_RDONLY); + sprintf(buf, "/var/tmp/tape/%s", file); + return open(buf, O_RDONLY); } void mediaShutdownTape(Device *dev) { - return; + if (!tapeInitted) + return; + if (!access("/usr/tmp/tape", X_OK)) + (void)vsystem("rm -rf /usr/tmp/tape"); + else if (!access("/var/tmp/tape", X_OK)) + (void)vsystem("rm -rf /var/tmp/tape"); + tapeInitted = FALSE; } diff --git a/usr.sbin/sysinstall/tcpip.c b/usr.sbin/sysinstall/tcpip.c index 04166c7..13dcdbc 100644 --- a/usr.sbin/sysinstall/tcpip.c +++ b/usr.sbin/sysinstall/tcpip.c @@ -1,5 +1,5 @@ /* - * $Id: tcpip.c,v 1.25 1995/05/28 09:31:44 jkh Exp $ + * $Id: tcpip.c,v 1.26 1995/05/28 23:12:09 jkh Exp $ * * Copyright (c) 1995 * Gary J Palmer. All rights reserved. @@ -196,12 +196,12 @@ tcpOpenDialog(Device *devp) /* Setup a nice screen for us to splat stuff onto */ draw_box(ds_win, TCP_DIALOG_Y, TCP_DIALOG_X, TCP_DIALOG_HEIGHT, TCP_DIALOG_WIDTH, dialog_attr, border_attr); wattrset(ds_win, dialog_attr); - sprintf(title, " Interface %s ", devp->name); - mvwaddstr(ds_win, TCP_DIALOG_Y, TCP_DIALOG_X + 22, title); + mvwaddstr(ds_win, TCP_DIALOG_Y, TCP_DIALOG_X + 15, " Network Configuration "); draw_box(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 8, TCP_DIALOG_HEIGHT - 13, TCP_DIALOG_WIDTH - 17, dialog_attr, border_attr); wattrset(ds_win, dialog_attr); - mvwaddstr(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 16, " Per Interface Configuration "); + sprintf(title, " Configuration for Interface %s ", devp->name); + mvwaddstr(ds_win, TCP_DIALOG_Y + 9, TCP_DIALOG_X + 14, title); /* Initialise vars from previous device values */ if (devp->private) { diff --git a/usr.sbin/sysinstall/ufs.c b/usr.sbin/sysinstall/ufs.c index 1fd9d4e..55a2701 100644 --- a/usr.sbin/sysinstall/ufs.c +++ b/usr.sbin/sysinstall/ufs.c @@ -4,7 +4,7 @@ * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * - * $Id: ufs.c,v 1.1 1995/05/27 10:39:04 jkh Exp $ + * $Id: ufs.c,v 1.2 1995/05/27 23:39:35 phk Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -44,17 +44,19 @@ */ #include "sysinstall.h" +#include <sys/fcntl.h> +#include <sys/param.h> -Boolean -mediaInitUFS(Device *dev) -{ - return TRUE; -} +/* No init or shutdown routines necessary - all done in mediaSetUFS() */ int mediaGetUFS(char *file) { - return -1; -} + char buf[PATH_MAX]; -/* UFS has no Shutdown routine since this is handled at the device level */ + snprintf(buf, PATH_MAX, "%s/%s", (char *)mediaDevice->private, file); + if (!access(buf, R_OK)) + return open(buf, O_RDONLY); + snprintf(buf, PATH_MAX, "%s/dists/%s", (char *)mediaDevice->private, file); + return open(buf, O_RDONLY); +} |