diff --git a/usr.sbin/sade/dispatch.c b/usr.sbin/sade/dispatch.c index 4896b235c146..b1d0099b6803 100644 --- a/usr.sbin/sade/dispatch.c +++ b/usr.sbin/sade/dispatch.c @@ -1,440 +1,448 @@ /* * The new sysinstall program. * * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * * $FreeBSD$ * * 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. * * 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 #include #include #include #include "list.h" static int dispatch_shutdown(dialogMenuItem *unused); static int dispatch_systemExecute(dialogMenuItem *unused); static int dispatch_msgConfirm(dialogMenuItem *unused); +static int dispatch_mediaOpen(dialogMenuItem *unused); static int dispatch_mediaClose(dialogMenuItem *unused); static struct _word { char *name; int (*handler)(dialogMenuItem *self); } resWords[] = { { "configAnonFTP", configAnonFTP }, { "configRouter", configRouter }, { "configInetd", configInetd }, { "configNFSServer", configNFSServer }, { "configNTP", configNTP }, { "configPCNFSD", configPCNFSD }, { "configPackages", configPackages }, { "configUsers", configUsers }, #ifdef WITH_SLICES { "diskPartitionEditor", diskPartitionEditor }, #endif { "diskPartitionWrite", diskPartitionWrite }, { "diskLabelEditor", diskLabelEditor }, { "diskLabelCommit", diskLabelCommit }, { "distReset", distReset }, { "distSetCustom", distSetCustom }, { "distUnsetCustom", distUnsetCustom }, { "distSetDeveloper", distSetDeveloper }, { "distSetXDeveloper", distSetXDeveloper }, { "distSetKernDeveloper", distSetKernDeveloper }, { "distSetUser", distSetUser }, { "distSetXUser", distSetXUser }, { "distSetMinimum", distSetMinimum }, { "distSetEverything", distSetEverything }, { "distSetSrc", distSetSrc }, { "distExtractAll", distExtractAll }, { "docBrowser", docBrowser }, { "docShowDocument", docShowDocument }, { "installCommit", installCommit }, { "installExpress", installExpress }, { "installStandard", installStandard }, { "installUpgrade", installUpgrade }, { "installFixupBase", installFixupBase }, { "installFixitHoloShell", installFixitHoloShell }, { "installFixitCDROM", installFixitCDROM }, { "installFixitFloppy", installFixitFloppy }, { "installFilesystems", installFilesystems }, { "installVarDefaults", installVarDefaults }, { "loadConfig", dispatch_load_file }, { "loadFloppyConfig", dispatch_load_floppy }, + { "mediaOpen", dispatch_mediaOpen }, { "mediaClose", dispatch_mediaClose }, { "mediaSetCDROM", mediaSetCDROM }, { "mediaSetFloppy", mediaSetFloppy }, { "mediaSetDOS", mediaSetDOS }, { "mediaSetTape", mediaSetTape }, { "mediaSetFTP", mediaSetFTP }, { "mediaSetFTPActive", mediaSetFTPActive }, { "mediaSetFTPPassive", mediaSetFTPPassive }, { "mediaSetHTTP", mediaSetHTTP }, { "mediaSetUFS", mediaSetUFS }, { "mediaSetNFS", mediaSetNFS }, { "mediaSetFTPUserPass", mediaSetFTPUserPass }, { "mediaSetCPIOVerbosity", mediaSetCPIOVerbosity }, { "mediaGetType", mediaGetType }, { "msgConfirm", dispatch_msgConfirm }, { "optionsEditor", optionsEditor }, { "packageAdd", packageAdd }, { "addGroup", userAddGroup }, { "addUser", userAddUser }, { "shutdown", dispatch_shutdown }, { "system", dispatch_systemExecute }, { "dumpVariables", dump_variables }, { "tcpMenuSelect", tcpMenuSelect }, { NULL, NULL }, }; /* * Helper routines for buffering data. * * We read an entire configuration into memory before executing it * so that we are truely standalone and can do things like nuke the * file or disk we're working on. */ typedef struct command_buffer_ { qelement queue; char * string; } command_buffer; static void dispatch_free_command(command_buffer *item) { REMQUE(item); free(item->string); free(item); } static void dispatch_free_all(qelement *head) { command_buffer *item; while (!EMPTYQUE(*head)) { item = (command_buffer *) head->q_forw; dispatch_free_command(item); } } static command_buffer * dispatch_add_command(qelement *head, char *string) { command_buffer *new; new = malloc(sizeof(command_buffer)); if (!new) return NULL; new->string = strdup(string); INSQUEUE(new, head->q_back); return new; } /* * Command processing */ /* Just convenience */ static int dispatch_shutdown(dialogMenuItem *unused) { systemShutdown(0); return DITEM_FAILURE; } static int dispatch_systemExecute(dialogMenuItem *unused) { char *cmd = variable_get(VAR_COMMAND); if (cmd) return systemExecute(cmd) ? DITEM_FAILURE : DITEM_SUCCESS; else msgDebug("_systemExecute: No command passed in `command' variable.\n"); return DITEM_FAILURE; } static int dispatch_msgConfirm(dialogMenuItem *unused) { char *msg = variable_get(VAR_COMMAND); if (msg) { msgConfirm("%s", msg); return DITEM_SUCCESS; } msgDebug("_msgConfirm: No message passed in `command' variable.\n"); return DITEM_FAILURE; } +static int +dispatch_mediaOpen(dialogMenuItem *unused) +{ + return mediaOpen(); +} + static int dispatch_mediaClose(dialogMenuItem *unused) { mediaClose(); return DITEM_SUCCESS; } static int call_possible_resword(char *name, dialogMenuItem *value, int *status) { int i, rval; rval = 0; for (i = 0; resWords[i].name; i++) { if (!strcmp(name, resWords[i].name)) { *status = resWords[i].handler(value); rval = 1; break; } } return rval; } /* For a given string, call it or spit out an undefined command diagnostic */ int dispatchCommand(char *str) { int i; char *cp; if (!str || !*str) { msgConfirm("Null or zero-length string passed to dispatchCommand"); return DITEM_FAILURE; } /* If it's got a newline, trim it */ if ((cp = index(str, '\n')) != NULL) *cp = '\0'; /* If it's got a `=' sign in there, assume it's a variable setting */ if (index(str, '=')) { if (isDebug()) msgDebug("dispatch: setting variable `%s'\n", str); variable_set(str, 0); i = DITEM_SUCCESS; } else { /* A command might be a pathname if it's encoded in argv[0], which we also support */ if ((cp = rindex(str, '/')) != NULL) str = cp + 1; if (isDebug()) msgDebug("dispatch: calling resword `%s'\n", str); if (!call_possible_resword(str, NULL, &i)) { msgNotify("Warning: No such command ``%s''", str); i = DITEM_FAILURE; } /* * Allow a user to prefix a command with "noError" to cause * us to ignore any errors for that one command. */ if (i != DITEM_SUCCESS && variable_get(VAR_NO_ERROR)) i = DITEM_SUCCESS; variable_unset(VAR_NO_ERROR); } return i; } /* * File processing */ static qelement * dispatch_load_fp(FILE *fp) { qelement *head; char buf[BUFSIZ], *cp; head = malloc(sizeof(qelement)); if (!head) return NULL; INITQUE(*head); while (fgets(buf, sizeof buf, fp)) { if ((cp = strchr(buf, '\n')) != NULL) *cp = '\0'; if (*buf == '\0' || *buf == '#') continue; if (!dispatch_add_command(head, buf)) return NULL; } return head; } static int dispatch_execute(qelement *head) { int result = DITEM_SUCCESS; command_buffer *item; char *old_interactive; if (!head) return result | DITEM_FAILURE; old_interactive = variable_get(VAR_NONINTERACTIVE); if (old_interactive) old_interactive = strdup(old_interactive); /* save copy */ /* Hint to others that we're running from a script, should they care */ variable_set2(VAR_NONINTERACTIVE, "yes", 0); while (!EMPTYQUE(*head)) { item = (command_buffer *) head->q_forw; if (DITEM_STATUS(dispatchCommand(item->string)) != DITEM_SUCCESS) { msgConfirm("Command `%s' failed - rest of script aborted.\n", item->string); result |= DITEM_FAILURE; break; } dispatch_free_command(item); } dispatch_free_all(head); if (!old_interactive) variable_unset(VAR_NONINTERACTIVE); else { variable_set2(VAR_NONINTERACTIVE, old_interactive, 0); free(old_interactive); } return result; } int dispatch_load_file_int(int quiet) { FILE *fp; char *cp; int i; qelement *list; static const char *names[] = { "install.cfg", "/stand/install.cfg", "/tmp/install.cfg", NULL }; fp = NULL; cp = variable_get(VAR_CONFIG_FILE); if (!cp) { for (i = 0; names[i]; i++) if ((fp = fopen(names[i], "r")) != NULL) break; } else fp = fopen(cp, "r"); if (!fp) { if (!quiet) msgConfirm("Unable to open %s: %s", cp, strerror(errno)); return DITEM_FAILURE; } list = dispatch_load_fp(fp); fclose(fp); return dispatch_execute(list); } int dispatch_load_file(dialogMenuItem *self) { return dispatch_load_file_int(FALSE); } int dispatch_load_floppy(dialogMenuItem *self) { int what = DITEM_SUCCESS; extern char *distWanted; char *cp; FILE *fp; qelement *list; mediaClose(); cp = variable_get_value(VAR_INSTALL_CFG, "Specify the name of a configuration file\n" "residing on a MSDOS or UFS floppy.", 0); if (!cp || !*cp) { variable_unset(VAR_INSTALL_CFG); what |= DITEM_FAILURE; return what; } distWanted = cp; /* Try to open the floppy drive */ if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) { msgConfirm("Unable to set media device to floppy."); what |= DITEM_FAILURE; mediaClose(); return what; } if (!DEVICE_INIT(mediaDevice)) { msgConfirm("Unable to mount floppy filesystem."); what |= DITEM_FAILURE; mediaClose(); return what; } fp = DEVICE_GET(mediaDevice, cp, TRUE); if (fp) { list = dispatch_load_fp(fp); fclose(fp); mediaClose(); what |= dispatch_execute(list); } else { if (!variable_get(VAR_NO_ERROR)) msgConfirm("Configuration file '%s' not found.", cp); variable_unset(VAR_INSTALL_CFG); what |= DITEM_FAILURE; mediaClose(); } return what; } diff --git a/usr.sbin/sade/sade.8 b/usr.sbin/sade/sade.8 index aeb268e8e623..378359df56f7 100644 --- a/usr.sbin/sade/sade.8 +++ b/usr.sbin/sade/sade.8 @@ -1,920 +1,925 @@ .\" Copyright (c) 1997 .\" 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. .\" 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. .\" .\" THIS SOFTWARE IS PROVIDED BY Jordan Hubbard AND CONTRIBUTORS ``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 CONTRIBUTORS 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, 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. .\" .\" $FreeBSD$ .\" .Dd July 17, 2005 .Dt SYSINSTALL 8 .Os .Sh NAME .Nm sysinstall .Nd system installation and configuration tool .Sh SYNOPSIS .Nm .Op Ar var=value .Op Ar function .Op Ar ... .Sh DESCRIPTION The .Nm utility is used for installing and configuring .Fx systems. It is the first utility invoked by the .Fx installation boot floppy and is also available as .Pa /usr/sbin/sysinstall on newly installed .Fx systems for use in later configuring the system. .Pp The .Nm utility is generally invoked without arguments for the default behavior, where the main installation/configuration menu is presented. .Pp On those occasions where it is deemed necessary to invoke a subsystem of sysinstall directly, however, it is also possible to do so by naming the appropriate function entry points on the command line. Since this action is essentially identical to running an installation script, each command-line argument corresponding to a line of script, the reader is encouraged to read the section on scripting for more information on this feature. .Sh NOTES The .Nm utility is essentially nothing more than a monolithic C program with the ability to write MBRs and disk labels (through the services of the .Xr libdisk 3 library) and install distributions or packages onto new and existing .Fx systems. It also contains some extra intelligence for running as a replacement for .Xr init 8 when it is invoked by the .Fx installation boot procedure. It assumes very little in the way of additional utility support and performs most file system operations by calling the relevant syscalls (such as .Xr mount 2 ) directly. .Pp The .Nm utility currently uses the .Xr dialog 3 library to do user interaction with simple ANSI line graphics, color support for which is enabled by either running on a syscons VTY or some other color-capable terminal emulator (newer versions of xterm will support color when using the .Dq xterm-color termcap entry). .Pp This product is currently at the end of its life cycle and will eventually be replaced. .Sh RUNNING SCRIPTS The .Nm utility may be either driven interactively through its various internal menus or run in batch mode, driven by an external script. Such a script may be loaded and executed in one of 3 ways: .Bl -tag -width Ds .It Sy "LOAD_CONFIG_FILE" If .Nm is compiled with LOAD_CONFIG_FILE set in the environment (or in the Makefile) to some value, then that value will be used as the filename to automatically look for and load when .Nm starts up and with no user interaction required. This option is aimed primarily at large sites who wish to create a single prototype install for multiple machines with largely identical configurations and/or installation options. .It Sy "MAIN MENU" If .Nm is run interactively, that is to say in the default manner, it will bring up a main menu which contains a "load config file" option. Selecting this option will prompt for the name of a script file which it then will attempt to load from a DOS or UFS formatted floppy. .It Sy "COMMAND LINE" Each command line argument is treated as a script directive when .Nm is run in multi-user mode. Execution ends either by explicit request (e.g.\& calling the .Ar shutdown directive), upon reaching the end of the argument list or on error. .Pp For example: .Bd -literal /usr/sbin/sysinstall _ftpPath=ftp://ziggy/pub/ mediaSetFTP configPackages .Ed .Pp Would initialize .Nm for FTP installation media (using the server `ziggy') and then bring up the package installation editor, exiting when finished. .El .Sh SCRIPT SYNTAX A script is a list of one or more directives, each directive taking the form of: .Pp .Ar var=value .Pp .Ar function .Pp or .Ar #somecomment .Pp Where .Ar var=value is the assignment of some internal .Nm variable, e.g.\& "ftpPass=FuNkYChiKn", and .Ar function is the name of an internal .Nm function, e.g.\& "mediaSetFTP", and .Ar #comment is a single-line comment for documentation purposes (ignored by sysinstall). Each directive must be by itself on a single line, functions taking their arguments by examining known variable names. This requires that you be sure to assign the relevant variables before calling a function which requires them. .Pp The .Ar noError variable can be assigned before each directive: this will cause any error detected while processing the directive itself to be ignored. The value of .Ar noError will automatically reset to the default "unassigned" every time a directive is processed. .Pp When and where a function depends on the settings of one or more variables will be noted in the following table: .Pp .Sy "Function Glossary" : .Pp .Bl -tag -width indent .It configAnonFTP Invoke the Anonymous FTP configuration menu. .Pp .Sy Variables : None .It configRouter Select which routing daemon you wish to use, potentially loading any required 3rd-party routing daemons as necessary. .Pp .Sy Variables : .Bl -tag -width indent .It router can be set to the name of the desired routing daemon, e.g.\& .Dq routed or .Dq gated , otherwise it is prompted for. .El .It configNFSServer Configure host as an NFS server. .Pp .Sy Variables : None .It configNTP Configure host as a user of the Network Time Protocol. .Pp .Sy Variables : .Bl -tag -width indent .It ntpdate_flags The flags to .Xr ntpdate 8 , that is to say the name of the server to sync from. .El .It configPCNFSD Configure host to support PC NFS. .Pp .Sy Variables : .Bl -tag -width indent .It pcnfsd_pkg The name of the PCNFSD package to load if necessary (defaults to hard coded version). .El .It configPackages Bring up the interactive package management menu. .Pp .Sy Variables : None .It configUsers Add users and/or groups to the system. .Pp .Sy Variables : None .It diskPartitionEditor Invokes the disk partition (MBR) editor. .Pp .Sy Variables : .Bl -tag -width findx .It geometry The disk geometry, as a cyls/heads/sectors formatted string. Default: no change to geometry. .It partition Set to disk partitioning type or size, its value being .Ar free in order to use only remaining free space for .Fx , .Ar all to use the entire disk for .Fx but maintain a proper partition table, .Ar existing to use an existing .Fx partition (first found), .Ar exclusive to use the disk in .Dq dangerously dedicated mode or, finally, .Ar somenumber to allocate .Ar somenumber blocks of available free space to a new .Fx partition. Default: Interactive mode. .It bootManager is set to one of .Ar boot to signify the installation of a boot manager, .Ar standard to signify installation of a "standard" non-boot MGR DOS MBR or .Ar none to indicate that no change to the boot manager is desired. Default: none. .It diskInteractive If set, bring up the interactive disk partition editor. .El .Pp Note: Nothing is actually written to disk by this function, an explicit call to .Ar diskPartitionWrite being required for that to happen. .It diskPartitionWrite Causes any pending MBR changes (typically from the .Ar diskPartitionEditor function) to be written out. .Pp .Sy Variables : None .It diskLabelEditor Invokes the disk label editor. This is a bit trickier from a script since you need to essentially label everything inside each .Fx (type 0xA5) partition created by the .Ar diskPartitionEditor function, and that requires knowing a few rules about how things are laid out. When creating a script to automatically allocate disk space and partition it up, it is suggested that you first perform the installation interactively at least once and take careful notes as to what the slice names will be, then and only then hardwiring them into the script. .Pp For example, let's say you have a SCSI disk on which you have created a new .Fx partition in slice 2 (your DOS partition residing in slice 1). The slice name would be .Ar da0s2 for the whole .Fx partition .Ar ( da0s1 being your DOS primary partition). Now let's further assume that you have 500MB in this partition and you want to sub-partition that space into root, swap, var and usr file systems for .Fx . Your invocation of the .Ar diskLabelEditor function might involve setting the following variables: .Bl -tag -width findx .It Li "da0s2-1=ufs 40960 /" A 20MB root file system (all sizes are in 512 byte blocks). .It Li "da0s2-2=swap 131072 /" A 64MB swap partition. .It Li "da0s2-3=ufs 204800 /var" A 100MB /var file system. .It Li "da0s2-4=ufs 0 /usr 1" With the balance of free space (around 316MB) going to the /usr file system and with soft-updates enabled (the argument following the mount point, if non-zero, means to set the soft updates flag). .El .Pp One can also use the .Ar diskLabelEditor for mounting or erasing existing partitions as well as creating new ones. Using the previous example again, let's say that we also wanted to mount our DOS partition and make sure that an .Pa /etc/fstab entry is created for it in the new installation. Before calling the .Ar diskLabelEditor function, we simply add an additional line: .Pp .Dl "da0s1=/dos_c N" .Pp before the call. This tells the label editor that you want to mount the first slice on .Pa /dos_c and not to attempt to newfs it (not that .Nm would attempt this for a DOS partition in any case, but it could just as easily be an existing UFS partition being named here and the 2nd field is non-optional). .Pp You can also set the .Ar diskInteractive variable to request that the disk label editor use an interactive dialog to partition the disk instead of using variables to explicitly layout the disk as described above. .Pp Note: No file system data is actually written to disk until an explicit call to .Ar diskLabelCommit is made. .It diskLabelCommit Writes out all pending disklabel information and creates and/or mounts any file systems which have requests pending from the .Ar diskLabelEditor function. .Pp .Sy Variables : None .It distReset Resets all selected distributions to the empty set (no distributions selected). .Pp .Sy Variables : None .It distSetCustom Allows the selection of a custom distribution set (e.g.\& not just one of the existing "canned" sets) with no user interaction. .Pp .Sy Variables : .Bl -tag -width indent .It dists List of distributions to load. Possible distribution values are: .Bl -tag -width indentxx .It Li base The base binary distribution. .It Li doc Miscellaneous documentation .It Li games Games .It Li manpages Manual pages (unformatted) .It Li catpages Pre-formatted manual pages .It Li proflibs Profiled libraries for developers. .It Li dict Dictionary information (for tools like spell). .It Li info GNU info files and other extra docs. .It Li lib32 (amd64 only) 32-bit runtime compatibility libraries. .It Li ports The ports collection. .It Li ssecure /usr/src/secure .It Li sbase /usr/src/[top level files] .It Li scontrib /usr/src/contrib .It Li sgnu /usr/src/gnu .It Li setc /usr/src/etc .It Li sgames /usr/src/games .It Li sinclude /usr/src/include .It Li skrb5 /usr/src/kerberos5 .It Li slib /usr/src/lib .It Li slibexec /usr/src/libexec .It Li srelease /usr/src/release .It Li srescue /usr/src/rescue .It Li sbin /usr/src/bin .It Li ssbin /usr/src/sbin .It Li sshare /usr/src/share .It Li ssys /usr/src/sys .It Li subin /usr/src/usr.bin .It Li susbin /usr/src/usr.sbin .It Li ssmailcf /usr/src/usr.sbin/sendmail/cf .It Li Xbin X.Org client applications. .It Li Xlib X.Org libraries. .It Li Xman X.Org manual pages. .It Li Xdoc X.Org protocol and library documentation. .It Li Xprog X.Org imake distribution. .It Li Xsrv X.Org X server. .It Li Xnest X.Org nested X server. .It Li Xprt X.Org print server. .It Li Xvfb X.Org virtual frame-buffer X server. .It Li Xfmsc X.Org miscellaneous font set. .It Li Xf75 X.Org 75DPI font set. .It Li Xf100 X.Org 100DPI font set. .It Li Xfcyr X.Org Cyrillic font set. .It Li Xft1 X.Org Type 1 font set. .It Li Xftt X.Org TrueType font set. .It Li Xfs X.Org font server. .El .El .It distSetDeveloper Selects the standard Developer's distribution set. .Pp .Sy Variables : None .It distSetXDeveloper Selects the standard X Developer's distribution set. .Pp .Sy Variables : None .It distSetKernDeveloper Selects the standard kernel Developer's distribution set. .Pp .Sy Variables : None .It distSetUser Selects the standard user distribution set. .Pp .Sy Variables : None .It distSetXUser Selects the standard X user's distribution set. .Pp .Sy Variables : None .It distSetMinimum Selects the very minimum distribution set. .Pp .Sy Variables : None .It distSetEverything Selects the full whack - all available distributions. .Pp .Sy Variables : None .It distSetSrc Interactively select source subcomponents. .Pp .Sy Variables : None .It distSetXOrg Interactively select X.Org subcomponents. .Pp .Sy Variables : None .It distExtractAll Install all currently selected distributions (requires that media device also be selected). .Pp .Sy Variables : None .It docBrowser Install (if necessary) an HTML documentation browser and go to the HTML documentation submenu. .Pp .Sy Variables : .Bl -tag -width indent .It browserPackage The name of the browser package to try and install as necessary. Defaults to latest links package. .It browserBinary The name of the browser binary itself (if overriding the .Ar browserPackage variable). Defaults to links. .El .It installCommit Commit any and all pending changes to disk. This function is essentially shorthand for a number of more granular "commit" functions. .Pp .Sy Variables : None .It installExpress Start an "express" installation, asking few questions of the user. .Pp .Sy Variables : None .It installStandard Start a "standard" installation, the most user-friendly installation type available. .Pp .Sy Variables : None .It installUpgrade Start an upgrade installation. .Pp .Sy Variables : None .It installFixitHoloShell Start up the "emergency holographic shell" over on VTY4 if running as init. This will also happen automatically as part of the installation process unless .Ar noHoloShell is set. .Pp .Sy Variables : None .It installFixitCDROM Go into "fixit" mode, assuming a live file system CDROM currently in the drive. .Pp .Sy Variables : None .It installFixitFloppy Go into "fixit" mode, assuming an available fixit floppy disk (user will be prompted for it). .Pp .Sy Variables : None .It installFilesystems Do just the file system initialization part of an install. .Pp .Sy Variables : None .It installVarDefaults Initialize all variables to their defaults, overriding any previous settings. .Pp .Sy Variables : None .It loadConfig Sort of like an #include statement, it allows you to load one configuration file from another. .Pp .Sy Variables : .Bl -tag -width indent .It configFile The fully qualified pathname of the file to load. .El +.It mediaOpen +If a media device is set, mount it. +.Pp +.Sy Variables : +None .It mediaClose If a media device is open, close it. .Pp .Sy Variables : None .It mediaSetCDROM Select a .Fx CDROM as the installation media. .Pp .Sy Variables : None .It mediaSetFloppy Select a pre-made floppy installation set as the installation media. .Pp .Sy Variables : None .It mediaSetDOS Select an existing DOS primary partition as the installation media. The first primary partition found is used (e.g.\& C:). .Pp .Sy Variables : None .It mediaSetTape Select a tape device as the installation media. .Pp .Sy Variables : None .It mediaSetFTP Select an FTP site as the installation media. .Pp .Sy Variables : .Bl -tag -width indent .It hostname The name of the host being installed (non-optional). .It domainname The domain name of the host being installed (optional). .It defaultrouter The default router for this host (non-optional). .It netDev Which host interface to use .Ar ( ed0 or .Ar ep0 , for example. Non-optional). .It netInteractive If set, bring up the interactive network setup form even if all relevant configuration variables are already set (optional). .It ipaddr The IP address for the selected host interface (non-optional). .It netmask The netmask for the selected host interface (non-optional). .It _ftpPath The fully qualified URL of the FTP site containing the .Fx distribution you are interested in, e.g.\& .Ar ftp://ftp.FreeBSD.org/pub/FreeBSD/ . .El .It mediaSetFTPActive Alias for .Ar mediaSetFTP using "active" FTP transfer mode. .Pp .Sy Variables : Same as for .Ar mediaSetFTP . .It mediaSetFTPPassive Alias for .Ar mediaSetFTP using "passive" FTP transfer mode. .Pp .Sy Variables : Same as for .Ar mediaSetFTP . .It mediaSetHTTP Alias for .Ar mediaSetFTP using an HTTP proxy. .Pp .Sy Variables : See .Ar mediaSetFTP , plus .Bl -tag -width indent .It _httpPath The proxy to use (host:port) (non-optional). .El .It mediaSetUFS Select an existing UFS partition (mounted with the label editor) as the installation media. .Pp .Sy Variables : .Bl -tag -width indent .It ufs full /path to directory containing the .Fx distribution you are interested in. .El .It mediaSetNFS .Pp .Sy Variables : .Bl -tag -width indent .It hostname The name of the host being installed (non-optional). .It domainname The domain name of the host being installed (optional). .It defaultrouter The default router for this host (non-optional). .It netDev Which host interface to use .Ar ( ed0 or .Ar ep0 , for example. Non-optional). .It netInteractive If set, bring up the interactive network setup form even if all relevant configuration variables are already set (optional). .It ipaddr The IP address for the selected host interface (non-optional). .It netmask The netmask for the selected host interface (non-optional). .It nfs full hostname:/path specification for directory containing the .Fx distribution you are interested in. .El .It mediaSetFTPUserPass .Pp .Sy Variables : .Bl -tag -width indent .It ftpUser The username to log in as on the ftp server site. Default: ftp .It ftpPass The password to use for this username on the ftp server site. Default: user@host .El .It mediaSetCPIOVerbosity .Pp .Sy Variables : .Bl -tag -width indent .It cpioVerbose Can be used to set the verbosity of cpio extractions to low, medium or high. .El .It mediaGetType Interactively get the user to specify some type of media. .Pp .Sy Variables : None .It optionsEditor Invoke the interactive options editor. .Pp .Sy Variables : None .It packageAdd Try to fetch and add a package to the system (requires that a media type be set), .Pp .Sy Variables : .Bl -tag -width indent .It package The name of the package to add, e.g.\& bash-1.14.7 or ncftp-2.4.2. .El .It addGroup Invoke the interactive group editor. .Pp .Sy Variables : None .It addUser Invoke the interactive user editor. .Pp .Sy Variables : None .It shutdown Stop the script and terminate sysinstall. .Pp .Sy Variables : None .It system Execute an arbitrary command with .Xr system 3 .Pp .Sy Variables : .Bl -tag -width indent .It command The name of the command to execute. When running from a boot floppy, very minimal expectations should be made as to what is available until/unless a relatively full system installation has just been done. .El .It tcpMenuSelect Configure a network device. .Pp .Sy Variables : Same as for .Ar mediaSetFTP except that .Ar _ftpPath is not used. .El .Sh DISTRIBUTION MEDIA The following files can be used to affect the operation of .Nm when used during initial system installation. .Bl -tag -width ".Pa packages/INDEX" .It Pa cdrom.inf A text file of properties, listed one per line, that describe the contents of the media in use. The syntax for each line is simply .Dq Ar property No = Ar value . Currently, only the following properties are recognized. .Bl -tag -width ".Va CD_MACHINE_ARCH" .It Va CD_VERSION This property should be set to the .Fx version on the current media volume. For example, .Dq Li "CD_VERSION = 5.3" . .It Va CD_MACHINE_ARCH This property should be set to the architecture of the contents on this volume. This property is normally only used with .Fx products that contain CDs for different architectures, to provide better error messages if users try to install Alpha packages on an i386 machine. For example, .Dq Li "CD_MACHINE_ARCH = alpha" . .It Va CD_VOLUME In a multi-volume collection (such as the .Fx 4-CD set), the .Pa ports/INDEX file on each disc should contain the full package index for the set. The last field of the .Pa INDEX file denotes which volume the package appears on, and the .Va CD_VOLUME property here defines the volume ID of the current disc. .El .It Pa packages/INDEX The package index file. Each package is listed on a separate line with additional meta-data such as the required dependencies. This index is generated by .Dq Li "make index" from the .Xr ports 7 collection. When multi-volume support is enabled, an additional field should be added to each line indicating which media volume contains the given package. .El .Pp For information about building a full release of .Fx , please see .Xr release 7 . .Sh FILES This utility may edit the contents of .Pa /etc/rc.conf , .Pa /etc/hosts , and .Pa /etc/resolv.conf as necessary to reflect changes in the network configuration. .Sh SEE ALSO If you have a reasonably complete source tree online, take a look at .Pa /usr/src/usr.sbin/sysinstall/install.cfg for a sample installation script. .Sh HISTORY This version of .Nm first appeared in .Fx 2.0 . .Sh AUTHORS .An Jordan K. Hubbard Aq jkh@FreeBSD.org .Sh BUGS This utility is a prototype which lasted several years past its expiration date and is greatly in need of death. diff --git a/usr.sbin/sade/sade.h b/usr.sbin/sade/sade.h index d099cca5cffd..3dfc0483bf12 100644 --- a/usr.sbin/sade/sade.h +++ b/usr.sbin/sade/sade.h @@ -1,881 +1,882 @@ /* * The new sysinstall program. * * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * * 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. * * 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. * * $FreeBSD$ */ #ifndef _SYSINSTALL_H_INCLUDE #define _SYSINSTALL_H_INCLUDE #include #include #include #include #include #include #include #include #include #include "ui_objects.h" #include "dir.h" #include "colors.h" #include "dist.h" /*** Defines ***/ #if defined(__i386__) || defined(__alpha__) || defined(__amd64__) #define WITH_SYSCONS #define WITH_MICE #endif #if defined(__i386__) || defined(__amd64__) #define WITH_SLICES #endif #if defined(__i386__) || defined(__alpha__) #define WITH_LINUX #endif /* device limits */ #define DEV_NAME_MAX 128 /* The maximum length of a device name */ #define DEV_MAX 100 /* The maximum number of devices we'll deal with */ #define INTERFACE_MAX 50 /* Maximum number of network interfaces we'll deal with */ #define IO_ERROR -2 /* Status code for I/O error rather than normal EOF */ /* Number of seconds to wait for data to come off even the slowest media */ #define MEDIA_TIMEOUT 300 /* * I make some pretty gross assumptions about having a max of 50 chunks * total - 8 slices and 42 partitions. I can't easily display many more * than that on the screen at once! * * For 2.1 I'll revisit this and try to make it more dynamic, but since * this will catch 99.99% of all possible cases, I'm not too worried. */ #define MAX_CHUNKS 40 /* Internal environment variable names */ #define DISK_PARTITIONED "_diskPartitioned" #define DISK_LABELLED "_diskLabelled" #define DISK_SELECTED "_diskSelected" #define SYSTEM_STATE "_systemState" #define RUNNING_ON_ROOT "_runningOnRoot" #define TCP_CONFIGURED "_tcpConfigured" /* Ones that can be tweaked from config files */ #define VAR_BLANKTIME "blanktime" #define VAR_BOOTMGR "bootManager" #define VAR_BROWSER_BINARY "browserBinary" #define VAR_BROWSER_PACKAGE "browserPackage" #define VAR_CPIO_VERBOSITY "cpioVerbose" #define VAR_DEBUG "debug" #define VAR_DESKSTYLE "_deskStyle" #define VAR_DISK "disk" #define VAR_DISKINTERACTIVE "diskInteractive" #define VAR_DISTS "dists" #define VAR_DIST_MAIN "distMain" #define VAR_DIST_SRC "distSRC" #define VAR_DIST_X11 "distX11" #define VAR_DEDICATE_DISK "dedicateDisk" #define VAR_DOMAINNAME "domainname" #define VAR_EDITOR "editor" #define VAR_EXTRAS "ifconfig_" #define VAR_COMMAND "command" #define VAR_CONFIG_FILE "configFile" #define VAR_FIXIT_TTY "fixitTty" #define VAR_FTP_DIR "ftpDirectory" #define VAR_FTP_PASS "ftpPass" #define VAR_FTP_PATH "_ftpPath" #define VAR_FTP_PORT "ftpPort" #define VAR_FTP_STATE "ftpState" #define VAR_FTP_USER "ftpUser" #define VAR_FTP_HOST "ftpHost" #define VAR_HTTP_PATH "_httpPath" #define VAR_HTTP_PROXY "httpProxy" #define VAR_HTTP_PORT "httpPort" #define VAR_HTTP_HOST "httpHost" #define VAR_HTTP_FTP_MODE "httpFtpMode" #define VAR_GATEWAY "defaultrouter" #define VAR_GEOMETRY "geometry" #define VAR_HOSTNAME "hostname" #define VAR_IFCONFIG "ifconfig_" #define VAR_INSTALL_CFG "installConfig" #define VAR_INSTALL_ROOT "installRoot" #define VAR_IPADDR "ipaddr" #define VAR_IPV6_ENABLE "ipv6_enable" #define VAR_IPV6ADDR "ipv6addr" #define VAR_KERN_SECURELEVEL "kern_securelevel" #define VAR_KEYMAP "keymap" #define VAR_LABEL "label" #define VAR_LABEL_COUNT "labelCount" #define VAR_LINUX_ENABLE "linux_enable" #define VAR_MEDIA_TYPE "mediaType" #define VAR_MEDIA_TIMEOUT "MEDIA_TIMEOUT" #define VAR_MOUSED "moused_enable" #define VAR_MOUSED_FLAGS "moused_flags" #define VAR_MOUSED_PORT "moused_port" #define VAR_MOUSED_TYPE "moused_type" #define VAR_NAMESERVER "nameserver" #define VAR_NETINTERACTIVE "netInteractive" #define VAR_NETMASK "netmask" #define VAR_NETWORK_DEVICE "netDev" #define VAR_NEWFS_ARGS "newfsArgs" #define VAR_NFS_PATH "nfs" #define VAR_NFS_HOST "nfsHost" #define VAR_NFS_V3 "nfs_use_v3" #define VAR_NFS_TCP "nfs_use_tcp" #define VAR_NFS_SECURE "nfs_reserved_port_only" #define VAR_NFS_SERVER "nfs_server_enable" #define VAR_NO_CONFIRM "noConfirm" #define VAR_NO_ERROR "noError" #define VAR_NO_HOLOSHELL "noHoloShell" #define VAR_NO_INET6 "noInet6" #define VAR_NO_WARN "noWarn" #define VAR_NO_USR "noUsr" #define VAR_NO_TMP "noTmp" #define VAR_NO_HOME "noHome" #define VAR_NONINTERACTIVE "nonInteractive" #define VAR_NOVELL "novell" #define VAR_OSF1_ENABLE "osf1_enable" #define VAR_RPCBIND_ENABLE "rpcbind_enable" #define VAR_NTPDATE_FLAGS "ntpdate_flags" #define VAR_PACKAGE "package" #define VAR_PARTITION "partition" #define VAR_PCNFSD "pcnfsd" #define VAR_PKG_TMPDIR "PKG_TMPDIR" #define VAR_PORTS_PATH "ports" #define VAR_PPP_ENABLE "ppp_enable" #define VAR_PPP_PROFILE "ppp_profile" #define VAR_RELNAME "releaseName" #define VAR_ROOT_SIZE "rootSize" #define VAR_ROUTER "router" #define VAR_ROUTER_ENABLE "router_enable" #define VAR_ROUTERFLAGS "router_flags" #define VAR_SENDMAIL_ENABLE "sendmail_enable" #define VAR_SERIAL_SPEED "serialSpeed" #define VAR_SLOW_ETHER "slowEthernetCard" #define VAR_SWAP_SIZE "swapSize" #define VAR_TAPE_BLOCKSIZE "tapeBlocksize" #define VAR_TRY_DHCP "tryDHCP" #define VAR_TRY_RTSOL "tryRTSOL" #define VAR_SKIP_PCCARD "skipPCCARD" #define VAR_UFS_PATH "ufs" #define VAR_USR_SIZE "usrSize" #define VAR_VAR_SIZE "varSize" #define VAR_TMP_SIZE "tmpSize" #define VAR_HOME_SIZE "homeSize" #define VAR_XORG_CONFIG "_xorgconfig" #define VAR_TERM "TERM" #define VAR_CONSTERM "_consterm" #define DEFAULT_TAPE_BLOCKSIZE "20" /* One MB worth of blocks */ #define ONE_MEG 2048 #define ONE_GIG (ONE_MEG * 1024) /* Which selection attributes to use */ #define ATTR_SELECTED (ColorDisplay ? item_selected_attr : item_attr) #define ATTR_TITLE button_active_attr /* Handy strncpy() macro */ #define SAFE_STRCPY(to, from) sstrncpy((to), (from), sizeof (to) - 1) /*** Types ***/ typedef int Boolean; typedef struct disk Disk; typedef struct chunk Chunk; /* Bitfields for menu options */ #define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */ #define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */ #define DMENU_CHECKLIST_TYPE 0x4 /* Multiple choice menu */ #define DMENU_SELECTION_RETURNS 0x8 /* Immediate return on item selection */ typedef struct _dmenu { int type; /* What sort of menu we are */ char *title; /* Our title */ char *prompt; /* Our prompt */ char *helpline; /* Line of help at bottom */ char *helpfile; /* Help file for "F1" */ #if (__STDC_VERSION__ >= 199901L) || (__GNUC__ >= 3) dialogMenuItem items[]; /* Array of menu items */ #elif __GNUC__ dialogMenuItem items[0]; /* Array of menu items */ #else #error "Create hack for C89 and K&R compilers." #endif } DMenu; /* An rc.conf variable */ typedef struct _variable { struct _variable *next; char *name; char *value; int dirty; } Variable; #define NO_ECHO_OBJ(type) ((type) | (DITEM_NO_ECHO << 16)) #define TYPE_OF_OBJ(type) ((type) & 0xff) #define ATTR_OF_OBJ(type) ((type) >> 16) /* A screen layout structure */ typedef struct _layout { int y; /* x & Y co-ordinates */ int x; int len; /* The size of the dialog on the screen */ int maxlen; /* How much the user can type in ... */ char *prompt; /* The string for the prompt */ char *help; /* The display for the help line */ void *var; /* The var to set when this changes */ int type; /* The type of the dialog to create */ void *obj; /* The obj pointer returned by libdialog */ } Layout; typedef enum { DEVICE_TYPE_NONE, DEVICE_TYPE_DISK, DEVICE_TYPE_FLOPPY, DEVICE_TYPE_FTP, DEVICE_TYPE_NETWORK, DEVICE_TYPE_CDROM, DEVICE_TYPE_TAPE, DEVICE_TYPE_DOS, DEVICE_TYPE_UFS, DEVICE_TYPE_NFS, DEVICE_TYPE_ANY, DEVICE_TYPE_HTTP, } DeviceType; /* CDROM mount codes */ #define CD_UNMOUNTED 0 #define CD_ALREADY_MOUNTED 1 #define CD_WE_MOUNTED_IT 2 /* A "device" from sysinstall's point of view */ typedef struct _device { char name[DEV_NAME_MAX]; char *description; char *devname; DeviceType type; Boolean enabled; Boolean (*init)(struct _device *dev); FILE * (*get)(struct _device *dev, char *file, Boolean probe); void (*shutdown)(struct _device *dev); void *private; unsigned int flags; unsigned int volume; } Device; /* Some internal representations of partitions */ typedef enum { PART_NONE, PART_SLICE, PART_SWAP, PART_FILESYSTEM, PART_FAT, PART_EFI } PartType; #define NEWFS_UFS_CMD "newfs" #define NEWFS_MSDOS_CMD "newfs_msdos" enum newfs_type { NEWFS_UFS, NEWFS_MSDOS, NEWFS_CUSTOM }; #define NEWFS_UFS_STRING "UFS" #define NEWFS_MSDOS_STRING "FAT" #define NEWFS_CUSTOM_STRING "CST" /* The longest set of custom command line arguments we'll pass. */ #define NEWFS_CMD_ARGS_MAX 256 typedef struct _part_info { char mountpoint[FILENAME_MAX]; /* Is invocation of newfs desired? */ Boolean do_newfs; enum newfs_type newfs_type; union { struct { char user_options[NEWFS_CMD_ARGS_MAX]; Boolean acls; /* unused */ Boolean multilabel; /* unused */ Boolean softupdates; Boolean ufs1; } newfs_ufs; struct { /* unused */ } newfs_msdos; struct { char command[NEWFS_CMD_ARGS_MAX]; } newfs_custom; } newfs_data; } PartInfo; /* An option */ typedef struct _opt { char *name; char *desc; enum { OPT_IS_STRING, OPT_IS_INT, OPT_IS_FUNC, OPT_IS_VAR } type; void *data; void *aux; char *(*check)(); } Option; /* Weird index nodey things we use for keeping track of package information */ typedef enum { PACKAGE, PLACE } node_type; /* Types of nodes */ typedef struct _pkgnode { /* A node in the reconstructed hierarchy */ struct _pkgnode *next; /* My next sibling */ node_type type; /* What am I? */ char *name; /* My name */ char *desc; /* My description (Hook) */ struct _pkgnode *kids; /* My little children */ void *data; /* A place to hang my data */ } PkgNode; typedef PkgNode *PkgNodePtr; /* A single package */ typedef struct _indexEntry { /* A single entry in an INDEX file */ char *name; /* name */ char *path; /* full path to port */ char *prefix; /* port prefix */ char *comment; /* one line description */ char *descrfile; /* path to description file */ char *deps; /* packages this depends on */ int depc; /* how many depend on me */ int installed; /* indicates if it is installed */ char *maintainer; /* maintainer */ unsigned int volume; /* Volume of package */ } IndexEntry; typedef IndexEntry *IndexEntryPtr; typedef int (*commandFunc)(char *key, void *data); #define HOSTNAME_FIELD_LEN 128 #define IPADDR_FIELD_LEN 16 #define EXTRAS_FIELD_LEN 128 /* This is the structure that Network devices carry around in their private, erm, structures */ typedef struct _devPriv { int use_rtsol; int use_dhcp; char ipaddr[IPADDR_FIELD_LEN]; char netmask[IPADDR_FIELD_LEN]; char extras[EXTRAS_FIELD_LEN]; } DevInfo; /*** Externs ***/ extern jmp_buf BailOut; /* Used to get the heck out */ extern int CDROMInitQuiet; /* Don't whine if mount(2) fails */ extern int DebugFD; /* Where diagnostic output goes */ extern Boolean Fake; /* Don't actually modify anything - testing */ extern Boolean Restarting; /* Are we restarting sysinstall? */ extern Boolean SystemWasInstalled; /* Did we install it? */ extern Boolean RunningAsInit; /* Are we running stand-alone? */ extern Boolean DialogActive; /* Is the dialog() stuff up? */ extern Boolean ColorDisplay; /* Are we on a color display? */ extern Boolean OnVTY; /* On a syscons VTY? */ extern Variable *VarHead; /* The head of the variable chain */ extern Device *mediaDevice; /* Where we're getting our distribution from */ extern unsigned int Dists; /* Which distributions we want */ extern unsigned int SrcDists; /* Which src distributions we want */ extern unsigned int XOrgDists; /* Which X.Org dists we want */ extern int BootMgr; /* Which boot manager to use */ extern int StatusLine; /* Where to print our status messages */ extern DMenu MenuInitial; /* Initial installation menu */ extern DMenu MenuFixit; /* Fixit repair menu */ #if defined(__i386__) || defined(__amd64__) #ifdef PC98 extern DMenu MenuIPLType; /* Type of IPL to write on the disk */ #else extern DMenu MenuMBRType; /* Type of MBR to write on the disk */ #endif #endif extern DMenu MenuConfigure; /* Final configuration menu */ extern DMenu MenuDocumentation; /* Documentation menu */ extern DMenu MenuFTPOptions; /* FTP Installation options */ extern DMenu MenuIndex; /* Index menu */ extern DMenu MenuOptions; /* Installation options */ extern DMenu MenuOptionsLanguage; /* Language options menu */ extern DMenu MenuKLD; /* Prototype KLD menu */ extern DMenu MenuMedia; /* Media type menu */ #ifdef WITH_MICE extern DMenu MenuMouse; /* Mouse type menu */ #endif extern DMenu MenuMediaCDROM; /* CDROM media menu */ extern DMenu MenuMediaDOS; /* DOS media menu */ extern DMenu MenuMediaFloppy; /* Floppy media menu */ extern DMenu MenuMediaFTP; /* FTP media menu */ extern DMenu MenuMediaTape; /* Tape media menu */ extern DMenu MenuNetworkDevice; /* Network device menu */ extern DMenu MenuNTP; /* NTP time server menu */ extern DMenu MenuSecurity; /* System security options menu */ extern DMenu MenuSecurelevel; /* Securelevel menu */ extern DMenu MenuStartup; /* Startup services menu */ #ifdef WITH_SYSCONS extern DMenu MenuSyscons; /* System console configuration menu */ extern DMenu MenuSysconsFont; /* System console font configuration menu */ extern DMenu MenuSysconsKeymap; /* System console keymap configuration menu */ extern DMenu MenuSysconsKeyrate; /* System console keyrate configuration menu */ extern DMenu MenuSysconsSaver; /* System console saver configuration menu */ extern DMenu MenuSysconsScrnmap; /* System console screenmap configuration menu */ extern DMenu MenuSysconsTtys; /* System console terminal type menu */ #endif extern DMenu MenuNetworking; /* Network configuration menu */ extern DMenu MenuMTA; /* MTA selection menu */ extern DMenu MenuInstallCustom; /* Custom Installation menu */ extern DMenu MenuDistributions; /* Distribution menu */ extern DMenu MenuDiskDevices; /* Disk type devices */ extern DMenu MenuSubDistributions; /* Custom distribution menu */ extern DMenu MenuSrcDistributions; /* Source distribution menu */ extern DMenu MenuXOrg; /* X.Org main menu */ extern DMenu MenuXOrgSelect; /* X.Org distribution selection menu */ extern DMenu MenuXOrgSelectCore; /* X.Org core distribution menu */ extern DMenu MenuXOrgSelectServer; /* X.Org server distribution menu */ extern DMenu MenuXOrgSelectFonts; /* X.Org font selection menu */ extern DMenu MenuXDesktops; /* X Desktops menu */ extern DMenu MenuHTMLDoc; /* HTML Documentation menu */ extern DMenu MenuUsermgmt; /* User management menu */ extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */ extern DMenu MenuXOrgConfig; /* Select X.Org configuration tool */ extern int FixItMode; /* FixItMode starts shell onc urrent device (ie Serial port) */ extern const char * StartName; /* Which name we were started as */ /* Important chunks. */ extern Chunk *HomeChunk; extern Chunk *RootChunk; extern Chunk *SwapChunk; extern Chunk *TmpChunk; extern Chunk *UsrChunk; extern Chunk *VarChunk; #ifdef __ia64__ extern Chunk *EfiChunk; #endif /* Stuff from libdialog which isn't properly declared outside */ extern void display_helpfile(void); extern void display_helpline(WINDOW *w, int y, int width); /*** Prototypes ***/ /* anonFTP.c */ extern int configAnonFTP(dialogMenuItem *self); /* cdrom.c */ extern Boolean mediaInitCDROM(Device *dev); extern FILE *mediaGetCDROM(Device *dev, char *file, Boolean probe); extern void mediaShutdownCDROM(Device *dev); /* command.c */ extern void command_clear(void); extern void command_sort(void); extern void command_execute(void); extern void command_shell_add(char *key, char *fmt, ...) __printflike(2, 3); extern void command_func_add(char *key, commandFunc func, void *data); /* config.c */ extern void configEnvironmentRC_conf(void); extern void configEnvironmentResolv(char *config); extern void configRC_conf(void); extern int configFstab(dialogMenuItem *self); extern int configRC(dialogMenuItem *self); extern int configResolv(dialogMenuItem *self); extern int configPackages(dialogMenuItem *self); extern int configSaver(dialogMenuItem *self); extern int configSaverTimeout(dialogMenuItem *self); #ifdef WITH_LINUX extern int configLinux(dialogMenuItem *self); #endif extern int configNTP(dialogMenuItem *self); #ifdef __alpha__ extern int configOSF1(dialogMenuItem *self); #endif extern int configUsers(dialogMenuItem *self); extern int configRouter(dialogMenuItem *self); extern int configPCNFSD(dialogMenuItem *self); extern int configInetd(dialogMenuItem *self); extern int configNFSServer(dialogMenuItem *self); extern int configMTAPostfix(dialogMenuItem *self); extern int configMTAExim(dialogMenuItem *self); extern int configRpcBind(dialogMenuItem *self); extern int configWriteRC_conf(dialogMenuItem *self); extern int configSecurelevel(dialogMenuItem *self); extern int configSecurelevelDisabled(dialogMenuItem *self); extern int configSecurelevelSecure(dialogMenuItem *self); extern int configSecurelevelHighlySecure(dialogMenuItem *self); extern int configSecurelevelNetworkSecure(dialogMenuItem *self); extern int configEtcTtys(dialogMenuItem *self); #ifdef __i386__ extern int checkLoaderACPI(void); extern int configLoaderACPI(int); #endif /* devices.c */ extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), int (*check)(dialogMenuItem *d)); extern void deviceGetAll(void); extern void deviceReset(void); extern void deviceRescan(void); extern Device **deviceFind(char *name, DeviceType type); extern Device **deviceFindDescr(char *name, char *desc, DeviceType class); extern int deviceCount(Device **devs); extern Device *new_device(char *name); extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled, Boolean (*init)(Device *mediadev), FILE * (*get)(Device *dev, char *file, Boolean probe), void (*shutDown)(Device *mediadev), void *private); extern Boolean dummyInit(Device *dev); extern FILE *dummyGet(Device *dev, char *dist, Boolean probe); extern void dummyShutdown(Device *dev); /* dhcp.c */ extern int dhcpParseLeases(char *file, char *hostname, char *domain, char *nameserver, char *ipaddr, char *gateway, char *netmask); /* disks.c */ #ifdef WITH_SLICES extern void diskPartition(Device *dev); extern int diskPartitionEditor(dialogMenuItem *self); #endif extern int diskPartitionWrite(dialogMenuItem *self); extern int diskGetSelectCount(Device ***devs); /* dispatch.c */ extern int dispatchCommand(char *command); extern int dispatch_load_floppy(dialogMenuItem *self); extern int dispatch_load_file_int(int); extern int dispatch_load_file(dialogMenuItem *self); /* dist.c */ extern int distReset(dialogMenuItem *self); extern int distConfig(dialogMenuItem *self); extern int distSetCustom(dialogMenuItem *self); extern int distUnsetCustom(dialogMenuItem *self); extern int distSetDeveloper(dialogMenuItem *self); extern int distSetXDeveloper(dialogMenuItem *self); extern int distSetKernDeveloper(dialogMenuItem *self); extern int distSetXKernDeveloper(dialogMenuItem *self); extern int distSetUser(dialogMenuItem *self); extern int distSetXUser(dialogMenuItem *self); extern int distSetMinimum(dialogMenuItem *self); extern int distSetEverything(dialogMenuItem *self); extern int distSetSrc(dialogMenuItem *self); extern int distSetXOrg(dialogMenuItem *self); extern int distExtractAll(dialogMenuItem *self); /* dmenu.c */ extern int dmenuDisplayFile(dialogMenuItem *tmp); extern int dmenuSubmenu(dialogMenuItem *tmp); extern int dmenuSystemCommand(dialogMenuItem *tmp); extern int dmenuSystemCommandBox(dialogMenuItem *tmp); extern int dmenuExit(dialogMenuItem *tmp); extern int dmenuISetVariable(dialogMenuItem *tmp); extern int dmenuSetVariable(dialogMenuItem *tmp); extern int dmenuSetKmapVariable(dialogMenuItem *tmp); extern int dmenuSetVariables(dialogMenuItem *tmp); extern int dmenuToggleVariable(dialogMenuItem *tmp); extern int dmenuSetFlag(dialogMenuItem *tmp); extern int dmenuSetValue(dialogMenuItem *tmp); extern Boolean dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons); extern Boolean dmenuOpenSimple(DMenu *menu, Boolean buttons); extern int dmenuVarCheck(dialogMenuItem *item); extern int dmenuVarsCheck(dialogMenuItem *item); extern int dmenuFlagCheck(dialogMenuItem *item); extern int dmenuRadioCheck(dialogMenuItem *item); /* doc.c */ extern int docBrowser(dialogMenuItem *self); extern int docShowDocument(dialogMenuItem *self); /* dos.c */ extern Boolean mediaCloseDOS(Device *dev, FILE *fp); extern Boolean mediaInitDOS(Device *dev); extern FILE *mediaGetDOS(Device *dev, char *file, Boolean probe); extern void mediaShutdownDOS(Device *dev); /* floppy.c */ extern int getRootFloppy(void); extern Boolean mediaInitFloppy(Device *dev); extern FILE *mediaGetFloppy(Device *dev, char *file, Boolean probe); extern void mediaShutdownFloppy(Device *dev); /* ftp_strat.c */ extern Boolean mediaCloseFTP(Device *dev, FILE *fp); extern Boolean mediaInitFTP(Device *dev); extern FILE *mediaGetFTP(Device *dev, char *file, Boolean probe); extern void mediaShutdownFTP(Device *dev); /* http.c */ extern Boolean mediaInitHTTP(Device *dev); extern FILE *mediaGetHTTP(Device *dev, char *file, Boolean probe); /* globals.c */ extern void globalsInit(void); /* index.c */ int index_read(FILE *fp, PkgNodePtr papa); int index_menu(PkgNodePtr root, PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll); void index_init(PkgNodePtr top, PkgNodePtr plist); void index_node_free(PkgNodePtr top, PkgNodePtr plist); void index_sort(PkgNodePtr top); void index_print(PkgNodePtr top, int level); int index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended); int index_initialize(char *path); PkgNodePtr index_search(PkgNodePtr top, char *str, PkgNodePtr *tp); /* install.c */ extern Boolean checkLabels(Boolean whinge); extern int installCommit(dialogMenuItem *self); extern int installCustomCommit(dialogMenuItem *self); extern int installExpress(dialogMenuItem *self); extern int installStandard(dialogMenuItem *self); extern int installFixitHoloShell(dialogMenuItem *self); extern int installFixitCDROM(dialogMenuItem *self); extern int installFixitFloppy(dialogMenuItem *self); extern int installFixupBase(dialogMenuItem *self); extern int installUpgrade(dialogMenuItem *self); extern int installFilesystems(dialogMenuItem *self); extern int installVarDefaults(dialogMenuItem *self); extern void installEnvironment(void); extern Boolean copySelf(void); /* kget.c */ extern int kget(char *out); /* keymap.c */ extern int loadKeymap(const char *lang); /* label.c */ extern int diskLabelEditor(dialogMenuItem *self); extern int diskLabelCommit(dialogMenuItem *self); /* makedevs.c (auto-generated) */ extern const char termcap_ansi[]; extern const char termcap_vt100[]; extern const char termcap_cons25w[]; extern const char termcap_cons25[]; extern const char termcap_cons25_m[]; extern const char termcap_cons25r[]; extern const char termcap_cons25r_m[]; extern const char termcap_cons25l1[]; extern const char termcap_cons25l1_m[]; extern const char termcap_xterm[]; extern const u_char font_iso_8x16[]; extern const u_char font_cp850_8x16[]; extern const u_char font_cp866_8x16[]; extern const u_char koi8_r2cp866[]; extern u_char default_scrnmap[]; /* media.c */ extern char *cpioVerbosity(void); +extern int mediaOpen(void); extern void mediaClose(void); extern int mediaTimeout(void); extern int mediaSetCDROM(dialogMenuItem *self); extern int mediaSetFloppy(dialogMenuItem *self); extern int mediaSetDOS(dialogMenuItem *self); extern int mediaSetTape(dialogMenuItem *self); extern int mediaSetFTP(dialogMenuItem *self); extern int mediaSetFTPActive(dialogMenuItem *self); extern int mediaSetFTPPassive(dialogMenuItem *self); extern int mediaSetHTTP(dialogMenuItem *self); extern int mediaSetUFS(dialogMenuItem *self); extern int mediaSetNFS(dialogMenuItem *self); extern int mediaSetFTPUserPass(dialogMenuItem *self); extern int mediaSetCPIOVerbosity(dialogMenuItem *self); extern int mediaGetType(dialogMenuItem *self); extern Boolean mediaExtractDist(char *dir, char *dist, FILE *fp); extern Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpic); extern Boolean mediaExtractDistEnd(int zpid, int cpid); extern Boolean mediaVerify(void); extern FILE *mediaGenericGet(char *base, const char *file); /* misc.c */ extern Boolean file_readable(char *fname); extern Boolean file_executable(char *fname); extern Boolean directory_exists(const char *dirname); extern char *root_bias(char *path); extern char *itoa(int value); extern char *string_concat(char *p1, char *p2); extern char *string_concat3(char *p1, char *p2, char *p3); extern char *string_prune(char *str); extern char *string_skipwhite(char *str); extern char *string_copy(char *s1, char *s2); extern char *pathBaseName(const char *path); extern void safe_free(void *ptr); extern void *safe_malloc(size_t size); extern void *safe_realloc(void *orig, size_t size); extern dialogMenuItem *item_add(dialogMenuItem *list, char *prompt, char *title, int (*checked)(dialogMenuItem *self), int (*fire)(dialogMenuItem *self), void (*selected)(dialogMenuItem *self, int is_selected), void *data, int *aux, int *curr, int *max); extern void items_free(dialogMenuItem *list, int *curr, int *max); extern int Mkdir(char *); extern int Mkdir_command(char *key, void *data); extern int Mount(char *, void *data); extern int Mount_msdosfs(char *mountp, void *devname); extern WINDOW *openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height); extern ComposeObj *initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max); extern int layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, int *n, int max, int *cbutton, int *cancel); extern WINDOW *savescr(void); extern void restorescr(WINDOW *w); extern char *sstrncpy(char *dst, const char *src, int size); /* modules.c */ extern void driverFloppyCheck(void); extern void moduleInitialize(void); extern int kldBrowser(dialogMenuItem *self); /* mouse.c */ extern int mousedTest(dialogMenuItem *self); extern int mousedDisable(dialogMenuItem *self); extern int setMouseFlags(dialogMenuItem *self); /* msg.c */ extern Boolean isDebug(void); extern void msgInfo(char *fmt, ...) __printf0like(1, 2); extern void msgYap(char *fmt, ...) __printflike(1, 2); extern void msgWarn(char *fmt, ...) __printflike(1, 2); extern void msgDebug(char *fmt, ...) __printflike(1, 2); extern void msgError(char *fmt, ...) __printflike(1, 2); extern void msgFatal(char *fmt, ...) __printflike(1, 2); extern void msgConfirm(char *fmt, ...) __printflike(1, 2); extern void msgNotify(char *fmt, ...) __printflike(1, 2); extern void msgWeHaveOutput(char *fmt, ...) __printflike(1, 2); extern int msgYesNo(char *fmt, ...) __printflike(1, 2); extern int msgNoYes(char *fmt, ...) __printflike(1, 2); extern char *msgGetInput(char *buf, char *fmt, ...) __printflike(2, 3); extern int msgSimpleConfirm(char *); extern int msgSimpleNotify(char *); /* network.c */ extern Boolean mediaInitNetwork(Device *dev); extern void mediaShutdownNetwork(Device *dev); /* nfs.c */ extern Boolean mediaInitNFS(Device *dev); extern FILE *mediaGetNFS(Device *dev, char *file, Boolean probe); extern void mediaShutdownNFS(Device *dev); /* options.c */ extern int optionsEditor(dialogMenuItem *self); /* package.c */ extern int packageAdd(dialogMenuItem *self); extern int package_add(char *name); extern int package_extract(Device *dev, char *name, Boolean depended); extern Boolean package_installed(char *name); /* pccard.c */ extern void pccardInitialize(void); /* system.c */ extern void systemInitialize(int argc, char **argv); extern void systemShutdown(int status); extern int execExecute(char *cmd, char *name); extern int systemExecute(char *cmd); extern void systemSuspendDialog(void); extern void systemResumeDialog(void); extern int systemDisplayHelp(char *file); extern char *systemHelpFile(char *file, char *buf); extern void systemChangeFont(const u_char font[]); extern void systemChangeLang(char *lang); extern void systemChangeTerminal(char *color, const u_char c_termcap[], char *mono, const u_char m_termcap[]); extern void systemChangeScreenmap(const u_char newmap[]); extern void systemCreateHoloshell(void); extern int vsystem(char *fmt, ...) __printflike(1, 2); /* tape.c */ extern char *mediaTapeBlocksize(void); extern Boolean mediaInitTape(Device *dev); extern FILE *mediaGetTape(Device *dev, char *file, Boolean probe); extern void mediaShutdownTape(Device *dev); /* tcpip.c */ extern int tcpOpenDialog(Device *dev); extern int tcpMenuSelect(dialogMenuItem *self); extern Device *tcpDeviceSelect(void); /* termcap.c */ extern int set_termcap(void); /* ttys.c */ extern void configTtys(void); /* ufs.c */ extern void mediaShutdownUFS(Device *dev); extern Boolean mediaInitUFS(Device *dev); extern FILE *mediaGetUFS(Device *dev, char *file, Boolean probe); /* user.c */ extern int userAddGroup(dialogMenuItem *self); extern int userAddUser(dialogMenuItem *self); /* variable.c */ extern void variable_set(char *var, int dirty); extern void variable_set2(char *name, char *value, int dirty); extern char *variable_get(char *var); extern int variable_cmp(char *var, char *value); extern void variable_unset(char *var); extern char *variable_get_value(char *var, char *prompt, int dirty); extern int variable_check(char *data); extern int variable_check2(char *data); extern int dump_variables(dialogMenuItem *self); extern void free_variables(void); extern void pvariable_set(char *var); extern char *pvariable_get(char *var); /* wizard.c */ extern void slice_wizard(Disk *d); /* * Macros. Please find a better place for us! */ #define DEVICE_INIT(d) ((d) != NULL ? (d)->init((d)) : (Boolean)0) #define DEVICE_GET(d, b, f) ((d) != NULL ? (d)->get((d), (b), (f)) : NULL) #define DEVICE_SHUTDOWN(d) ((d) != NULL ? (d)->shutdown((d)) : (void)0) #ifdef USE_GZIP #define UNZIPPER "gunzip" #else #define UNZIPPER "bunzip2" #endif #endif /* _SYSINSTALL_H_INCLUDE */ diff --git a/usr.sbin/sysinstall/dispatch.c b/usr.sbin/sysinstall/dispatch.c index 4896b235c146..b1d0099b6803 100644 --- a/usr.sbin/sysinstall/dispatch.c +++ b/usr.sbin/sysinstall/dispatch.c @@ -1,440 +1,448 @@ /* * The new sysinstall program. * * This is probably the last program in the `sysinstall' line - the next * generation being essentially a complete rewrite. * * $FreeBSD$ * * 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. * * 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 #include #include #include #include "list.h" static int dispatch_shutdown(dialogMenuItem *unused); static int dispatch_systemExecute(dialogMenuItem *unused); static int dispatch_msgConfirm(dialogMenuItem *unused); +static int dispatch_mediaOpen(dialogMenuItem *unused); static int dispatch_mediaClose(dialogMenuItem *unused); static struct _word { char *name; int (*handler)(dialogMenuItem *self); } resWords[] = { { "configAnonFTP", configAnonFTP }, { "configRouter", configRouter }, { "configInetd", configInetd }, { "configNFSServer", configNFSServer }, { "configNTP", configNTP }, { "configPCNFSD", configPCNFSD }, { "configPackages", configPackages }, { "configUsers", configUsers }, #ifdef WITH_SLICES { "diskPartitionEditor", diskPartitionEditor }, #endif { "diskPartitionWrite", diskPartitionWrite }, { "diskLabelEditor", diskLabelEditor }, { "diskLabelCommit", diskLabelCommit }, { "distReset", distReset }, { "distSetCustom", distSetCustom }, { "distUnsetCustom", distUnsetCustom }, { "distSetDeveloper", distSetDeveloper }, { "distSetXDeveloper", distSetXDeveloper }, { "distSetKernDeveloper", distSetKernDeveloper }, { "distSetUser", distSetUser }, { "distSetXUser", distSetXUser }, { "distSetMinimum", distSetMinimum }, { "distSetEverything", distSetEverything }, { "distSetSrc", distSetSrc }, { "distExtractAll", distExtractAll }, { "docBrowser", docBrowser }, { "docShowDocument", docShowDocument }, { "installCommit", installCommit }, { "installExpress", installExpress }, { "installStandard", installStandard }, { "installUpgrade", installUpgrade }, { "installFixupBase", installFixupBase }, { "installFixitHoloShell", installFixitHoloShell }, { "installFixitCDROM", installFixitCDROM }, { "installFixitFloppy", installFixitFloppy }, { "installFilesystems", installFilesystems }, { "installVarDefaults", installVarDefaults }, { "loadConfig", dispatch_load_file }, { "loadFloppyConfig", dispatch_load_floppy }, + { "mediaOpen", dispatch_mediaOpen }, { "mediaClose", dispatch_mediaClose }, { "mediaSetCDROM", mediaSetCDROM }, { "mediaSetFloppy", mediaSetFloppy }, { "mediaSetDOS", mediaSetDOS }, { "mediaSetTape", mediaSetTape }, { "mediaSetFTP", mediaSetFTP }, { "mediaSetFTPActive", mediaSetFTPActive }, { "mediaSetFTPPassive", mediaSetFTPPassive }, { "mediaSetHTTP", mediaSetHTTP }, { "mediaSetUFS", mediaSetUFS }, { "mediaSetNFS", mediaSetNFS }, { "mediaSetFTPUserPass", mediaSetFTPUserPass }, { "mediaSetCPIOVerbosity", mediaSetCPIOVerbosity }, { "mediaGetType", mediaGetType }, { "msgConfirm", dispatch_msgConfirm }, { "optionsEditor", optionsEditor }, { "packageAdd", packageAdd }, { "addGroup", userAddGroup }, { "addUser", userAddUser }, { "shutdown", dispatch_shutdown }, { "system", dispatch_systemExecute }, { "dumpVariables", dump_variables }, { "tcpMenuSelect", tcpMenuSelect }, { NULL, NULL }, }; /* * Helper routines for buffering data. * * We read an entire configuration into memory before executing it * so that we are truely standalone and can do things like nuke the * file or disk we're working on. */ typedef struct command_buffer_ { qelement queue; char * string; } command_buffer; static void dispatch_free_command(command_buffer *item) { REMQUE(item); free(item->string); free(item); } static void dispatch_free_all(qelement *head) { command_buffer *item; while (!EMPTYQUE(*head)) { item = (command_buffer *) head->q_forw; dispatch_free_command(item); } } static command_buffer * dispatch_add_command(qelement *head, char *string) { command_buffer *new; new = malloc(sizeof(command_buffer)); if (!new) return NULL; new->string = strdup(string); INSQUEUE(new, head->q_back); return new; } /* * Command processing */ /* Just convenience */ static int dispatch_shutdown(dialogMenuItem *unused) { systemShutdown(0); return DITEM_FAILURE; } static int dispatch_systemExecute(dialogMenuItem *unused) { char *cmd = variable_get(VAR_COMMAND); if (cmd) return systemExecute(cmd) ? DITEM_FAILURE : DITEM_SUCCESS; else msgDebug("_systemExecute: No command passed in `command' variable.\n"); return DITEM_FAILURE; } static int dispatch_msgConfirm(dialogMenuItem *unused) { char *msg = variable_get(VAR_COMMAND); if (msg) { msgConfirm("%s", msg); return DITEM_SUCCESS; } msgDebug("_msgConfirm: No message passed in `command' variable.\n"); return DITEM_FAILURE; } +static int +dispatch_mediaOpen(dialogMenuItem *unused) +{ + return mediaOpen(); +} + static int dispatch_mediaClose(dialogMenuItem *unused) { mediaClose(); return DITEM_SUCCESS; } static int call_possible_resword(char *name, dialogMenuItem *value, int *status) { int i, rval; rval = 0; for (i = 0; resWords[i].name; i++) { if (!strcmp(name, resWords[i].name)) { *status = resWords[i].handler(value); rval = 1; break; } } return rval; } /* For a given string, call it or spit out an undefined command diagnostic */ int dispatchCommand(char *str) { int i; char *cp; if (!str || !*str) { msgConfirm("Null or zero-length string passed to dispatchCommand"); return DITEM_FAILURE; } /* If it's got a newline, trim it */ if ((cp = index(str, '\n')) != NULL) *cp = '\0'; /* If it's got a `=' sign in there, assume it's a variable setting */ if (index(str, '=')) { if (isDebug()) msgDebug("dispatch: setting variable `%s'\n", str); variable_set(str, 0); i = DITEM_SUCCESS; } else { /* A command might be a pathname if it's encoded in argv[0], which we also support */ if ((cp = rindex(str, '/')) != NULL) str = cp + 1; if (isDebug()) msgDebug("dispatch: calling resword `%s'\n", str); if (!call_possible_resword(str, NULL, &i)) { msgNotify("Warning: No such command ``%s''", str); i = DITEM_FAILURE; } /* * Allow a user to prefix a command with "noError" to cause * us to ignore any errors for that one command. */ if (i != DITEM_SUCCESS && variable_get(VAR_NO_ERROR)) i = DITEM_SUCCESS; variable_unset(VAR_NO_ERROR); } return i; } /* * File processing */ static qelement * dispatch_load_fp(FILE *fp) { qelement *head; char buf[BUFSIZ], *cp; head = malloc(sizeof(qelement)); if (!head) return NULL; INITQUE(*head); while (fgets(buf, sizeof buf, fp)) { if ((cp = strchr(buf, '\n')) != NULL) *cp = '\0'; if (*buf == '\0' || *buf == '#') continue; if (!dispatch_add_command(head, buf)) return NULL; } return head; } static int dispatch_execute(qelement *head) { int result = DITEM_SUCCESS; command_buffer *item; char *old_interactive; if (!head) return result | DITEM_FAILURE; old_interactive = variable_get(VAR_NONINTERACTIVE); if (old_interactive) old_interactive = strdup(old_interactive); /* save copy */ /* Hint to others that we're running from a script, should they care */ variable_set2(VAR_NONINTERACTIVE, "yes", 0); while (!EMPTYQUE(*head)) { item = (command_buffer *) head->q_forw; if (DITEM_STATUS(dispatchCommand(item->string)) != DITEM_SUCCESS) { msgConfirm("Command `%s' failed - rest of script aborted.\n", item->string); result |= DITEM_FAILURE; break; } dispatch_free_command(item); } dispatch_free_all(head); if (!old_interactive) variable_unset(VAR_NONINTERACTIVE); else { variable_set2(VAR_NONINTERACTIVE, old_interactive, 0); free(old_interactive); } return result; } int dispatch_load_file_int(int quiet) { FILE *fp; char *cp; int i; qelement *list; static const char *names[] = { "install.cfg", "/stand/install.cfg", "/tmp/install.cfg", NULL }; fp = NULL; cp = variable_get(VAR_CONFIG_FILE); if (!cp) { for (i = 0; names[i]; i++) if ((fp = fopen(names[i], "r")) != NULL) break; } else fp = fopen(cp, "r"); if (!fp) { if (!quiet) msgConfirm("Unable to open %s: %s", cp, strerror(errno)); return DITEM_FAILURE; } list = dispatch_load_fp(fp); fclose(fp); return dispatch_execute(list); } int dispatch_load_file(dialogMenuItem *self) { return dispatch_load_file_int(FALSE); } int dispatch_load_floppy(dialogMenuItem *self) { int what = DITEM_SUCCESS; extern char *distWanted; char *cp; FILE *fp; qelement *list; mediaClose(); cp = variable_get_value(VAR_INSTALL_CFG, "Specify the name of a configuration file\n" "residing on a MSDOS or UFS floppy.", 0); if (!cp || !*cp) { variable_unset(VAR_INSTALL_CFG); what |= DITEM_FAILURE; return what; } distWanted = cp; /* Try to open the floppy drive */ if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE) { msgConfirm("Unable to set media device to floppy."); what |= DITEM_FAILURE; mediaClose(); return what; } if (!DEVICE_INIT(mediaDevice)) { msgConfirm("Unable to mount floppy filesystem."); what |= DITEM_FAILURE; mediaClose(); return what; } fp = DEVICE_GET(mediaDevice, cp, TRUE); if (fp) { list = dispatch_load_fp(fp); fclose(fp); mediaClose(); what |= dispatch_execute(list); } else { if (!variable_get(VAR_NO_ERROR)) msgConfirm("Configuration file '%s' not found.", cp); variable_unset(VAR_INSTALL_CFG); what |= DITEM_FAILURE; mediaClose(); } return what; } diff --git a/usr.sbin/sysinstall/media.c b/usr.sbin/sysinstall/media.c index cbdc01c04ed4..8e61c5a57088 100644 --- a/usr.sbin/sysinstall/media.c +++ b/usr.sbin/sysinstall/media.c @@ -1,882 +1,890 @@ /* * The new sysinstall program. * * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * * $FreeBSD$ * * 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. * * 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 #include #include #include #include #include #include #include #include #include #include #include #include #include static Boolean got_intr = FALSE; static Boolean ftp_skip_resolve = FALSE; /* timeout handler */ static void handle_intr(int sig) { msgDebug("User generated interrupt.\n"); got_intr = TRUE; } static int check_for_interrupt(void) { if (got_intr) { got_intr = FALSE; return TRUE; } return FALSE; } static int genericHook(dialogMenuItem *self, DeviceType type) { Device **devs; devs = deviceFind(self->prompt, type); if (devs) mediaDevice = devs[0]; return (devs ? DITEM_LEAVE_MENU : DITEM_FAILURE); } static int cdromHook(dialogMenuItem *self) { return genericHook(self, DEVICE_TYPE_CDROM); } static void kickstart_dns(void) { static Boolean initted = FALSE; int time; char *cp; cp = variable_get(VAR_MEDIA_TIMEOUT); if (!cp) time = MEDIA_TIMEOUT; else time = atoi(cp); if (!time) time = 100; if (!initted) { res_init(); _res.retry = 2; /* 2 times seems a reasonable number to me */ _res.retrans = time / 2; /* so spend half our alloted time on each try */ initted = TRUE; } } char * cpioVerbosity() { char *cp = variable_get(VAR_CPIO_VERBOSITY); if (cp && !strcmp(cp, "high")) return "-v"; else if (cp && !strcmp(cp, "medium")) return "-V"; return ""; } +int +mediaOpen(void) +{ + if (!mediaDevice || !mediaVerify() || !DEVICE_INIT(mediaDevice)) + return DITEM_FAILURE; + return DITEM_SUCCESS; +} + void mediaClose(void) { if (mediaDevice) DEVICE_SHUTDOWN(mediaDevice); mediaDevice = NULL; } /* * Return 1 if we successfully found and set the installation type to * be a CD. */ int mediaSetCDROM(dialogMenuItem *self) { Device **devs; int cnt; mediaClose(); devs = deviceFind(NULL, DEVICE_TYPE_CDROM); cnt = deviceCount(devs); if (!cnt) { if (self) /* Interactive? */ msgConfirm("No CD/DVD devices found! Please check that your system's\n" "configuration is correct and that the CD/DVD drive is of a supported\n" "type. For more information, consult the hardware guide\n" "in the Doc menu."); return DITEM_FAILURE | DITEM_CONTINUE; } else if (cnt > 1) { DMenu *menu; int status; menu = deviceCreateMenu(&MenuMediaCDROM, DEVICE_TYPE_CDROM, cdromHook, NULL); if (!menu) msgFatal("Unable to create CDROM menu! Something is seriously wrong."); status = dmenuOpenSimple(menu, FALSE); free(menu); if (!status) return DITEM_FAILURE; } else mediaDevice = devs[0]; return (mediaDevice ? DITEM_SUCCESS | DITEM_LEAVE_MENU : DITEM_FAILURE); } static int floppyHook(dialogMenuItem *self) { return genericHook(self, DEVICE_TYPE_FLOPPY); } /* * Return 1 if we successfully found and set the installation type to * be a floppy */ int mediaSetFloppy(dialogMenuItem *self) { Device **devs; int cnt; mediaClose(); devs = deviceFind(NULL, DEVICE_TYPE_FLOPPY); cnt = deviceCount(devs); if (!cnt) { msgConfirm("No floppy devices found! Please check that your system's configuration\n" "is correct. For more information, consult the hardware guide in the Doc\n" "menu."); return DITEM_FAILURE | DITEM_CONTINUE; } else if (cnt > 1) { DMenu *menu; int status; menu = deviceCreateMenu(&MenuMediaFloppy, DEVICE_TYPE_FLOPPY, floppyHook, NULL); if (!menu) msgFatal("Unable to create Floppy menu! Something is seriously wrong."); status = dmenuOpenSimple(menu, FALSE); free(menu); if (!status) return DITEM_FAILURE; } else mediaDevice = devs[0]; if (mediaDevice) mediaDevice->private = NULL; return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE); } static int DOSHook(dialogMenuItem *self) { return genericHook(self, DEVICE_TYPE_DOS); } /* * Return 1 if we successfully found and set the installation type to * be a DOS partition. */ int mediaSetDOS(dialogMenuItem *self) { Device **devs; int cnt; mediaClose(); devs = deviceFind(NULL, DEVICE_TYPE_DOS); cnt = deviceCount(devs); if (!cnt) { msgConfirm("No DOS primary partitions found! This installation method is unavailable"); return DITEM_FAILURE | DITEM_CONTINUE; } else if (cnt > 1) { DMenu *menu; int status; menu = deviceCreateMenu(&MenuMediaDOS, DEVICE_TYPE_DOS, DOSHook, NULL); if (!menu) msgFatal("Unable to create DOS menu! Something is seriously wrong."); status = dmenuOpenSimple(menu, FALSE); free(menu); if (!status) return DITEM_FAILURE; } else mediaDevice = devs[0]; return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE); } static int tapeHook(dialogMenuItem *self) { return genericHook(self, DEVICE_TYPE_TAPE); } /* * Return 1 if we successfully found and set the installation type to * be a tape drive. */ int mediaSetTape(dialogMenuItem *self) { Device **devs; int cnt; mediaClose(); devs = deviceFind(NULL, DEVICE_TYPE_TAPE); cnt = deviceCount(devs); if (!cnt) { msgConfirm("No tape drive devices found! Please check that your system's configuration\n" "is correct. For more information, consult the hardware guide in the Doc\n" "menu."); return DITEM_FAILURE | DITEM_CONTINUE; } else if (cnt > 1) { DMenu *menu; int status; menu = deviceCreateMenu(&MenuMediaTape, DEVICE_TYPE_TAPE, tapeHook, NULL); if (!menu) msgFatal("Unable to create tape drive menu! Something is seriously wrong."); status = dmenuOpenSimple(menu, FALSE); free(menu); if (!status) return DITEM_FAILURE; } else mediaDevice = devs[0]; if (mediaDevice) { char *val; val = msgGetInput("/var/tmp", "Please enter the name of a temporary directory containing\n" "sufficient space for holding the contents of this tape (or\n" "tapes). The contents of this directory will be removed\n" "after installation, so be sure to specify a directory that\n" "can be erased afterwards!\n"); if (!val) mediaDevice = NULL; else mediaDevice->private = strdup(val); } return (mediaDevice ? DITEM_LEAVE_MENU : DITEM_FAILURE); } /* * Return 0 if we successfully found and set the installation type to * be an ftp server */ int mediaSetFTP(dialogMenuItem *self) { static Device ftpDevice; char *cp, hbuf[MAXHOSTNAMELEN], *hostname, *dir; struct addrinfo hints, *res; int af, urllen; extern int FtpPort; static Device *networkDev = NULL; mediaClose(); cp = variable_get(VAR_FTP_PATH); /* If we've been through here before ... */ if (networkDev && cp && msgYesNo("Re-use old FTP site selection values?")) cp = NULL; if (!cp) { if (!dmenuOpenSimple(&MenuMediaFTP, FALSE)) return DITEM_FAILURE; else cp = variable_get(VAR_FTP_PATH); } if (!cp) return DITEM_FAILURE; else if (!strcmp(cp, "other")) { variable_set2(VAR_FTP_PATH, "ftp://", 0); cp = variable_get_value(VAR_FTP_PATH, "Please specify the URL of a FreeBSD distribution on a\n" "remote ftp site. This site must accept either anonymous\n" "ftp or you should have set an ftp username and password\n" "in the Options screen.\n\n" "A URL looks like this: ftp:///\n" "Where is relative to the anonymous ftp directory or the\n" "home directory of the user being logged in as.", 0); if (!cp || !*cp || !strcmp(cp, "ftp://")) { variable_unset(VAR_FTP_PATH); return DITEM_FAILURE; } urllen = strlen(cp); if (urllen >= sizeof(ftpDevice.name)) { msgConfirm("Length of specified URL is %d characters. Allowable maximum is %d.", urllen,sizeof(ftpDevice.name)-1); variable_unset(VAR_FTP_PATH); return DITEM_FAILURE; } } if (strncmp("ftp://", cp, 6)) { msgConfirm("Sorry, %s is an invalid URL!", cp); variable_unset(VAR_FTP_PATH); return DITEM_FAILURE; } SAFE_STRCPY(ftpDevice.name, cp); SAFE_STRCPY(hbuf, cp + 6); hostname = hbuf; if (!networkDev || msgYesNo("You've already done the network configuration once,\n" "would you like to skip over it now?") != 0) { if (networkDev) DEVICE_SHUTDOWN(networkDev); if (!(networkDev = tcpDeviceSelect())) { variable_unset(VAR_FTP_PATH); return DITEM_FAILURE; } } if (!DEVICE_INIT(networkDev)) { if (isDebug()) msgDebug("mediaSetFTP: Net device init failed.\n"); variable_unset(VAR_FTP_PATH); return DITEM_FAILURE; } if (*hostname == '[' && (cp = index(hostname + 1, ']')) != NULL && (*++cp == '\0' || *cp == '/' || *cp == ':')) { ++hostname; *(cp - 1) = '\0'; } else cp = index(hostname, ':'); if (cp != NULL && *cp == ':') { *(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); } if (!ftp_skip_resolve && variable_get(VAR_NAMESERVER)) { msgNotify("Looking up host %s.", hostname); if (isDebug()) msgDebug("Starting DNS.\n"); kickstart_dns(); if (isDebug()) msgDebug("Looking up hostname, %s, using getaddrinfo(AI_NUMERICHOST).\n", hostname); af = variable_cmp(VAR_IPV6_ENABLE, "YES") ? AF_INET : AF_UNSPEC; memset(&hints, 0, sizeof(hints)); hints.ai_family = af; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; if (getaddrinfo(hostname, NULL, &hints, &res) != 0) { if (isDebug()) msgDebug("Looking up hostname, %s, using getaddrinfo().\n", hostname); hints.ai_flags = AI_PASSIVE; if (getaddrinfo(hostname, NULL, &hints, &res) != 0) { msgConfirm("Cannot resolve hostname `%s'! Are you sure that" " your\nname server, gateway and network interface are" " correctly configured?", hostname); if (networkDev) DEVICE_SHUTDOWN(networkDev); networkDev = NULL; variable_unset(VAR_FTP_PATH); return DITEM_FAILURE; } } freeaddrinfo(res); if (isDebug()) msgDebug("Found DNS entry for %s successfully..\n", hostname); } variable_set2(VAR_FTP_HOST, hostname, 0); variable_set2(VAR_FTP_DIR, dir ? dir : "/", 0); variable_set2(VAR_FTP_PORT, itoa(FtpPort), 0); ftpDevice.type = DEVICE_TYPE_FTP; ftpDevice.init = mediaInitFTP; ftpDevice.get = mediaGetFTP; ftpDevice.shutdown = mediaShutdownFTP; ftpDevice.private = networkDev; mediaDevice = &ftpDevice; return DITEM_SUCCESS | DITEM_LEAVE_MENU | DITEM_RESTORE; } int mediaSetFTPActive(dialogMenuItem *self) { variable_set2(VAR_FTP_STATE, "active", 0); return mediaSetFTP(self); } int mediaSetFTPPassive(dialogMenuItem *self) { variable_set2(VAR_FTP_STATE, "passive", 0); return mediaSetFTP(self); } int mediaSetHTTP(dialogMenuItem *self) { Boolean tmp; int result; char *cp, *idx, hbuf[MAXHOSTNAMELEN], *hostname; int HttpPort; int what = DITEM_RESTORE; tmp = ftp_skip_resolve; ftp_skip_resolve = TRUE; result = mediaSetFTP(self); ftp_skip_resolve = tmp; if (DITEM_STATUS(result) != DITEM_SUCCESS) return result; cp = variable_get_value(VAR_HTTP_PROXY, "Please enter the address of the HTTP proxy in this format:\n" " hostname:port (the ':port' is optional, default is 3128)",0); if (!cp) return DITEM_FAILURE; SAFE_STRCPY(hbuf, cp); hostname = hbuf; if (*hostname == '[' && (idx = index(hostname + 1, ']')) != NULL && (*++idx == '\0' || *idx == ':')) { ++hostname; *(idx - 1) = '\0'; } else idx = index(hostname, ':'); if (idx == NULL || *idx != ':') HttpPort = 3128; /* try this as default */ else { *(idx++) = '\0'; HttpPort = strtol(idx, 0, 0); } variable_set2(VAR_HTTP_HOST, hostname, 0); variable_set2(VAR_HTTP_PORT, itoa(HttpPort), 0); if (isDebug()) { msgDebug("VAR_FTP_PATH : %s\n",variable_get(VAR_FTP_PATH)); msgDebug("VAR_HTTP_HOST, _PORT: %s:%s\n",variable_get(VAR_HTTP_HOST), variable_get(VAR_HTTP_PORT)); } /* mediaDevice has been set by mediaSetFTP(), overwrite partly: */ mediaDevice->type = DEVICE_TYPE_HTTP; mediaDevice->init = mediaInitHTTP; mediaDevice->get = mediaGetHTTP; mediaDevice->shutdown = dummyShutdown; return DITEM_SUCCESS | DITEM_LEAVE_MENU | what; } int mediaSetUFS(dialogMenuItem *self) { static Device ufsDevice; struct statfs st; char *cp; mediaClose(); cp = variable_get_value(VAR_UFS_PATH, "Enter a fully qualified pathname for the directory\n" "containing the FreeBSD distribution files:", 0); if (!cp) return DITEM_FAILURE; /* If they gave us a CDROM or something, try and pick a better name */ if (statfs(cp, &st)) strcpy(ufsDevice.name, "ufs"); else strcpy(ufsDevice.name, st.f_fstypename); ufsDevice.type = DEVICE_TYPE_UFS; ufsDevice.init = dummyInit; ufsDevice.get = mediaGetUFS; ufsDevice.shutdown = dummyShutdown; ufsDevice.private = strdup(cp); mediaDevice = &ufsDevice; return DITEM_LEAVE_MENU; } int mediaSetNFS(dialogMenuItem *self) { static Device nfsDevice; static Device *networkDev = NULL; char *cp, *idx; char hostname[MAXPATHLEN]; int pathlen; mediaClose(); 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", 0); if (!cp) return DITEM_FAILURE; SAFE_STRCPY(hostname, cp); if (!(idx = index(hostname, ':'))) { msgConfirm("Invalid NFS path specification. Must be of the form:\n" "host:/full/pathname/to/FreeBSD/distdir"); return DITEM_FAILURE; } pathlen = strlen(hostname); if (pathlen >= sizeof(nfsDevice.name)) { msgConfirm("Length of specified NFS path is %d characters. Allowable maximum is %d.", pathlen,sizeof(nfsDevice.name)-1); variable_unset(VAR_NFS_PATH); return DITEM_FAILURE; } SAFE_STRCPY(nfsDevice.name, hostname); *idx = '\0'; if (!networkDev || msgYesNo("You've already done the network configuration once,\n" "would you like to skip over it now?") != 0) { if (networkDev) DEVICE_SHUTDOWN(networkDev); if (!(networkDev = tcpDeviceSelect())) return DITEM_FAILURE; } if (!DEVICE_INIT(networkDev)) { if (isDebug()) msgDebug("mediaSetNFS: Net device init failed\n"); } if (variable_get(VAR_NAMESERVER)) { kickstart_dns(); if ((inet_addr(hostname) == INADDR_NONE) && (gethostbyname(hostname) == NULL)) { msgConfirm("Cannot resolve hostname `%s'! Are you sure that your\n" "name server, gateway and network interface are correctly configured?", hostname); if (networkDev) DEVICE_SHUTDOWN(networkDev); networkDev = NULL; variable_unset(VAR_NFS_PATH); return DITEM_FAILURE; } else { if (isDebug()) msgDebug("Found DNS entry for %s successfully..\n", hostname); } } variable_set2(VAR_NFS_HOST, hostname, 0); nfsDevice.type = DEVICE_TYPE_NFS; nfsDevice.init = mediaInitNFS; nfsDevice.get = mediaGetNFS; nfsDevice.shutdown = mediaShutdownNFS; nfsDevice.private = networkDev; mediaDevice = &nfsDevice; return DITEM_LEAVE_MENU; } Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpid) { int i, pfd[2],qfd[2]; if (!dir) dir = "/"; Mkdir(dir); chdir(dir); pipe(pfd); pipe(qfd); *zpid = fork(); if (!*zpid) { char *unzipper = RunningAsInit ? "/stand/" UNZIPPER : "/usr/bin/" UNZIPPER; dup2(qfd[0], 0); close(qfd[0]); dup2(pfd[1], 1); close(pfd[1]); if (DebugFD != -1) dup2(DebugFD, 2); else { close(2); open("/dev/null", O_WRONLY); } close(qfd[1]); close(pfd[0]); i = execl(unzipper, unzipper, (char *)0); if (isDebug()) msgDebug("%s command returns %d status\n", unzipper, i); exit(i); } *fd = qfd[1]; close(qfd[0]); *cpid = fork(); if (!*cpid) { char *cpio = RunningAsInit ? "/stand/cpio" : "/usr/bin/cpio"; dup2(pfd[0], 0); close(pfd[0]); close(pfd[1]); close(qfd[1]); if (DebugFD != -1) { dup2(DebugFD, 1); dup2(DebugFD, 2); } else { close(1); open("/dev/null", O_WRONLY); dup2(1, 2); } if (strlen(cpioVerbosity())) i = execl(cpio, cpio, "-idum", cpioVerbosity(), "--block-size", mediaTapeBlocksize(), (char *)0); else i = execl(cpio, cpio, "-idum", "--block-size", mediaTapeBlocksize(), (char *)0); if (isDebug()) msgDebug("%s command returns %d status\n", cpio, i); exit(i); } close(pfd[0]); close(pfd[1]); return TRUE; } Boolean mediaExtractDistEnd(int zpid, int cpid) { int i,j; i = waitpid(zpid, &j, 0); /* Don't check exit status - gunzip seems to return a bogus one! */ if (i < 0) { if (isDebug()) msgDebug("wait for %s returned status of %d!\n", USE_GZIP ? "gunzip" : "bunzip2", i); return FALSE; } i = waitpid(cpid, &j, 0); if (i < 0 || WEXITSTATUS(j)) { if (isDebug()) msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); return FALSE; } return TRUE; } Boolean mediaExtractDist(char *dir, char *dist, FILE *fp) { int i, j, total, seconds, zpid, cpid, pfd[2], qfd[2]; char buf[BUFSIZ]; struct timeval start, stop; struct sigaction new, old; if (!dir) dir = "/"; Mkdir(dir); chdir(dir); pipe(pfd); /* read end */ pipe(qfd); /* write end */ zpid = fork(); if (!zpid) { char *unzipper = RunningAsInit ? "/stand/" UNZIPPER : "/usr/bin/" UNZIPPER; fclose(fp); close(qfd[1]); dup2(qfd[0], 0); close(qfd[0]); close(pfd[0]); dup2(pfd[1], 1); close(pfd[1]); if (DebugFD != -1) dup2(DebugFD, 2); else { close(2); open("/dev/null", O_WRONLY); } i = execl(unzipper, unzipper, (char *)0); if (isDebug()) msgDebug("%s command returns %d status\n", unzipper, i); exit(i); } cpid = fork(); if (!cpid) { char *cpio = RunningAsInit ? "/stand/cpio" : "/usr/bin/cpio"; close(pfd[1]); dup2(pfd[0], 0); close(pfd[0]); close (qfd[0]); close(qfd[1]); fclose(fp); if (DebugFD != -1) { dup2(DebugFD, 1); dup2(DebugFD, 2); } else { dup2(open("/dev/null", O_WRONLY), 1); dup2(1, 2); } if (strlen(cpioVerbosity())) i = execl(cpio, cpio, "-idum", cpioVerbosity(), "--block-size", mediaTapeBlocksize(), (char *)0); else i = execl(cpio, cpio, "-idum", "--block-size", mediaTapeBlocksize(), (char *)0); if (isDebug()) msgDebug("%s command returns %d status\n", cpio, i); exit(i); } close(pfd[0]); close(pfd[1]); close(qfd[0]); total = 0; (void)gettimeofday(&start, (struct timezone *)0); /* Make ^C abort the current transfer rather than the whole show */ new.sa_handler = handle_intr; new.sa_flags = 0; (void)sigemptyset(&new.sa_mask); sigaction(SIGINT, &new, &old); while ((i = fread(buf, 1, BUFSIZ, fp)) > 0) { if (check_for_interrupt()) { msgConfirm("Failure to read from media: User interrupt."); break; } if (write(qfd[1], buf, i) != i) { msgConfirm("Write error on transfer to cpio process, try of %d bytes.", i); break; } else { (void)gettimeofday(&stop, (struct timezone *)0); stop.tv_sec = stop.tv_sec - start.tv_sec; stop.tv_usec = stop.tv_usec - start.tv_usec; if (stop.tv_usec < 0) stop.tv_sec--, stop.tv_usec += 1000000; seconds = stop.tv_sec + (stop.tv_usec / 1000000.0); if (!seconds) seconds = 1; total += i; msgInfo("%10d bytes read from %s dist @ %.1f KB/sec.", total, dist, (total / seconds) / 1024.0); } } sigaction(SIGINT, &old, NULL); /* restore sigint */ close(qfd[1]); i = waitpid(zpid, &j, 0); /* Don't check exit status - gunzip seems to return a bogus one! */ if (i < 0) { if (isDebug()) msgDebug("wait for %s returned status of %d!\n", USE_GZIP ? "gunzip" : "bunzip2", i); return FALSE; } i = waitpid(cpid, &j, 0); if (i < 0 || WEXITSTATUS(j)) { if (isDebug()) msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j)); return FALSE; } return TRUE; } int mediaGetType(dialogMenuItem *self) { return ((dmenuOpenSimple(&MenuMedia, FALSE) && mediaDevice) ? DITEM_SUCCESS : DITEM_FAILURE); } /* Return TRUE if all the media variables are set up correctly */ Boolean mediaVerify(void) { if (!mediaDevice) return (DITEM_STATUS(mediaGetType(NULL)) == DITEM_SUCCESS); return TRUE; } /* Set the FTP username and password fields */ int mediaSetFTPUserPass(dialogMenuItem *self) { char *pass; if (variable_get_value(VAR_FTP_USER, "Please enter the username you wish to login as:", 0)) { DialogInputAttrs |= DITEM_NO_ECHO; pass = variable_get_value(VAR_FTP_PASS, "Please enter the password for this user:", 0); DialogInputAttrs &= ~DITEM_NO_ECHO; } else pass = NULL; return (pass ? DITEM_SUCCESS : DITEM_FAILURE); } /* Set CPIO verbosity level */ int mediaSetCPIOVerbosity(dialogMenuItem *self) { char *cp = variable_get(VAR_CPIO_VERBOSITY); if (!cp) { msgConfirm("CPIO Verbosity is not set to anything!"); return DITEM_FAILURE; } else { if (!strcmp(cp, "low")) variable_set2(VAR_CPIO_VERBOSITY, "medium", 0); else if (!strcmp(cp, "medium")) variable_set2(VAR_CPIO_VERBOSITY, "high", 0); else /* must be "high" - wrap around */ variable_set2(VAR_CPIO_VERBOSITY, "low", 0); } return DITEM_SUCCESS; } /* A generic open which follows a well-known "path" of places to look */ FILE * mediaGenericGet(char *base, const char *file) { char buf[PATH_MAX]; snprintf(buf, PATH_MAX, "%s/%s", base, file); if (file_readable(buf)) return fopen(buf, "r"); snprintf(buf, PATH_MAX, "%s/FreeBSD/%s", base, file); if (file_readable(buf)) return fopen(buf, "r"); snprintf(buf, PATH_MAX, "%s/releases/%s", base, file); if (file_readable(buf)) return fopen(buf, "r"); snprintf(buf, PATH_MAX, "%s/%s/%s", base, variable_get(VAR_RELNAME), file); if (file_readable(buf)) return fopen(buf, "r"); snprintf(buf, PATH_MAX, "%s/releases/%s/%s", base, variable_get(VAR_RELNAME), file); return fopen(buf, "r"); } diff --git a/usr.sbin/sysinstall/sysinstall.8 b/usr.sbin/sysinstall/sysinstall.8 index aeb268e8e623..378359df56f7 100644 --- a/usr.sbin/sysinstall/sysinstall.8 +++ b/usr.sbin/sysinstall/sysinstall.8 @@ -1,920 +1,925 @@ .\" Copyright (c) 1997 .\" 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. .\" 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. .\" .\" THIS SOFTWARE IS PROVIDED BY Jordan Hubbard AND CONTRIBUTORS ``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 CONTRIBUTORS 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, 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. .\" .\" $FreeBSD$ .\" .Dd July 17, 2005 .Dt SYSINSTALL 8 .Os .Sh NAME .Nm sysinstall .Nd system installation and configuration tool .Sh SYNOPSIS .Nm .Op Ar var=value .Op Ar function .Op Ar ... .Sh DESCRIPTION The .Nm utility is used for installing and configuring .Fx systems. It is the first utility invoked by the .Fx installation boot floppy and is also available as .Pa /usr/sbin/sysinstall on newly installed .Fx systems for use in later configuring the system. .Pp The .Nm utility is generally invoked without arguments for the default behavior, where the main installation/configuration menu is presented. .Pp On those occasions where it is deemed necessary to invoke a subsystem of sysinstall directly, however, it is also possible to do so by naming the appropriate function entry points on the command line. Since this action is essentially identical to running an installation script, each command-line argument corresponding to a line of script, the reader is encouraged to read the section on scripting for more information on this feature. .Sh NOTES The .Nm utility is essentially nothing more than a monolithic C program with the ability to write MBRs and disk labels (through the services of the .Xr libdisk 3 library) and install distributions or packages onto new and existing .Fx systems. It also contains some extra intelligence for running as a replacement for .Xr init 8 when it is invoked by the .Fx installation boot procedure. It assumes very little in the way of additional utility support and performs most file system operations by calling the relevant syscalls (such as .Xr mount 2 ) directly. .Pp The .Nm utility currently uses the .Xr dialog 3 library to do user interaction with simple ANSI line graphics, color support for which is enabled by either running on a syscons VTY or some other color-capable terminal emulator (newer versions of xterm will support color when using the .Dq xterm-color termcap entry). .Pp This product is currently at the end of its life cycle and will eventually be replaced. .Sh RUNNING SCRIPTS The .Nm utility may be either driven interactively through its various internal menus or run in batch mode, driven by an external script. Such a script may be loaded and executed in one of 3 ways: .Bl -tag -width Ds .It Sy "LOAD_CONFIG_FILE" If .Nm is compiled with LOAD_CONFIG_FILE set in the environment (or in the Makefile) to some value, then that value will be used as the filename to automatically look for and load when .Nm starts up and with no user interaction required. This option is aimed primarily at large sites who wish to create a single prototype install for multiple machines with largely identical configurations and/or installation options. .It Sy "MAIN MENU" If .Nm is run interactively, that is to say in the default manner, it will bring up a main menu which contains a "load config file" option. Selecting this option will prompt for the name of a script file which it then will attempt to load from a DOS or UFS formatted floppy. .It Sy "COMMAND LINE" Each command line argument is treated as a script directive when .Nm is run in multi-user mode. Execution ends either by explicit request (e.g.\& calling the .Ar shutdown directive), upon reaching the end of the argument list or on error. .Pp For example: .Bd -literal /usr/sbin/sysinstall _ftpPath=ftp://ziggy/pub/ mediaSetFTP configPackages .Ed .Pp Would initialize .Nm for FTP installation media (using the server `ziggy') and then bring up the package installation editor, exiting when finished. .El .Sh SCRIPT SYNTAX A script is a list of one or more directives, each directive taking the form of: .Pp .Ar var=value .Pp .Ar function .Pp or .Ar #somecomment .Pp Where .Ar var=value is the assignment of some internal .Nm variable, e.g.\& "ftpPass=FuNkYChiKn", and .Ar function is the name of an internal .Nm function, e.g.\& "mediaSetFTP", and .Ar #comment is a single-line comment for documentation purposes (ignored by sysinstall). Each directive must be by itself on a single line, functions taking their arguments by examining known variable names. This requires that you be sure to assign the relevant variables before calling a function which requires them. .Pp The .Ar noError variable can be assigned before each directive: this will cause any error detected while processing the directive itself to be ignored. The value of .Ar noError will automatically reset to the default "unassigned" every time a directive is processed. .Pp When and where a function depends on the settings of one or more variables will be noted in the following table: .Pp .Sy "Function Glossary" : .Pp .Bl -tag -width indent .It configAnonFTP Invoke the Anonymous FTP configuration menu. .Pp .Sy Variables : None .It configRouter Select which routing daemon you wish to use, potentially loading any required 3rd-party routing daemons as necessary. .Pp .Sy Variables : .Bl -tag -width indent .It router can be set to the name of the desired routing daemon, e.g.\& .Dq routed or .Dq gated , otherwise it is prompted for. .El .It configNFSServer Configure host as an NFS server. .Pp .Sy Variables : None .It configNTP Configure host as a user of the Network Time Protocol. .Pp .Sy Variables : .Bl -tag -width indent .It ntpdate_flags The flags to .Xr ntpdate 8 , that is to say the name of the server to sync from. .El .It configPCNFSD Configure host to support PC NFS. .Pp .Sy Variables : .Bl -tag -width indent .It pcnfsd_pkg The name of the PCNFSD package to load if necessary (defaults to hard coded version). .El .It configPackages Bring up the interactive package management menu. .Pp .Sy Variables : None .It configUsers Add users and/or groups to the system. .Pp .Sy Variables : None .It diskPartitionEditor Invokes the disk partition (MBR) editor. .Pp .Sy Variables : .Bl -tag -width findx .It geometry The disk geometry, as a cyls/heads/sectors formatted string. Default: no change to geometry. .It partition Set to disk partitioning type or size, its value being .Ar free in order to use only remaining free space for .Fx , .Ar all to use the entire disk for .Fx but maintain a proper partition table, .Ar existing to use an existing .Fx partition (first found), .Ar exclusive to use the disk in .Dq dangerously dedicated mode or, finally, .Ar somenumber to allocate .Ar somenumber blocks of available free space to a new .Fx partition. Default: Interactive mode. .It bootManager is set to one of .Ar boot to signify the installation of a boot manager, .Ar standard to signify installation of a "standard" non-boot MGR DOS MBR or .Ar none to indicate that no change to the boot manager is desired. Default: none. .It diskInteractive If set, bring up the interactive disk partition editor. .El .Pp Note: Nothing is actually written to disk by this function, an explicit call to .Ar diskPartitionWrite being required for that to happen. .It diskPartitionWrite Causes any pending MBR changes (typically from the .Ar diskPartitionEditor function) to be written out. .Pp .Sy Variables : None .It diskLabelEditor Invokes the disk label editor. This is a bit trickier from a script since you need to essentially label everything inside each .Fx (type 0xA5) partition created by the .Ar diskPartitionEditor function, and that requires knowing a few rules about how things are laid out. When creating a script to automatically allocate disk space and partition it up, it is suggested that you first perform the installation interactively at least once and take careful notes as to what the slice names will be, then and only then hardwiring them into the script. .Pp For example, let's say you have a SCSI disk on which you have created a new .Fx partition in slice 2 (your DOS partition residing in slice 1). The slice name would be .Ar da0s2 for the whole .Fx partition .Ar ( da0s1 being your DOS primary partition). Now let's further assume that you have 500MB in this partition and you want to sub-partition that space into root, swap, var and usr file systems for .Fx . Your invocation of the .Ar diskLabelEditor function might involve setting the following variables: .Bl -tag -width findx .It Li "da0s2-1=ufs 40960 /" A 20MB root file system (all sizes are in 512 byte blocks). .It Li "da0s2-2=swap 131072 /" A 64MB swap partition. .It Li "da0s2-3=ufs 204800 /var" A 100MB /var file system. .It Li "da0s2-4=ufs 0 /usr 1" With the balance of free space (around 316MB) going to the /usr file system and with soft-updates enabled (the argument following the mount point, if non-zero, means to set the soft updates flag). .El .Pp One can also use the .Ar diskLabelEditor for mounting or erasing existing partitions as well as creating new ones. Using the previous example again, let's say that we also wanted to mount our DOS partition and make sure that an .Pa /etc/fstab entry is created for it in the new installation. Before calling the .Ar diskLabelEditor function, we simply add an additional line: .Pp .Dl "da0s1=/dos_c N" .Pp before the call. This tells the label editor that you want to mount the first slice on .Pa /dos_c and not to attempt to newfs it (not that .Nm would attempt this for a DOS partition in any case, but it could just as easily be an existing UFS partition being named here and the 2nd field is non-optional). .Pp You can also set the .Ar diskInteractive variable to request that the disk label editor use an interactive dialog to partition the disk instead of using variables to explicitly layout the disk as described above. .Pp Note: No file system data is actually written to disk until an explicit call to .Ar diskLabelCommit is made. .It diskLabelCommit Writes out all pending disklabel information and creates and/or mounts any file systems which have requests pending from the .Ar diskLabelEditor function. .Pp .Sy Variables : None .It distReset Resets all selected distributions to the empty set (no distributions selected). .Pp .Sy Variables : None .It distSetCustom Allows the selection of a custom distribution set (e.g.\& not just one of the existing "canned" sets) with no user interaction. .Pp .Sy Variables : .Bl -tag -width indent .It dists List of distributions to load. Possible distribution values are: .Bl -tag -width indentxx .It Li base The base binary distribution. .It Li doc Miscellaneous documentation .It Li games Games .It Li manpages Manual pages (unformatted) .It Li catpages Pre-formatted manual pages .It Li proflibs Profiled libraries for developers. .It Li dict Dictionary information (for tools like spell). .It Li info GNU info files and other extra docs. .It Li lib32 (amd64 only) 32-bit runtime compatibility libraries. .It Li ports The ports collection. .It Li ssecure /usr/src/secure .It Li sbase /usr/src/[top level files] .It Li scontrib /usr/src/contrib .It Li sgnu /usr/src/gnu .It Li setc /usr/src/etc .It Li sgames /usr/src/games .It Li sinclude /usr/src/include .It Li skrb5 /usr/src/kerberos5 .It Li slib /usr/src/lib .It Li slibexec /usr/src/libexec .It Li srelease /usr/src/release .It Li srescue /usr/src/rescue .It Li sbin /usr/src/bin .It Li ssbin /usr/src/sbin .It Li sshare /usr/src/share .It Li ssys /usr/src/sys .It Li subin /usr/src/usr.bin .It Li susbin /usr/src/usr.sbin .It Li ssmailcf /usr/src/usr.sbin/sendmail/cf .It Li Xbin X.Org client applications. .It Li Xlib X.Org libraries. .It Li Xman X.Org manual pages. .It Li Xdoc X.Org protocol and library documentation. .It Li Xprog X.Org imake distribution. .It Li Xsrv X.Org X server. .It Li Xnest X.Org nested X server. .It Li Xprt X.Org print server. .It Li Xvfb X.Org virtual frame-buffer X server. .It Li Xfmsc X.Org miscellaneous font set. .It Li Xf75 X.Org 75DPI font set. .It Li Xf100 X.Org 100DPI font set. .It Li Xfcyr X.Org Cyrillic font set. .It Li Xft1 X.Org Type 1 font set. .It Li Xftt X.Org TrueType font set. .It Li Xfs X.Org font server. .El .El .It distSetDeveloper Selects the standard Developer's distribution set. .Pp .Sy Variables : None .It distSetXDeveloper Selects the standard X Developer's distribution set. .Pp .Sy Variables : None .It distSetKernDeveloper Selects the standard kernel Developer's distribution set. .Pp .Sy Variables : None .It distSetUser Selects the standard user distribution set. .Pp .Sy Variables : None .It distSetXUser Selects the standard X user's distribution set. .Pp .Sy Variables : None .It distSetMinimum Selects the very minimum distribution set. .Pp .Sy Variables : None .It distSetEverything Selects the full whack - all available distributions. .Pp .Sy Variables : None .It distSetSrc Interactively select source subcomponents. .Pp .Sy Variables : None .It distSetXOrg Interactively select X.Org subcomponents. .Pp .Sy Variables : None .It distExtractAll Install all currently selected distributions (requires that media device also be selected). .Pp .Sy Variables : None .It docBrowser Install (if necessary) an HTML documentation browser and go to the HTML documentation submenu. .Pp .Sy Variables : .Bl -tag -width indent .It browserPackage The name of the browser package to try and install as necessary. Defaults to latest links package. .It browserBinary The name of the browser binary itself (if overriding the .Ar browserPackage variable). Defaults to links. .El .It installCommit Commit any and all pending changes to disk. This function is essentially shorthand for a number of more granular "commit" functions. .Pp .Sy Variables : None .It installExpress Start an "express" installation, asking few questions of the user. .Pp .Sy Variables : None .It installStandard Start a "standard" installation, the most user-friendly installation type available. .Pp .Sy Variables : None .It installUpgrade Start an upgrade installation. .Pp .Sy Variables : None .It installFixitHoloShell Start up the "emergency holographic shell" over on VTY4 if running as init. This will also happen automatically as part of the installation process unless .Ar noHoloShell is set. .Pp .Sy Variables : None .It installFixitCDROM Go into "fixit" mode, assuming a live file system CDROM currently in the drive. .Pp .Sy Variables : None .It installFixitFloppy Go into "fixit" mode, assuming an available fixit floppy disk (user will be prompted for it). .Pp .Sy Variables : None .It installFilesystems Do just the file system initialization part of an install. .Pp .Sy Variables : None .It installVarDefaults Initialize all variables to their defaults, overriding any previous settings. .Pp .Sy Variables : None .It loadConfig Sort of like an #include statement, it allows you to load one configuration file from another. .Pp .Sy Variables : .Bl -tag -width indent .It configFile The fully qualified pathname of the file to load. .El +.It mediaOpen +If a media device is set, mount it. +.Pp +.Sy Variables : +None .It mediaClose If a media device is open, close it. .Pp .Sy Variables : None .It mediaSetCDROM Select a .Fx CDROM as the installation media. .Pp .Sy Variables : None .It mediaSetFloppy Select a pre-made floppy installation set as the installation media. .Pp .Sy Variables : None .It mediaSetDOS Select an existing DOS primary partition as the installation media. The first primary partition found is used (e.g.\& C:). .Pp .Sy Variables : None .It mediaSetTape Select a tape device as the installation media. .Pp .Sy Variables : None .It mediaSetFTP Select an FTP site as the installation media. .Pp .Sy Variables : .Bl -tag -width indent .It hostname The name of the host being installed (non-optional). .It domainname The domain name of the host being installed (optional). .It defaultrouter The default router for this host (non-optional). .It netDev Which host interface to use .Ar ( ed0 or .Ar ep0 , for example. Non-optional). .It netInteractive If set, bring up the interactive network setup form even if all relevant configuration variables are already set (optional). .It ipaddr The IP address for the selected host interface (non-optional). .It netmask The netmask for the selected host interface (non-optional). .It _ftpPath The fully qualified URL of the FTP site containing the .Fx distribution you are interested in, e.g.\& .Ar ftp://ftp.FreeBSD.org/pub/FreeBSD/ . .El .It mediaSetFTPActive Alias for .Ar mediaSetFTP using "active" FTP transfer mode. .Pp .Sy Variables : Same as for .Ar mediaSetFTP . .It mediaSetFTPPassive Alias for .Ar mediaSetFTP using "passive" FTP transfer mode. .Pp .Sy Variables : Same as for .Ar mediaSetFTP . .It mediaSetHTTP Alias for .Ar mediaSetFTP using an HTTP proxy. .Pp .Sy Variables : See .Ar mediaSetFTP , plus .Bl -tag -width indent .It _httpPath The proxy to use (host:port) (non-optional). .El .It mediaSetUFS Select an existing UFS partition (mounted with the label editor) as the installation media. .Pp .Sy Variables : .Bl -tag -width indent .It ufs full /path to directory containing the .Fx distribution you are interested in. .El .It mediaSetNFS .Pp .Sy Variables : .Bl -tag -width indent .It hostname The name of the host being installed (non-optional). .It domainname The domain name of the host being installed (optional). .It defaultrouter The default router for this host (non-optional). .It netDev Which host interface to use .Ar ( ed0 or .Ar ep0 , for example. Non-optional). .It netInteractive If set, bring up the interactive network setup form even if all relevant configuration variables are already set (optional). .It ipaddr The IP address for the selected host interface (non-optional). .It netmask The netmask for the selected host interface (non-optional). .It nfs full hostname:/path specification for directory containing the .Fx distribution you are interested in. .El .It mediaSetFTPUserPass .Pp .Sy Variables : .Bl -tag -width indent .It ftpUser The username to log in as on the ftp server site. Default: ftp .It ftpPass The password to use for this username on the ftp server site. Default: user@host .El .It mediaSetCPIOVerbosity .Pp .Sy Variables : .Bl -tag -width indent .It cpioVerbose Can be used to set the verbosity of cpio extractions to low, medium or high. .El .It mediaGetType Interactively get the user to specify some type of media. .Pp .Sy Variables : None .It optionsEditor Invoke the interactive options editor. .Pp .Sy Variables : None .It packageAdd Try to fetch and add a package to the system (requires that a media type be set), .Pp .Sy Variables : .Bl -tag -width indent .It package The name of the package to add, e.g.\& bash-1.14.7 or ncftp-2.4.2. .El .It addGroup Invoke the interactive group editor. .Pp .Sy Variables : None .It addUser Invoke the interactive user editor. .Pp .Sy Variables : None .It shutdown Stop the script and terminate sysinstall. .Pp .Sy Variables : None .It system Execute an arbitrary command with .Xr system 3 .Pp .Sy Variables : .Bl -tag -width indent .It command The name of the command to execute. When running from a boot floppy, very minimal expectations should be made as to what is available until/unless a relatively full system installation has just been done. .El .It tcpMenuSelect Configure a network device. .Pp .Sy Variables : Same as for .Ar mediaSetFTP except that .Ar _ftpPath is not used. .El .Sh DISTRIBUTION MEDIA The following files can be used to affect the operation of .Nm when used during initial system installation. .Bl -tag -width ".Pa packages/INDEX" .It Pa cdrom.inf A text file of properties, listed one per line, that describe the contents of the media in use. The syntax for each line is simply .Dq Ar property No = Ar value . Currently, only the following properties are recognized. .Bl -tag -width ".Va CD_MACHINE_ARCH" .It Va CD_VERSION This property should be set to the .Fx version on the current media volume. For example, .Dq Li "CD_VERSION = 5.3" . .It Va CD_MACHINE_ARCH This property should be set to the architecture of the contents on this volume. This property is normally only used with .Fx products that contain CDs for different architectures, to provide better error messages if users try to install Alpha packages on an i386 machine. For example, .Dq Li "CD_MACHINE_ARCH = alpha" . .It Va CD_VOLUME In a multi-volume collection (such as the .Fx 4-CD set), the .Pa ports/INDEX file on each disc should contain the full package index for the set. The last field of the .Pa INDEX file denotes which volume the package appears on, and the .Va CD_VOLUME property here defines the volume ID of the current disc. .El .It Pa packages/INDEX The package index file. Each package is listed on a separate line with additional meta-data such as the required dependencies. This index is generated by .Dq Li "make index" from the .Xr ports 7 collection. When multi-volume support is enabled, an additional field should be added to each line indicating which media volume contains the given package. .El .Pp For information about building a full release of .Fx , please see .Xr release 7 . .Sh FILES This utility may edit the contents of .Pa /etc/rc.conf , .Pa /etc/hosts , and .Pa /etc/resolv.conf as necessary to reflect changes in the network configuration. .Sh SEE ALSO If you have a reasonably complete source tree online, take a look at .Pa /usr/src/usr.sbin/sysinstall/install.cfg for a sample installation script. .Sh HISTORY This version of .Nm first appeared in .Fx 2.0 . .Sh AUTHORS .An Jordan K. Hubbard Aq jkh@FreeBSD.org .Sh BUGS This utility is a prototype which lasted several years past its expiration date and is greatly in need of death. diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h index d099cca5cffd..3dfc0483bf12 100644 --- a/usr.sbin/sysinstall/sysinstall.h +++ b/usr.sbin/sysinstall/sysinstall.h @@ -1,881 +1,882 @@ /* * The new sysinstall program. * * This is probably the last attempt in the `sysinstall' line, the next * generation being slated to essentially a complete rewrite. * * 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. * * 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. * * $FreeBSD$ */ #ifndef _SYSINSTALL_H_INCLUDE #define _SYSINSTALL_H_INCLUDE #include #include #include #include #include #include #include #include #include #include "ui_objects.h" #include "dir.h" #include "colors.h" #include "dist.h" /*** Defines ***/ #if defined(__i386__) || defined(__alpha__) || defined(__amd64__) #define WITH_SYSCONS #define WITH_MICE #endif #if defined(__i386__) || defined(__amd64__) #define WITH_SLICES #endif #if defined(__i386__) || defined(__alpha__) #define WITH_LINUX #endif /* device limits */ #define DEV_NAME_MAX 128 /* The maximum length of a device name */ #define DEV_MAX 100 /* The maximum number of devices we'll deal with */ #define INTERFACE_MAX 50 /* Maximum number of network interfaces we'll deal with */ #define IO_ERROR -2 /* Status code for I/O error rather than normal EOF */ /* Number of seconds to wait for data to come off even the slowest media */ #define MEDIA_TIMEOUT 300 /* * I make some pretty gross assumptions about having a max of 50 chunks * total - 8 slices and 42 partitions. I can't easily display many more * than that on the screen at once! * * For 2.1 I'll revisit this and try to make it more dynamic, but since * this will catch 99.99% of all possible cases, I'm not too worried. */ #define MAX_CHUNKS 40 /* Internal environment variable names */ #define DISK_PARTITIONED "_diskPartitioned" #define DISK_LABELLED "_diskLabelled" #define DISK_SELECTED "_diskSelected" #define SYSTEM_STATE "_systemState" #define RUNNING_ON_ROOT "_runningOnRoot" #define TCP_CONFIGURED "_tcpConfigured" /* Ones that can be tweaked from config files */ #define VAR_BLANKTIME "blanktime" #define VAR_BOOTMGR "bootManager" #define VAR_BROWSER_BINARY "browserBinary" #define VAR_BROWSER_PACKAGE "browserPackage" #define VAR_CPIO_VERBOSITY "cpioVerbose" #define VAR_DEBUG "debug" #define VAR_DESKSTYLE "_deskStyle" #define VAR_DISK "disk" #define VAR_DISKINTERACTIVE "diskInteractive" #define VAR_DISTS "dists" #define VAR_DIST_MAIN "distMain" #define VAR_DIST_SRC "distSRC" #define VAR_DIST_X11 "distX11" #define VAR_DEDICATE_DISK "dedicateDisk" #define VAR_DOMAINNAME "domainname" #define VAR_EDITOR "editor" #define VAR_EXTRAS "ifconfig_" #define VAR_COMMAND "command" #define VAR_CONFIG_FILE "configFile" #define VAR_FIXIT_TTY "fixitTty" #define VAR_FTP_DIR "ftpDirectory" #define VAR_FTP_PASS "ftpPass" #define VAR_FTP_PATH "_ftpPath" #define VAR_FTP_PORT "ftpPort" #define VAR_FTP_STATE "ftpState" #define VAR_FTP_USER "ftpUser" #define VAR_FTP_HOST "ftpHost" #define VAR_HTTP_PATH "_httpPath" #define VAR_HTTP_PROXY "httpProxy" #define VAR_HTTP_PORT "httpPort" #define VAR_HTTP_HOST "httpHost" #define VAR_HTTP_FTP_MODE "httpFtpMode" #define VAR_GATEWAY "defaultrouter" #define VAR_GEOMETRY "geometry" #define VAR_HOSTNAME "hostname" #define VAR_IFCONFIG "ifconfig_" #define VAR_INSTALL_CFG "installConfig" #define VAR_INSTALL_ROOT "installRoot" #define VAR_IPADDR "ipaddr" #define VAR_IPV6_ENABLE "ipv6_enable" #define VAR_IPV6ADDR "ipv6addr" #define VAR_KERN_SECURELEVEL "kern_securelevel" #define VAR_KEYMAP "keymap" #define VAR_LABEL "label" #define VAR_LABEL_COUNT "labelCount" #define VAR_LINUX_ENABLE "linux_enable" #define VAR_MEDIA_TYPE "mediaType" #define VAR_MEDIA_TIMEOUT "MEDIA_TIMEOUT" #define VAR_MOUSED "moused_enable" #define VAR_MOUSED_FLAGS "moused_flags" #define VAR_MOUSED_PORT "moused_port" #define VAR_MOUSED_TYPE "moused_type" #define VAR_NAMESERVER "nameserver" #define VAR_NETINTERACTIVE "netInteractive" #define VAR_NETMASK "netmask" #define VAR_NETWORK_DEVICE "netDev" #define VAR_NEWFS_ARGS "newfsArgs" #define VAR_NFS_PATH "nfs" #define VAR_NFS_HOST "nfsHost" #define VAR_NFS_V3 "nfs_use_v3" #define VAR_NFS_TCP "nfs_use_tcp" #define VAR_NFS_SECURE "nfs_reserved_port_only" #define VAR_NFS_SERVER "nfs_server_enable" #define VAR_NO_CONFIRM "noConfirm" #define VAR_NO_ERROR "noError" #define VAR_NO_HOLOSHELL "noHoloShell" #define VAR_NO_INET6 "noInet6" #define VAR_NO_WARN "noWarn" #define VAR_NO_USR "noUsr" #define VAR_NO_TMP "noTmp" #define VAR_NO_HOME "noHome" #define VAR_NONINTERACTIVE "nonInteractive" #define VAR_NOVELL "novell" #define VAR_OSF1_ENABLE "osf1_enable" #define VAR_RPCBIND_ENABLE "rpcbind_enable" #define VAR_NTPDATE_FLAGS "ntpdate_flags" #define VAR_PACKAGE "package" #define VAR_PARTITION "partition" #define VAR_PCNFSD "pcnfsd" #define VAR_PKG_TMPDIR "PKG_TMPDIR" #define VAR_PORTS_PATH "ports" #define VAR_PPP_ENABLE "ppp_enable" #define VAR_PPP_PROFILE "ppp_profile" #define VAR_RELNAME "releaseName" #define VAR_ROOT_SIZE "rootSize" #define VAR_ROUTER "router" #define VAR_ROUTER_ENABLE "router_enable" #define VAR_ROUTERFLAGS "router_flags" #define VAR_SENDMAIL_ENABLE "sendmail_enable" #define VAR_SERIAL_SPEED "serialSpeed" #define VAR_SLOW_ETHER "slowEthernetCard" #define VAR_SWAP_SIZE "swapSize" #define VAR_TAPE_BLOCKSIZE "tapeBlocksize" #define VAR_TRY_DHCP "tryDHCP" #define VAR_TRY_RTSOL "tryRTSOL" #define VAR_SKIP_PCCARD "skipPCCARD" #define VAR_UFS_PATH "ufs" #define VAR_USR_SIZE "usrSize" #define VAR_VAR_SIZE "varSize" #define VAR_TMP_SIZE "tmpSize" #define VAR_HOME_SIZE "homeSize" #define VAR_XORG_CONFIG "_xorgconfig" #define VAR_TERM "TERM" #define VAR_CONSTERM "_consterm" #define DEFAULT_TAPE_BLOCKSIZE "20" /* One MB worth of blocks */ #define ONE_MEG 2048 #define ONE_GIG (ONE_MEG * 1024) /* Which selection attributes to use */ #define ATTR_SELECTED (ColorDisplay ? item_selected_attr : item_attr) #define ATTR_TITLE button_active_attr /* Handy strncpy() macro */ #define SAFE_STRCPY(to, from) sstrncpy((to), (from), sizeof (to) - 1) /*** Types ***/ typedef int Boolean; typedef struct disk Disk; typedef struct chunk Chunk; /* Bitfields for menu options */ #define DMENU_NORMAL_TYPE 0x1 /* Normal dialog menu */ #define DMENU_RADIO_TYPE 0x2 /* Radio dialog menu */ #define DMENU_CHECKLIST_TYPE 0x4 /* Multiple choice menu */ #define DMENU_SELECTION_RETURNS 0x8 /* Immediate return on item selection */ typedef struct _dmenu { int type; /* What sort of menu we are */ char *title; /* Our title */ char *prompt; /* Our prompt */ char *helpline; /* Line of help at bottom */ char *helpfile; /* Help file for "F1" */ #if (__STDC_VERSION__ >= 199901L) || (__GNUC__ >= 3) dialogMenuItem items[]; /* Array of menu items */ #elif __GNUC__ dialogMenuItem items[0]; /* Array of menu items */ #else #error "Create hack for C89 and K&R compilers." #endif } DMenu; /* An rc.conf variable */ typedef struct _variable { struct _variable *next; char *name; char *value; int dirty; } Variable; #define NO_ECHO_OBJ(type) ((type) | (DITEM_NO_ECHO << 16)) #define TYPE_OF_OBJ(type) ((type) & 0xff) #define ATTR_OF_OBJ(type) ((type) >> 16) /* A screen layout structure */ typedef struct _layout { int y; /* x & Y co-ordinates */ int x; int len; /* The size of the dialog on the screen */ int maxlen; /* How much the user can type in ... */ char *prompt; /* The string for the prompt */ char *help; /* The display for the help line */ void *var; /* The var to set when this changes */ int type; /* The type of the dialog to create */ void *obj; /* The obj pointer returned by libdialog */ } Layout; typedef enum { DEVICE_TYPE_NONE, DEVICE_TYPE_DISK, DEVICE_TYPE_FLOPPY, DEVICE_TYPE_FTP, DEVICE_TYPE_NETWORK, DEVICE_TYPE_CDROM, DEVICE_TYPE_TAPE, DEVICE_TYPE_DOS, DEVICE_TYPE_UFS, DEVICE_TYPE_NFS, DEVICE_TYPE_ANY, DEVICE_TYPE_HTTP, } DeviceType; /* CDROM mount codes */ #define CD_UNMOUNTED 0 #define CD_ALREADY_MOUNTED 1 #define CD_WE_MOUNTED_IT 2 /* A "device" from sysinstall's point of view */ typedef struct _device { char name[DEV_NAME_MAX]; char *description; char *devname; DeviceType type; Boolean enabled; Boolean (*init)(struct _device *dev); FILE * (*get)(struct _device *dev, char *file, Boolean probe); void (*shutdown)(struct _device *dev); void *private; unsigned int flags; unsigned int volume; } Device; /* Some internal representations of partitions */ typedef enum { PART_NONE, PART_SLICE, PART_SWAP, PART_FILESYSTEM, PART_FAT, PART_EFI } PartType; #define NEWFS_UFS_CMD "newfs" #define NEWFS_MSDOS_CMD "newfs_msdos" enum newfs_type { NEWFS_UFS, NEWFS_MSDOS, NEWFS_CUSTOM }; #define NEWFS_UFS_STRING "UFS" #define NEWFS_MSDOS_STRING "FAT" #define NEWFS_CUSTOM_STRING "CST" /* The longest set of custom command line arguments we'll pass. */ #define NEWFS_CMD_ARGS_MAX 256 typedef struct _part_info { char mountpoint[FILENAME_MAX]; /* Is invocation of newfs desired? */ Boolean do_newfs; enum newfs_type newfs_type; union { struct { char user_options[NEWFS_CMD_ARGS_MAX]; Boolean acls; /* unused */ Boolean multilabel; /* unused */ Boolean softupdates; Boolean ufs1; } newfs_ufs; struct { /* unused */ } newfs_msdos; struct { char command[NEWFS_CMD_ARGS_MAX]; } newfs_custom; } newfs_data; } PartInfo; /* An option */ typedef struct _opt { char *name; char *desc; enum { OPT_IS_STRING, OPT_IS_INT, OPT_IS_FUNC, OPT_IS_VAR } type; void *data; void *aux; char *(*check)(); } Option; /* Weird index nodey things we use for keeping track of package information */ typedef enum { PACKAGE, PLACE } node_type; /* Types of nodes */ typedef struct _pkgnode { /* A node in the reconstructed hierarchy */ struct _pkgnode *next; /* My next sibling */ node_type type; /* What am I? */ char *name; /* My name */ char *desc; /* My description (Hook) */ struct _pkgnode *kids; /* My little children */ void *data; /* A place to hang my data */ } PkgNode; typedef PkgNode *PkgNodePtr; /* A single package */ typedef struct _indexEntry { /* A single entry in an INDEX file */ char *name; /* name */ char *path; /* full path to port */ char *prefix; /* port prefix */ char *comment; /* one line description */ char *descrfile; /* path to description file */ char *deps; /* packages this depends on */ int depc; /* how many depend on me */ int installed; /* indicates if it is installed */ char *maintainer; /* maintainer */ unsigned int volume; /* Volume of package */ } IndexEntry; typedef IndexEntry *IndexEntryPtr; typedef int (*commandFunc)(char *key, void *data); #define HOSTNAME_FIELD_LEN 128 #define IPADDR_FIELD_LEN 16 #define EXTRAS_FIELD_LEN 128 /* This is the structure that Network devices carry around in their private, erm, structures */ typedef struct _devPriv { int use_rtsol; int use_dhcp; char ipaddr[IPADDR_FIELD_LEN]; char netmask[IPADDR_FIELD_LEN]; char extras[EXTRAS_FIELD_LEN]; } DevInfo; /*** Externs ***/ extern jmp_buf BailOut; /* Used to get the heck out */ extern int CDROMInitQuiet; /* Don't whine if mount(2) fails */ extern int DebugFD; /* Where diagnostic output goes */ extern Boolean Fake; /* Don't actually modify anything - testing */ extern Boolean Restarting; /* Are we restarting sysinstall? */ extern Boolean SystemWasInstalled; /* Did we install it? */ extern Boolean RunningAsInit; /* Are we running stand-alone? */ extern Boolean DialogActive; /* Is the dialog() stuff up? */ extern Boolean ColorDisplay; /* Are we on a color display? */ extern Boolean OnVTY; /* On a syscons VTY? */ extern Variable *VarHead; /* The head of the variable chain */ extern Device *mediaDevice; /* Where we're getting our distribution from */ extern unsigned int Dists; /* Which distributions we want */ extern unsigned int SrcDists; /* Which src distributions we want */ extern unsigned int XOrgDists; /* Which X.Org dists we want */ extern int BootMgr; /* Which boot manager to use */ extern int StatusLine; /* Where to print our status messages */ extern DMenu MenuInitial; /* Initial installation menu */ extern DMenu MenuFixit; /* Fixit repair menu */ #if defined(__i386__) || defined(__amd64__) #ifdef PC98 extern DMenu MenuIPLType; /* Type of IPL to write on the disk */ #else extern DMenu MenuMBRType; /* Type of MBR to write on the disk */ #endif #endif extern DMenu MenuConfigure; /* Final configuration menu */ extern DMenu MenuDocumentation; /* Documentation menu */ extern DMenu MenuFTPOptions; /* FTP Installation options */ extern DMenu MenuIndex; /* Index menu */ extern DMenu MenuOptions; /* Installation options */ extern DMenu MenuOptionsLanguage; /* Language options menu */ extern DMenu MenuKLD; /* Prototype KLD menu */ extern DMenu MenuMedia; /* Media type menu */ #ifdef WITH_MICE extern DMenu MenuMouse; /* Mouse type menu */ #endif extern DMenu MenuMediaCDROM; /* CDROM media menu */ extern DMenu MenuMediaDOS; /* DOS media menu */ extern DMenu MenuMediaFloppy; /* Floppy media menu */ extern DMenu MenuMediaFTP; /* FTP media menu */ extern DMenu MenuMediaTape; /* Tape media menu */ extern DMenu MenuNetworkDevice; /* Network device menu */ extern DMenu MenuNTP; /* NTP time server menu */ extern DMenu MenuSecurity; /* System security options menu */ extern DMenu MenuSecurelevel; /* Securelevel menu */ extern DMenu MenuStartup; /* Startup services menu */ #ifdef WITH_SYSCONS extern DMenu MenuSyscons; /* System console configuration menu */ extern DMenu MenuSysconsFont; /* System console font configuration menu */ extern DMenu MenuSysconsKeymap; /* System console keymap configuration menu */ extern DMenu MenuSysconsKeyrate; /* System console keyrate configuration menu */ extern DMenu MenuSysconsSaver; /* System console saver configuration menu */ extern DMenu MenuSysconsScrnmap; /* System console screenmap configuration menu */ extern DMenu MenuSysconsTtys; /* System console terminal type menu */ #endif extern DMenu MenuNetworking; /* Network configuration menu */ extern DMenu MenuMTA; /* MTA selection menu */ extern DMenu MenuInstallCustom; /* Custom Installation menu */ extern DMenu MenuDistributions; /* Distribution menu */ extern DMenu MenuDiskDevices; /* Disk type devices */ extern DMenu MenuSubDistributions; /* Custom distribution menu */ extern DMenu MenuSrcDistributions; /* Source distribution menu */ extern DMenu MenuXOrg; /* X.Org main menu */ extern DMenu MenuXOrgSelect; /* X.Org distribution selection menu */ extern DMenu MenuXOrgSelectCore; /* X.Org core distribution menu */ extern DMenu MenuXOrgSelectServer; /* X.Org server distribution menu */ extern DMenu MenuXOrgSelectFonts; /* X.Org font selection menu */ extern DMenu MenuXDesktops; /* X Desktops menu */ extern DMenu MenuHTMLDoc; /* HTML Documentation menu */ extern DMenu MenuUsermgmt; /* User management menu */ extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */ extern DMenu MenuXOrgConfig; /* Select X.Org configuration tool */ extern int FixItMode; /* FixItMode starts shell onc urrent device (ie Serial port) */ extern const char * StartName; /* Which name we were started as */ /* Important chunks. */ extern Chunk *HomeChunk; extern Chunk *RootChunk; extern Chunk *SwapChunk; extern Chunk *TmpChunk; extern Chunk *UsrChunk; extern Chunk *VarChunk; #ifdef __ia64__ extern Chunk *EfiChunk; #endif /* Stuff from libdialog which isn't properly declared outside */ extern void display_helpfile(void); extern void display_helpline(WINDOW *w, int y, int width); /*** Prototypes ***/ /* anonFTP.c */ extern int configAnonFTP(dialogMenuItem *self); /* cdrom.c */ extern Boolean mediaInitCDROM(Device *dev); extern FILE *mediaGetCDROM(Device *dev, char *file, Boolean probe); extern void mediaShutdownCDROM(Device *dev); /* command.c */ extern void command_clear(void); extern void command_sort(void); extern void command_execute(void); extern void command_shell_add(char *key, char *fmt, ...) __printflike(2, 3); extern void command_func_add(char *key, commandFunc func, void *data); /* config.c */ extern void configEnvironmentRC_conf(void); extern void configEnvironmentResolv(char *config); extern void configRC_conf(void); extern int configFstab(dialogMenuItem *self); extern int configRC(dialogMenuItem *self); extern int configResolv(dialogMenuItem *self); extern int configPackages(dialogMenuItem *self); extern int configSaver(dialogMenuItem *self); extern int configSaverTimeout(dialogMenuItem *self); #ifdef WITH_LINUX extern int configLinux(dialogMenuItem *self); #endif extern int configNTP(dialogMenuItem *self); #ifdef __alpha__ extern int configOSF1(dialogMenuItem *self); #endif extern int configUsers(dialogMenuItem *self); extern int configRouter(dialogMenuItem *self); extern int configPCNFSD(dialogMenuItem *self); extern int configInetd(dialogMenuItem *self); extern int configNFSServer(dialogMenuItem *self); extern int configMTAPostfix(dialogMenuItem *self); extern int configMTAExim(dialogMenuItem *self); extern int configRpcBind(dialogMenuItem *self); extern int configWriteRC_conf(dialogMenuItem *self); extern int configSecurelevel(dialogMenuItem *self); extern int configSecurelevelDisabled(dialogMenuItem *self); extern int configSecurelevelSecure(dialogMenuItem *self); extern int configSecurelevelHighlySecure(dialogMenuItem *self); extern int configSecurelevelNetworkSecure(dialogMenuItem *self); extern int configEtcTtys(dialogMenuItem *self); #ifdef __i386__ extern int checkLoaderACPI(void); extern int configLoaderACPI(int); #endif /* devices.c */ extern DMenu *deviceCreateMenu(DMenu *menu, DeviceType type, int (*hook)(dialogMenuItem *d), int (*check)(dialogMenuItem *d)); extern void deviceGetAll(void); extern void deviceReset(void); extern void deviceRescan(void); extern Device **deviceFind(char *name, DeviceType type); extern Device **deviceFindDescr(char *name, char *desc, DeviceType class); extern int deviceCount(Device **devs); extern Device *new_device(char *name); extern Device *deviceRegister(char *name, char *desc, char *devname, DeviceType type, Boolean enabled, Boolean (*init)(Device *mediadev), FILE * (*get)(Device *dev, char *file, Boolean probe), void (*shutDown)(Device *mediadev), void *private); extern Boolean dummyInit(Device *dev); extern FILE *dummyGet(Device *dev, char *dist, Boolean probe); extern void dummyShutdown(Device *dev); /* dhcp.c */ extern int dhcpParseLeases(char *file, char *hostname, char *domain, char *nameserver, char *ipaddr, char *gateway, char *netmask); /* disks.c */ #ifdef WITH_SLICES extern void diskPartition(Device *dev); extern int diskPartitionEditor(dialogMenuItem *self); #endif extern int diskPartitionWrite(dialogMenuItem *self); extern int diskGetSelectCount(Device ***devs); /* dispatch.c */ extern int dispatchCommand(char *command); extern int dispatch_load_floppy(dialogMenuItem *self); extern int dispatch_load_file_int(int); extern int dispatch_load_file(dialogMenuItem *self); /* dist.c */ extern int distReset(dialogMenuItem *self); extern int distConfig(dialogMenuItem *self); extern int distSetCustom(dialogMenuItem *self); extern int distUnsetCustom(dialogMenuItem *self); extern int distSetDeveloper(dialogMenuItem *self); extern int distSetXDeveloper(dialogMenuItem *self); extern int distSetKernDeveloper(dialogMenuItem *self); extern int distSetXKernDeveloper(dialogMenuItem *self); extern int distSetUser(dialogMenuItem *self); extern int distSetXUser(dialogMenuItem *self); extern int distSetMinimum(dialogMenuItem *self); extern int distSetEverything(dialogMenuItem *self); extern int distSetSrc(dialogMenuItem *self); extern int distSetXOrg(dialogMenuItem *self); extern int distExtractAll(dialogMenuItem *self); /* dmenu.c */ extern int dmenuDisplayFile(dialogMenuItem *tmp); extern int dmenuSubmenu(dialogMenuItem *tmp); extern int dmenuSystemCommand(dialogMenuItem *tmp); extern int dmenuSystemCommandBox(dialogMenuItem *tmp); extern int dmenuExit(dialogMenuItem *tmp); extern int dmenuISetVariable(dialogMenuItem *tmp); extern int dmenuSetVariable(dialogMenuItem *tmp); extern int dmenuSetKmapVariable(dialogMenuItem *tmp); extern int dmenuSetVariables(dialogMenuItem *tmp); extern int dmenuToggleVariable(dialogMenuItem *tmp); extern int dmenuSetFlag(dialogMenuItem *tmp); extern int dmenuSetValue(dialogMenuItem *tmp); extern Boolean dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons); extern Boolean dmenuOpenSimple(DMenu *menu, Boolean buttons); extern int dmenuVarCheck(dialogMenuItem *item); extern int dmenuVarsCheck(dialogMenuItem *item); extern int dmenuFlagCheck(dialogMenuItem *item); extern int dmenuRadioCheck(dialogMenuItem *item); /* doc.c */ extern int docBrowser(dialogMenuItem *self); extern int docShowDocument(dialogMenuItem *self); /* dos.c */ extern Boolean mediaCloseDOS(Device *dev, FILE *fp); extern Boolean mediaInitDOS(Device *dev); extern FILE *mediaGetDOS(Device *dev, char *file, Boolean probe); extern void mediaShutdownDOS(Device *dev); /* floppy.c */ extern int getRootFloppy(void); extern Boolean mediaInitFloppy(Device *dev); extern FILE *mediaGetFloppy(Device *dev, char *file, Boolean probe); extern void mediaShutdownFloppy(Device *dev); /* ftp_strat.c */ extern Boolean mediaCloseFTP(Device *dev, FILE *fp); extern Boolean mediaInitFTP(Device *dev); extern FILE *mediaGetFTP(Device *dev, char *file, Boolean probe); extern void mediaShutdownFTP(Device *dev); /* http.c */ extern Boolean mediaInitHTTP(Device *dev); extern FILE *mediaGetHTTP(Device *dev, char *file, Boolean probe); /* globals.c */ extern void globalsInit(void); /* index.c */ int index_read(FILE *fp, PkgNodePtr papa); int index_menu(PkgNodePtr root, PkgNodePtr top, PkgNodePtr plist, int *pos, int *scroll); void index_init(PkgNodePtr top, PkgNodePtr plist); void index_node_free(PkgNodePtr top, PkgNodePtr plist); void index_sort(PkgNodePtr top); void index_print(PkgNodePtr top, int level); int index_extract(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended); int index_initialize(char *path); PkgNodePtr index_search(PkgNodePtr top, char *str, PkgNodePtr *tp); /* install.c */ extern Boolean checkLabels(Boolean whinge); extern int installCommit(dialogMenuItem *self); extern int installCustomCommit(dialogMenuItem *self); extern int installExpress(dialogMenuItem *self); extern int installStandard(dialogMenuItem *self); extern int installFixitHoloShell(dialogMenuItem *self); extern int installFixitCDROM(dialogMenuItem *self); extern int installFixitFloppy(dialogMenuItem *self); extern int installFixupBase(dialogMenuItem *self); extern int installUpgrade(dialogMenuItem *self); extern int installFilesystems(dialogMenuItem *self); extern int installVarDefaults(dialogMenuItem *self); extern void installEnvironment(void); extern Boolean copySelf(void); /* kget.c */ extern int kget(char *out); /* keymap.c */ extern int loadKeymap(const char *lang); /* label.c */ extern int diskLabelEditor(dialogMenuItem *self); extern int diskLabelCommit(dialogMenuItem *self); /* makedevs.c (auto-generated) */ extern const char termcap_ansi[]; extern const char termcap_vt100[]; extern const char termcap_cons25w[]; extern const char termcap_cons25[]; extern const char termcap_cons25_m[]; extern const char termcap_cons25r[]; extern const char termcap_cons25r_m[]; extern const char termcap_cons25l1[]; extern const char termcap_cons25l1_m[]; extern const char termcap_xterm[]; extern const u_char font_iso_8x16[]; extern const u_char font_cp850_8x16[]; extern const u_char font_cp866_8x16[]; extern const u_char koi8_r2cp866[]; extern u_char default_scrnmap[]; /* media.c */ extern char *cpioVerbosity(void); +extern int mediaOpen(void); extern void mediaClose(void); extern int mediaTimeout(void); extern int mediaSetCDROM(dialogMenuItem *self); extern int mediaSetFloppy(dialogMenuItem *self); extern int mediaSetDOS(dialogMenuItem *self); extern int mediaSetTape(dialogMenuItem *self); extern int mediaSetFTP(dialogMenuItem *self); extern int mediaSetFTPActive(dialogMenuItem *self); extern int mediaSetFTPPassive(dialogMenuItem *self); extern int mediaSetHTTP(dialogMenuItem *self); extern int mediaSetUFS(dialogMenuItem *self); extern int mediaSetNFS(dialogMenuItem *self); extern int mediaSetFTPUserPass(dialogMenuItem *self); extern int mediaSetCPIOVerbosity(dialogMenuItem *self); extern int mediaGetType(dialogMenuItem *self); extern Boolean mediaExtractDist(char *dir, char *dist, FILE *fp); extern Boolean mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpic); extern Boolean mediaExtractDistEnd(int zpid, int cpid); extern Boolean mediaVerify(void); extern FILE *mediaGenericGet(char *base, const char *file); /* misc.c */ extern Boolean file_readable(char *fname); extern Boolean file_executable(char *fname); extern Boolean directory_exists(const char *dirname); extern char *root_bias(char *path); extern char *itoa(int value); extern char *string_concat(char *p1, char *p2); extern char *string_concat3(char *p1, char *p2, char *p3); extern char *string_prune(char *str); extern char *string_skipwhite(char *str); extern char *string_copy(char *s1, char *s2); extern char *pathBaseName(const char *path); extern void safe_free(void *ptr); extern void *safe_malloc(size_t size); extern void *safe_realloc(void *orig, size_t size); extern dialogMenuItem *item_add(dialogMenuItem *list, char *prompt, char *title, int (*checked)(dialogMenuItem *self), int (*fire)(dialogMenuItem *self), void (*selected)(dialogMenuItem *self, int is_selected), void *data, int *aux, int *curr, int *max); extern void items_free(dialogMenuItem *list, int *curr, int *max); extern int Mkdir(char *); extern int Mkdir_command(char *key, void *data); extern int Mount(char *, void *data); extern int Mount_msdosfs(char *mountp, void *devname); extern WINDOW *openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height); extern ComposeObj *initLayoutDialog(WINDOW *win, Layout *layout, int x, int y, int *max); extern int layoutDialogLoop(WINDOW *win, Layout *layout, ComposeObj **obj, int *n, int max, int *cbutton, int *cancel); extern WINDOW *savescr(void); extern void restorescr(WINDOW *w); extern char *sstrncpy(char *dst, const char *src, int size); /* modules.c */ extern void driverFloppyCheck(void); extern void moduleInitialize(void); extern int kldBrowser(dialogMenuItem *self); /* mouse.c */ extern int mousedTest(dialogMenuItem *self); extern int mousedDisable(dialogMenuItem *self); extern int setMouseFlags(dialogMenuItem *self); /* msg.c */ extern Boolean isDebug(void); extern void msgInfo(char *fmt, ...) __printf0like(1, 2); extern void msgYap(char *fmt, ...) __printflike(1, 2); extern void msgWarn(char *fmt, ...) __printflike(1, 2); extern void msgDebug(char *fmt, ...) __printflike(1, 2); extern void msgError(char *fmt, ...) __printflike(1, 2); extern void msgFatal(char *fmt, ...) __printflike(1, 2); extern void msgConfirm(char *fmt, ...) __printflike(1, 2); extern void msgNotify(char *fmt, ...) __printflike(1, 2); extern void msgWeHaveOutput(char *fmt, ...) __printflike(1, 2); extern int msgYesNo(char *fmt, ...) __printflike(1, 2); extern int msgNoYes(char *fmt, ...) __printflike(1, 2); extern char *msgGetInput(char *buf, char *fmt, ...) __printflike(2, 3); extern int msgSimpleConfirm(char *); extern int msgSimpleNotify(char *); /* network.c */ extern Boolean mediaInitNetwork(Device *dev); extern void mediaShutdownNetwork(Device *dev); /* nfs.c */ extern Boolean mediaInitNFS(Device *dev); extern FILE *mediaGetNFS(Device *dev, char *file, Boolean probe); extern void mediaShutdownNFS(Device *dev); /* options.c */ extern int optionsEditor(dialogMenuItem *self); /* package.c */ extern int packageAdd(dialogMenuItem *self); extern int package_add(char *name); extern int package_extract(Device *dev, char *name, Boolean depended); extern Boolean package_installed(char *name); /* pccard.c */ extern void pccardInitialize(void); /* system.c */ extern void systemInitialize(int argc, char **argv); extern void systemShutdown(int status); extern int execExecute(char *cmd, char *name); extern int systemExecute(char *cmd); extern void systemSuspendDialog(void); extern void systemResumeDialog(void); extern int systemDisplayHelp(char *file); extern char *systemHelpFile(char *file, char *buf); extern void systemChangeFont(const u_char font[]); extern void systemChangeLang(char *lang); extern void systemChangeTerminal(char *color, const u_char c_termcap[], char *mono, const u_char m_termcap[]); extern void systemChangeScreenmap(const u_char newmap[]); extern void systemCreateHoloshell(void); extern int vsystem(char *fmt, ...) __printflike(1, 2); /* tape.c */ extern char *mediaTapeBlocksize(void); extern Boolean mediaInitTape(Device *dev); extern FILE *mediaGetTape(Device *dev, char *file, Boolean probe); extern void mediaShutdownTape(Device *dev); /* tcpip.c */ extern int tcpOpenDialog(Device *dev); extern int tcpMenuSelect(dialogMenuItem *self); extern Device *tcpDeviceSelect(void); /* termcap.c */ extern int set_termcap(void); /* ttys.c */ extern void configTtys(void); /* ufs.c */ extern void mediaShutdownUFS(Device *dev); extern Boolean mediaInitUFS(Device *dev); extern FILE *mediaGetUFS(Device *dev, char *file, Boolean probe); /* user.c */ extern int userAddGroup(dialogMenuItem *self); extern int userAddUser(dialogMenuItem *self); /* variable.c */ extern void variable_set(char *var, int dirty); extern void variable_set2(char *name, char *value, int dirty); extern char *variable_get(char *var); extern int variable_cmp(char *var, char *value); extern void variable_unset(char *var); extern char *variable_get_value(char *var, char *prompt, int dirty); extern int variable_check(char *data); extern int variable_check2(char *data); extern int dump_variables(dialogMenuItem *self); extern void free_variables(void); extern void pvariable_set(char *var); extern char *pvariable_get(char *var); /* wizard.c */ extern void slice_wizard(Disk *d); /* * Macros. Please find a better place for us! */ #define DEVICE_INIT(d) ((d) != NULL ? (d)->init((d)) : (Boolean)0) #define DEVICE_GET(d, b, f) ((d) != NULL ? (d)->get((d), (b), (f)) : NULL) #define DEVICE_SHUTDOWN(d) ((d) != NULL ? (d)->shutdown((d)) : (void)0) #ifdef USE_GZIP #define UNZIPPER "gunzip" #else #define UNZIPPER "bunzip2" #endif #endif /* _SYSINSTALL_H_INCLUDE */