From c6e3d799ef162feb2fedba8677731a7b78ff8d32 Mon Sep 17 00:00:00 2001 From: jkh Date: Sun, 16 Jun 1996 21:57:35 +0000 Subject: Check network status earlier in FTP/NFS installs in order to reduce user frustration. --- release/sysinstall/ftp_strat.c | 41 ++++++--------------------------- release/sysinstall/media.c | 50 +++++++++++++++++++++++++++++++++++++---- release/sysinstall/menus.c | 4 ++-- release/sysinstall/sysinstall.h | 5 ++++- 4 files changed, 59 insertions(+), 41 deletions(-) (limited to 'release') diff --git a/release/sysinstall/ftp_strat.c b/release/sysinstall/ftp_strat.c index befe58e..907b519 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.16 1996/05/16 11:47:28 jkh Exp $ + * $Id: ftp_strat.c,v 1.17 1996/05/23 11:50:11 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -108,8 +108,8 @@ Boolean mediaInitFTP(Device *dev) { int i, retries; - char *cp, *hostname, *dir, *rel; - char *user, *login_name, password[80], url[BUFSIZ]; + char *cp, *rel, *hostname, *dir; + char *user, *login_name, password[80]; Device *netDevice = (Device *)dev->private; if (ftpInitted) @@ -134,37 +134,6 @@ mediaInitFTP(Device *dev) return FALSE; } - if (isDebug()) - msgDebug("Attempting to open connection for URL: %s\n", cp); - if (strncmp("ftp://", cp, 6) != NULL) { - msgConfirm("Invalid URL: %s\n(A URL must start with `ftp://' here)", cp); - return FALSE; - } - strncpy(url, cp, BUFSIZ); - if (isDebug()) - msgDebug("Using URL `%s'\n", url); - hostname = url + 6; - if ((cp = index(hostname, ':')) != NULL) { - *(cp++) = '\0'; - FtpPort = strtol(cp, 0, 0); - } - else - FtpPort = 21; - if ((dir = index(cp ? cp : hostname, '/')) != NULL) - *(dir++) = '\0'; - if (isDebug()) { - msgDebug("hostname = `%s'\n", hostname); - msgDebug("dir = `%s'\n", dir ? dir : "/"); - msgDebug("port # = `%d'\n", FtpPort); - } - msgNotify("Looking up host %s..", hostname); - if ((gethostbyname(hostname) == NULL) && (inet_addr(hostname) == INADDR_NONE)) { - msgConfirm("Cannot resolve hostname `%s'! Are you sure that your\n" - "name server, gateway and network interface are correctly configured?", hostname); - netDevice->shutdown(netDevice); - tcpOpenDialog(netDevice); - return FALSE; - } user = variable_get(VAR_FTP_USER); if (!user || !*user) { snprintf(password, BUFSIZ, "installer@%s", variable_get(VAR_HOSTNAME)); @@ -175,6 +144,10 @@ mediaInitFTP(Device *dev) strcpy(password, variable_get(VAR_FTP_PASS) ? variable_get(VAR_FTP_PASS) : login_name); } retries = 0; + hostname = variable_get(VAR_FTP_HOST); + dir = variable_get(VAR_FTP_DIR); + if (!hostname || !dir) + msgFatal("Missing FTP host or directory specification - something's wrong!"); retry: msgNotify("Logging in as %s..", login_name); diff --git a/release/sysinstall/media.c b/release/sysinstall/media.c index cd5d9c6..de6e697 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.38 1996/04/28 03:27:11 jkh Exp $ + * $Id: media.c,v 1.39 1996/06/08 07:02:21 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -34,13 +34,19 @@ * */ +#include #include +#include +#include +#include #include #include #include #include #include -#include +#include +#include + #include "sysinstall.h" static int @@ -251,7 +257,8 @@ int mediaSetFTP(dialogMenuItem *self) { static Device ftpDevice; - char *cp; + char *cp, *hostname, *dir; + extern int FtpPort; if (!dmenuOpenSimple(&MenuMediaFTP)) return DITEM_FAILURE | DITEM_RESTORE | DITEM_RECREATE; @@ -281,6 +288,28 @@ mediaSetFTP(dialogMenuItem *self) if (!tcpDeviceSelect()) return DITEM_FAILURE | DITEM_RESTORE | DITEM_RECREATE; + hostname = cp + 6; + if ((cp = index(hostname, ':')) != NULL) { + *(cp++) = '\0'; + FtpPort = strtol(cp, 0, 0); + } + else + FtpPort = 21; + if ((dir = index(cp ? cp : hostname, '/')) != NULL) + *(dir++) = '\0'; + if (isDebug()) { + msgDebug("hostname = `%s'\n", hostname); + msgDebug("dir = `%s'\n", dir ? dir : "/"); + msgDebug("port # = `%d'\n", FtpPort); + } + msgNotify("Looking up host %s..", hostname); + if ((gethostbyname(hostname) == NULL) && (inet_addr(hostname) == INADDR_NONE)) { + msgConfirm("Cannot resolve hostname `%s'! Are you sure that your\n" + "name server, gateway and network interface are correctly configured?", hostname); + return DITEM_FAILURE | DITEM_RESTORE | DITEM_RECREATE; + } + variable_set2(VAR_FTP_HOST, hostname); + variable_set2(VAR_FTP_DIR, dir ? dir : "/"); ftpDevice.type = DEVICE_TYPE_FTP; ftpDevice.init = mediaInitFTP; @@ -331,17 +360,30 @@ int mediaSetNFS(dialogMenuItem *self) { static Device nfsDevice; - char *cp; + char *cp, *idx; cp = variable_get_value(VAR_NFS_PATH, "Please enter the full NFS file specification for the remote\n" "host and directory containing the FreeBSD distribution files.\n" "This should be in the format: hostname:/some/freebsd/dir"); if (!cp) return DITEM_FAILURE; + if (!(idx = index(cp, ':'))) { + msgConfirm("Invalid NFS path specification. Must be of the form:\n" + "host:/full/pathname/to/FreeBSD/distdir"); + return DITEM_FAILURE; + } strncpy(nfsDevice.name, cp, DEV_NAME_MAX); /* str == NULL means we were just called to change NFS paths, not network interfaces */ if (!tcpDeviceSelect()) return DITEM_FAILURE; + *idx = '\0'; + msgNotify("Looking up host %s..", cp); + if ((gethostbyname(cp) == NULL) && (inet_addr(cp) == INADDR_NONE)) { + msgConfirm("Cannot resolve hostname `%s'! Are you sure that your\n" + "name server, gateway and network interface are correctly configured?", cp); + return DITEM_FAILURE; + } + variable_set2(VAR_NFS_HOST, cp); nfsDevice.type = DEVICE_TYPE_NFS; nfsDevice.init = mediaInitNFS; nfsDevice.get = mediaGetNFS; diff --git a/release/sysinstall/menus.c b/release/sysinstall/menus.c index ec43b9a..2916fcc 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.66 1996/06/12 17:09:32 jkh Exp $ + * $Id: menus.c,v 1.67 1996/06/13 17:07:39 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -210,7 +210,7 @@ option by pressing [ENTER].", /* prompt */ "Press F1 for usage instructions", /* help line */ "usage", /* help file */ { { "1 Usage", "Quick start - How to use this menu system", NULL, dmenuDisplayFile, NULL, "usage" }, - { "2 Doc", "More detailed documentation on FreeBSD", NULL, dmenuSubmenu, NULL, &MenuDocumentation }, + { "2 Doc", "Installation instructions, README, etc.", NULL, dmenuSubmenu, NULL, &MenuDocumentation }, { "3 Options", "Go to the options editor", NULL, optionsEditor }, { "4 Novice", "Begin a novice installation (for beginners)", NULL, installNovice }, { "5 Express", "Begin a quick installation (for the impatient)", NULL, installExpress }, diff --git a/release/sysinstall/sysinstall.h b/release/sysinstall/sysinstall.h index fc8463a..47b9570 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.60 1996/06/12 14:20:20 jkh Exp $ + * $Id: sysinstall.h,v 1.61 1996/06/14 14:33:59 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -91,12 +91,14 @@ #define VAR_DOMAINNAME "domainname" #define VAR_EDITOR "editor" #define VAR_EXTRAS "ifconfig_" +#define VAR_FTP_DIR "ftpDirectory" #define VAR_FTP_ONERROR "ftpOnError" #define VAR_FTP_PASS "ftpPass" #define VAR_FTP_PATH "ftp" #define VAR_FTP_RETRIES "ftpRetryCount" #define VAR_FTP_STATE "ftpState" #define VAR_FTP_USER "ftpUser" +#define VAR_FTP_HOST "ftpHost" #define VAR_GATED "gated" #define VAR_GATEWAY "defaultrouter" #define VAR_GEOMETRY "geometry" @@ -110,6 +112,7 @@ #define VAR_NAMESERVER "nameserver" #define VAR_NETMASK "netmask" #define VAR_NFS_PATH "nfs" +#define VAR_NFS_HOST "nfsHost" #define VAR_NFS_SECURE "nfsSecure" #define VAR_NFS_SERVER "nfs_server" #define VAR_NO_CONFIRM "noConfirm" -- cgit v1.1