Say welcome to 'sade', the SysAdmins Disk Editor. It's the fdisk and disklabel part

of sysinstall. So sysinstall may retire now, we have the important non-install part
of it covered.

ATM it doesn't understand GEOM stuff (like mirror, stripe, raid, ...), but patches
to change this and to clean it up internally are more than welcome.

Submitted by:	mami@nyitolap.hu
This commit is contained in:
Alexander Leidinger 2006-08-07 23:35:49 +00:00
parent e6748c986c
commit 2e14ff0f41
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=161060
23 changed files with 131 additions and 6355 deletions

View File

@ -4,15 +4,16 @@
_wizard= wizard.c
.endif
PROG= sysinstall
MAN= sysinstall.8
SRCS= anonFTP.c cdrom.c command.c config.c devices.c dhcp.c \
disks.c dispatch.c dist.c dmenu.c doc.c dos.c floppy.c \
ftp.c globals.c http.c index.c install.c installUpgrade.c keymap.c \
label.c main.c makedevs.c media.c menus.c misc.c modules.c \
mouse.c msg.c network.c nfs.c options.c package.c \
system.c tape.c tcpip.c termcap.c ttys.c ufs.c user.c \
variable.c ${_wizard} keymap.h countries.h
PROG= sade
MAN= sade.8
SRCS= command.c config.c devices.c \
disks.c dispatch.c dmenu.c \
globals.c install.c keymap.c \
label.c main.c makedevs.c menus.c misc.c \
msg.c system.c termcap.c \
variable.c ${_wizard} keymap.h
# command.c
CFLAGS+= -DUSE_GZIP=1
.if ${MACHINE} == "pc98"
@ -23,39 +24,8 @@ CFLAGS+= -I${.CURDIR}/../../gnu/lib/libdialog -I.
DPADD= ${LIBDIALOG} ${LIBNCURSES} ${LIBUTIL} ${LIBDISK} ${LIBFTPIO}
LDADD= -ldialog -lncurses -lutil -ldisk -lftpio
#
# When distributions have both UP and SMP kernels sysinstall
# will probe for the number of cpus on the target machine and
# automatically select which is appropriate. This can be overridden
# through the menus or both kernels can be installed (with the
# most "appropriate" one setup as /boot/kernel). For now this
# is done for i386 and amd64; for other systems support must be
# added to identify the cpu count if acpi and MPTable probing
# is insufficient.
#
# The unmber of cpus probed is passed through the environment in
# VAR_NCPUS ("ncpus") to scripts.
#
# Note that WITH_SMP is a compile time option that enables the
# builtin menus for the SMP kernel configuration. If this kernel
# is not built (see release/Makefile) then this should not be
# enabled as sysinstall may try to select an SMP kernel config
# where none is available. This option should not be needed--we
# should probe for an SMP kernel in the distribution but doing
# that is painful because of media changes and the structure of
# sysinstall so for now it's a priori.
#
.if ${MACHINE} == "i386" || ${MACHINE_ARCH} == "amd64"
SRCS+= acpi.c biosmptable.c
.if exists(${.CURDIR}/../../sys/${MACHINE}/conf/SMP)
CFLAGS+=-DWITH_SMP
.endif
DPADD+= ${LIBDEVINFO}
LDADD+= -ldevinfo
.endif
CLEANFILES= makedevs.c rtermcap
CLEANFILES+= keymap.tmp keymap.h countries.tmp countries.h
CLEANFILES+= keymap.tmp keymap.h
.if exists(${.CURDIR}/../../share/termcap/termcap.src)
RTERMCAP= TERMCAP=${.CURDIR}/../../share/termcap/termcap.src ./rtermcap
@ -130,25 +100,4 @@ keymap.h:
( echo " { NULL, NULL }"; echo "};" ; echo "" ) >> keymap.tmp
mv keymap.tmp keymap.h
countries.h: ${.CURDIR}/../../share/misc/iso3166
rm -f countries.tmp
awk 'BEGIN { \
FS = "\t"; \
num = 1; \
print "DMenu MenuCountry = {"; \
print " DMENU_NORMAL_TYPE | DMENU_SELECTION_RETURNS,"; \
print " \"Country Selection\","; \
print " \"Please choose a country, region, or group.\\n\""; \
print " \"Select an item using [SPACE] or [ENTER].\","; \
printf " NULL,\n NULL,\n { "; \
} \
/^[[:space:]]*#/ {next;} \
{if (num > 1) {printf " ";} \
print "{ \"" num "\", \"" $$4 "\"" \
", dmenuVarCheck, dmenuSetCountryVariable" \
", NULL, VAR_COUNTRY \"=" tolower($$1) "\" },"; \
++num;} \
END {print " { NULL } }\n};\n";}' < ${.ALLSRC} > countries.tmp
mv countries.tmp ${.TARGET}
.include <bsd.prog.mk>

View File

@ -1,9 +1,4 @@
/*
* 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
@ -34,7 +29,7 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
#define MAX_NUM_COMMANDS 10

View File

@ -1,9 +1,4 @@
/*
* 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
@ -34,7 +29,7 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
#include <sys/disklabel.h>
#include <sys/wait.h>
#include <sys/errno.h>
@ -182,7 +177,6 @@ configFstab(dialogMenuItem *self)
int i, cnt;
Chunk *c1, *c2;
if (!RunningAsInit) {
if (file_readable("/etc/fstab"))
return DITEM_SUCCESS;
else {
@ -190,7 +184,6 @@ configFstab(dialogMenuItem *self)
"any CD devices in use before running sysinstall then they may NOT\n"
"be found by this run!");
}
}
devs = deviceFind(NULL, DEVICE_TYPE_DISK);
if (!devs) {
@ -241,20 +234,6 @@ configFstab(dialogMenuItem *self)
fprintf(fstab, "/dev/%s\t\t%s\t\t%s\t%s\t\t%d\t%d\n", name_of(chunk_list[i]), mount_point(chunk_list[i]),
fstype(chunk_list[i]), fstype_short(chunk_list[i]), seq_num(chunk_list[i]), seq_num(chunk_list[i]));
/* Now look for the CDROMs */
devs = deviceFind(NULL, DEVICE_TYPE_CDROM);
cnt = deviceCount(devs);
/* Write out the CDROM entries */
for (i = 0; i < cnt; i++) {
char cdname[10];
sprintf(cdname, "/cdrom%s", i ? itoa(i) : "");
if (Mkdir(cdname))
msgConfirm("Unable to make mount point for: %s", cdname);
else
fprintf(fstab, "/dev/%s\t\t%s\t\tcd9660\tro,noauto\t0\t0\n", devs[i]->name, cdname);
}
fclose(fstab);
if (isDebug())
@ -262,6 +241,7 @@ configFstab(dialogMenuItem *self)
return DITEM_SUCCESS;
}
#if 0
/* Do the work of sucking in a config file.
* config is the filename to read in.
* lines is a fixed (max) sized array of char*
@ -291,9 +271,11 @@ readConfig(char *config, char **lines, int max)
msgDebug("readConfig: Read %d lines from %s.\n", nlines, config);
return nlines;
}
#endif
#define MAX_LINES 2000 /* Some big number we're not likely to ever reach - I'm being really lazy here, I know */
#if 0
static void
readConfigFile(char *config, int marked)
{
@ -319,7 +301,7 @@ readConfigFile(char *config, int marked)
/* If valid quotes, use it */
if (cp2) {
*cp2 = '\0';
/* If we have a legit value, set it */
/* If we have a legit value, set it */
if (strlen(cp))
variable_set2(lines[i], cp, marked);
}
@ -347,740 +329,5 @@ configEnvironmentRC_conf(void)
readConfigFile(configs[i].fname, configs[i].marked);
}
}
/* Load the environment from a resolv.conf file */
void
configEnvironmentResolv(char *config)
{
char *lines[MAX_LINES];
int i, nlines;
nlines = readConfig(config, lines, MAX_LINES);
if (nlines == -1)
return;
for (i = 0; i < nlines; i++) {
Boolean name_set = variable_get(VAR_NAMESERVER) ? 1 : 0;
if (!strncmp(lines[i], "domain", 6) && !variable_get(VAR_DOMAINNAME))
variable_set2(VAR_DOMAINNAME, string_skipwhite(string_prune(lines[i] + 6)), 0);
else if (!name_set && !strncmp(lines[i], "nameserver", 10)) {
/* Only take the first nameserver setting - we're lame */
variable_set2(VAR_NAMESERVER, string_skipwhite(string_prune(lines[i] + 10)), 0);
}
free(lines[i]);
}
}
/* Version of below for dispatch routines */
int
configRC(dialogMenuItem *unused)
{
configRC_conf();
return DITEM_SUCCESS;
}
/*
* Write out rc.conf
*
* rc.conf is sorted if running as init and the needed utilities are
* present
*
* If rc.conf is sorted, all variables in rc.conf which conflict with
* the variables in the environment are removed from the original
* rc.conf
*/
void
configRC_conf(void)
{
char line[256];
FILE *rcSite, *rcOld;
Variable *v;
int write_header;
time_t t_loc;
char *cp;
static int did_marker = 0;
int do_sort;
int do_merge;
time_t tp;
configTtys();
write_header = !file_readable("/etc/rc.conf");
do_sort = RunningAsInit && file_readable("/usr/bin/sort") &&
file_readable("/usr/bin/uniq");
do_merge = do_sort && file_readable("/etc/rc.conf");
if(do_merge) {
rcSite = fopen("/etc/rc.conf.new", "w");
} else
rcSite = fopen("/etc/rc.conf", "a");
if (rcSite == NULL) {
msgError("Error opening new rc.conf for writing: %s (%u)", strerror(errno), errno);
return;
}
if (do_merge) {
/* "Copy" the old rc.conf */
rcOld = fopen("/etc/rc.conf", "r");
if(!rcOld) {
msgError("Error opening rc.conf for reading: %s (%u)", strerror(errno), errno);
return;
}
while(fgets(line, sizeof(line), rcOld)) {
if(line[0] == '#' || variable_check2(line) != 0)
fprintf(rcSite, "%s", line);
else
fprintf(rcSite, "#REMOVED: %s", line);
}
fclose(rcOld);
} else if (write_header) {
fprintf(rcSite, "# This file now contains just the overrides from /etc/defaults/rc.conf.\n");
fprintf(rcSite, "# Please make all changes to this file, not to /etc/defaults/rc.conf.\n\n");
fprintf(rcSite, "# Enable network daemons for user convenience.\n");
if ((t_loc = time(NULL)) != -1 && (cp = ctime(&t_loc)))
fprintf(rcSite, "# Created: %s", cp);
}
/* Now do variable substitutions */
for (v = VarHead; v; v = v->next) {
if (v->dirty) {
if (!did_marker) {
time(&tp);
fprintf(rcSite, "# -- sysinstall generated deltas -- # "
"%s", ctime(&tp));
did_marker = 1;
}
fprintf(rcSite, "%s=\"%s\"\n", v->name, v->value);
v->dirty = 0;
}
}
fclose(rcSite);
if(do_merge) {
if(rename("/etc/rc.conf.new", "/etc/rc.conf") != 0) {
msgError("Error renaming temporary rc.conf: %s (%u)", strerror(errno), errno);
return;
}
}
/* Tidy up the resulting file if it's late enough in the installation
for sort and uniq to be available */
if (do_sort) {
(void)vsystem("sort /etc/rc.conf | uniq > /etc/rc.conf.new && mv /etc/rc.conf.new /etc/rc.conf");
}
}
int
configSaver(dialogMenuItem *self)
{
variable_set((char *)self->data, 1);
if (!variable_get(VAR_BLANKTIME))
variable_set2(VAR_BLANKTIME, "300", 1);
return DITEM_SUCCESS;
}
int
configSaverTimeout(dialogMenuItem *self)
{
return (variable_get_value(VAR_BLANKTIME,
"Enter time-out period in seconds for screen saver", 1) ?
DITEM_SUCCESS : DITEM_FAILURE);
}
int
configNTP(dialogMenuItem *self)
{
int status;
status = variable_get_value(VAR_NTPDATE_FLAGS,
"Enter the name of an NTP server", 1)
? DITEM_SUCCESS : DITEM_FAILURE;
if (status == DITEM_SUCCESS) {
static char tmp[255];
snprintf(tmp, sizeof(tmp), "ntpdate_enable=YES,ntpdate_flags=%s",
variable_get(VAR_NTPDATE_FLAGS));
self->data = tmp;
dmenuSetVariables(self);
}
return status;
}
int
configCountry(dialogMenuItem *self)
{
int choice, scroll, curr, max;
WINDOW *w = savescr();
dialog_clear_norefresh();
dmenuSetDefaultItem(&MenuCountry, NULL, NULL,
VAR_COUNTRY "=" DEFAULT_COUNTRY, &choice, &scroll, &curr, &max);
dmenuOpen(&MenuCountry, &choice, &scroll, &curr, &max, FALSE);
restorescr(w);
return DITEM_SUCCESS;
}
int
configUsers(dialogMenuItem *self)
{
WINDOW *w = savescr();
dialog_clear_norefresh();
dmenuOpenSimple(&MenuUsermgmt, FALSE);
restorescr(w);
return DITEM_SUCCESS;
}
#ifdef WITH_LINUX
int
configLinux(dialogMenuItem *self)
{
WINDOW *w = savescr();
int i;
dialog_clear_norefresh();
variable_set2(VAR_LINUX_ENABLE, "YES", 1);
Mkdir("/compat/linux");
msgNotify("Installing Linux compatibility library...");
i = package_add("linux_base-8");
restorescr(w);
return i;
}
#endif
#ifdef __alpha__
int
configOSF1(dialogMenuItem *self)
{
variable_set2(VAR_OSF1_ENABLE, "YES", 1);
Mkdir("/compat/osf1");
return DITEM_SUCCESS;
}
#endif
int
configSecurelevel(dialogMenuItem *self)
{
WINDOW *w = savescr();
dialog_clear_norefresh();
dmenuOpenSimple(&MenuSecurelevel, FALSE);
restorescr(w);
return DITEM_SUCCESS;
}
int
configSecurelevelDisabled(dialogMenuItem *self)
{
variable_set2("kern_securelevel_enable", "NO", 1);
return DITEM_SUCCESS;
}
int
configSecurelevelSecure(dialogMenuItem *self)
{
variable_set2("kern_securelevel_enable", "YES", 1);
variable_set2("kern_securelevel", "1", 1);
return DITEM_SUCCESS;
}
int
configSecurelevelHighlySecure(dialogMenuItem *self)
{
variable_set2("kern_securelevel_enable", "YES", 1);
variable_set2("kern_securelevel", "2", 1);
return DITEM_SUCCESS;
}
int
configSecurelevelNetworkSecure(dialogMenuItem *self)
{
variable_set2("kern_securelevel_enable", "YES", 1);
variable_set2("kern_securelevel", "3", 1);
return DITEM_SUCCESS;
}
int
configResolv(dialogMenuItem *ditem)
{
FILE *fp;
char *cp, *c6p, *dp, *hp;
cp = variable_get(VAR_NAMESERVER);
if (!cp || !*cp)
goto skip;
Mkdir("/etc");
fp = fopen("/etc/resolv.conf", "w");
if (!fp)
return DITEM_FAILURE;
if (variable_get(VAR_DOMAINNAME))
fprintf(fp, "domain\t%s\n", variable_get(VAR_DOMAINNAME));
fprintf(fp, "nameserver\t%s\n", cp);
fclose(fp);
if (isDebug())
msgDebug("Wrote out /etc/resolv.conf\n");
skip:
dp = variable_get(VAR_DOMAINNAME);
cp = variable_get(VAR_IPADDR);
c6p = variable_get(VAR_IPV6ADDR);
hp = variable_get(VAR_HOSTNAME);
/* Tack ourselves into /etc/hosts */
fp = fopen("/etc/hosts", "w");
if (!fp)
return DITEM_FAILURE;
/* Add an entry for localhost */
if (dp) {
fprintf(fp, "::1\t\t\tlocalhost.%s localhost\n", dp);
fprintf(fp, "127.0.0.1\t\tlocalhost.%s localhost\n", dp);
} else {
fprintf(fp, "::1\t\t\tlocalhost\n");
fprintf(fp, "127.0.0.1\t\tlocalhost\n");
}
/* Now the host entries, if applicable */
if (((cp && cp[0] != '0') || (c6p && c6p[0] != '0')) && hp) {
char cp2[255];
if (!index(hp, '.'))
cp2[0] = '\0';
else {
SAFE_STRCPY(cp2, hp);
*(index(cp2, '.')) = '\0';
}
if (c6p && c6p[0] != '0') {
fprintf(fp, "%s\t%s %s\n", c6p, hp, cp2);
fprintf(fp, "%s\t%s.\n", c6p, hp);
}
if (cp && cp[0] != '0') {
fprintf(fp, "%s\t\t%s %s\n", cp, hp, cp2);
fprintf(fp, "%s\t\t%s.\n", cp, hp);
}
}
fclose(fp);
if (isDebug())
msgDebug("Wrote out /etc/hosts\n");
return DITEM_SUCCESS;
}
int
configRouter(dialogMenuItem *self)
{
int ret;
ret = variable_get_value(VAR_ROUTER,
"Please specify the router you wish to use. Routed is\n"
"provided with the stock system and gated is provided\n"
"as an optional package which this installation system\n"
"will attempt to load if you select gated. Any other\n"
"choice of routing daemon will be assumed to be something\n"
"the user intends to install themselves before rebooting\n"
"the system. If you don't want any routing daemon, choose NO", 1)
? DITEM_SUCCESS : DITEM_FAILURE;
if (ret == DITEM_SUCCESS) {
char *cp = variable_get(VAR_ROUTER);
if (cp && strcmp(cp, "NO")) {
variable_set2(VAR_ROUTER_ENABLE, "YES", 1);
if (!strcmp(cp, "gated")) {
if (package_add("gated") != DITEM_SUCCESS) {
msgConfirm("Unable to load gated package. Falling back to no router.");
variable_unset(VAR_ROUTER);
variable_unset(VAR_ROUTERFLAGS);
variable_set2(VAR_ROUTER_ENABLE, "NO", 1);
cp = NULL;
}
}
if (cp) {
/* Now get the flags, if they chose a router */
ret = variable_get_value(VAR_ROUTERFLAGS,
"Please Specify the routing daemon flags; if you're running routed\n"
"then -q is the right choice for nodes and -s for gateway hosts.\n", 1)
? DITEM_SUCCESS : DITEM_FAILURE;
if (ret != DITEM_SUCCESS)
variable_unset(VAR_ROUTERFLAGS);
}
}
else {
/* No router case */
variable_set2(VAR_ROUTER_ENABLE, "NO", 1);
variable_unset(VAR_ROUTERFLAGS);
variable_unset(VAR_ROUTER);
}
}
else {
variable_set2(VAR_ROUTER_ENABLE, "NO", 1);
variable_unset(VAR_ROUTERFLAGS);
variable_unset(VAR_ROUTER);
}
return ret;
}
/* Shared between us and index_initialize() */
extern PkgNode Top, Plist;
int
configPackages(dialogMenuItem *self)
{
int i, restoreflag = 0;
PkgNodePtr tmp;
/* Did we get an INDEX? */
i = index_initialize("packages/INDEX");
if (DITEM_STATUS(i) == DITEM_FAILURE)
return i;
while (1) {
int ret, pos, scroll;
/* Bring up the packages menu */
pos = scroll = 0;
index_menu(&Top, &Top, &Plist, &pos, &scroll);
if (Plist.kids && Plist.kids->name) {
/* Now show the packing list menu */
pos = scroll = 0;
ret = index_menu(&Plist, &Plist, NULL, &pos, &scroll);
if (ret & DITEM_LEAVE_MENU)
break;
else if (DITEM_STATUS(ret) != DITEM_FAILURE) {
dialog_clear();
restoreflag = 1;
for (tmp = Plist.kids; tmp && tmp->name; tmp = tmp->next)
(void)index_extract(mediaDevice, &Top, tmp, FALSE);
break;
}
}
else {
msgConfirm("No packages were selected for extraction.");
break;
}
}
tmp = Plist.kids;
while (tmp) {
PkgNodePtr tmp2 = tmp->next;
safe_free(tmp);
tmp = tmp2;
}
index_init(NULL, &Plist);
return DITEM_SUCCESS | (restoreflag ? DITEM_RESTORE : 0);
}
/* Load pcnfsd package */
int
configPCNFSD(dialogMenuItem *self)
{
int ret;
ret = package_add("pcnfsd");
if (DITEM_STATUS(ret) == DITEM_SUCCESS) {
variable_set2(VAR_PCNFSD, "YES", 0);
variable_set2("mountd_flags", "-n", 1);
}
return ret;
}
int
configInetd(dialogMenuItem *self)
{
char cmd[256];
WINDOW *w = savescr();
if (msgYesNo("The Internet Super Server (inetd) allows a number of simple Internet\n"
"services to be enabled, including finger, ftp, and telnetd. Enabling\n"
"these services may increase risk of security problems by increasing\n"
"the exposure of your system.\n\n"
"With this in mind, do you wish to enable inetd?\n")) {
variable_set2("inetd_enable", "NO", 1);
} else {
/* If inetd is enabled, we'll need an inetd.conf */
variable_set2("inetd_enable", "YES", 1);
if (!msgYesNo("inetd(8) relies on its configuration file, /etc/inetd.conf, to determine\n"
"which of its Internet services will be available. The default FreeBSD\n"
"inetd.conf(5) leaves all services disabled by default, so they must be\n"
"specifically enabled in the configuration file before they will\n"
"function, even once inetd(8) is enabled. Note that services for\n"
"IPv6 must be separately enabled from IPv4 services.\n\n"
"Select [Yes] now to invoke an editor on /etc/inetd.conf, or [No] to\n"
"use the current settings.\n")) {
sprintf(cmd, "%s /etc/inetd.conf", variable_get(VAR_EDITOR));
dialog_clear();
systemExecute(cmd);
}
}
restorescr(w);
return DITEM_SUCCESS;
}
int
configNFSServer(dialogMenuItem *self)
{
char cmd[256];
int retval = 0;
/* If we're an NFS server, we need an exports file */
if (!file_readable("/etc/exports")) {
WINDOW *w = savescr();
if (file_readable("/etc/exports.disabled"))
vsystem("mv /etc/exports.disabled /etc/exports");
else {
dialog_clear_norefresh();
msgConfirm("Operating as an NFS server means that you must first configure\n"
"an /etc/exports file to indicate which hosts are allowed certain\n"
"kinds of access to your local file systems.\n"
"Press [ENTER] now to invoke an editor on /etc/exports\n");
vsystem("echo '#The following examples export /usr to 3 machines named after ducks,' > /etc/exports");
vsystem("echo '#/usr/src and /usr/ports read-only to machines named after trouble makers' >> /etc/exports");
vsystem("echo '#/home and all directories under it to machines named after dead rock stars' >> /etc/exports");
vsystem("echo '#and, /a to a network of privileged machines allowed to write on it as root.' >> /etc/exports");
vsystem("echo '#/usr huey louie dewie' >> /etc/exports");
vsystem("echo '#/usr/src /usr/obj -ro calvin hobbes' >> /etc/exports");
vsystem("echo '#/home -alldirs janice jimmy frank' >> /etc/exports");
vsystem("echo '#/a -maproot=0 -network 10.0.1.0 -mask 255.255.248.0' >> /etc/exports");
vsystem("echo '#' >> /etc/exports");
vsystem("echo '# You should replace these lines with your actual exported filesystems.' >> /etc/exports");
vsystem("echo \"# Note that BSD's export syntax is 'host-centric' vs. Sun's 'FS-centric' one.\" >> /etc/exports");
vsystem("echo >> /etc/exports");
sprintf(cmd, "%s /etc/exports", variable_get(VAR_EDITOR));
dialog_clear();
systemExecute(cmd);
}
variable_set2(VAR_NFS_SERVER, "YES", 1);
retval = configRpcBind(NULL);
restorescr(w);
}
else if (variable_get(VAR_NFS_SERVER)) { /* We want to turn it off again? */
vsystem("mv -f /etc/exports /etc/exports.disabled");
variable_unset(VAR_NFS_SERVER);
}
return DITEM_SUCCESS | retval;
}
/*
* Extend the standard dmenuToggleVariable() method to also check and set
* the rpcbind variable if needed.
*/
int
configRpcBind(dialogMenuItem *self)
{
int retval = 0;
int doupdate = 1;
if (self != NULL) {
retval = dmenuToggleVariable(self);
if (strcmp(variable_get(self->data), "YES") != 0)
doupdate = 0;
}
if (doupdate && strcmp(variable_get(VAR_RPCBIND_ENABLE), "YES") != 0) {
variable_set2(VAR_RPCBIND_ENABLE, "YES", 1);
retval |= DITEM_REDRAW;
}
return retval;
}
int
configEtcTtys(dialogMenuItem *self)
{
char cmd[256];
WINDOW *w = savescr();
/* Simply prompt for confirmation, then edit away. */
if (msgYesNo("Configuration of system TTYs requires editing the /etc/ttys file.\n"
"Typical configuration activities might include enabling getty(8)\n"
"on the first serial port to allow login via serial console after\n"
"reboot, or to enable xdm. The default ttys file enables normal\n"
"virtual consoles, and most sites will not need to perform manual\n"
"configuration.\n\n"
"To load /etc/ttys in the editor, select [Yes], otherwise, [No].")) {
} else {
configTtys();
sprintf(cmd, "%s /etc/ttys", variable_get(VAR_EDITOR));
dialog_clear();
systemExecute(cmd);
}
restorescr(w);
return DITEM_SUCCESS;
}
#ifdef __i386__
int
checkLoaderACPI(void)
{
char val[4];
if (kenv(KENV_GET, "loader.acpi_disabled_by_user", &val[0], 4) <= 0) {
return (0);
}
if (strtol(&val[0], NULL, 10) <= 0) {
return (0);
}
return (1);
}
int
configLoaderACPI(int disable)
{
FILE *ldconf;
ldconf = fopen("/boot/loader.conf", "a");
if (ldconf == NULL) {
msgConfirm("Unable to open /boot/loader.conf. Please consult the\n"
"FreeBSD Handbook for instructions on disabling ACPI");
return DITEM_FAILURE;
}
fprintf(ldconf, "# --- Generated by sysinstall ---\n");
fprintf(ldconf, "hint.acpi.0.disabled=%d\n", disable);
fclose(ldconf);
return DITEM_SUCCESS;
}
#endif
int
configMTAPostfix(dialogMenuItem *self)
{
int ret;
FILE *perconf;
if(setenv("POSTFIX_DEFAULT_MTA", "YES", 1) != 0)
msgError("Error setting the enviroment variable POSTFIX_DEFAULT_MTA: %s (%u)",
strerror(errno), errno);
ret = package_add("postfix-2.2");
unsetenv("POSTFIX_DEFAULT_MTA");
if(DITEM_STATUS(ret) == DITEM_FAILURE) {
msgConfirm("An error occurred while adding the postfix package\n"
"Please change installation media and try again.");
return ret;
}
variable_set2(VAR_SENDMAIL_ENABLE, "YES", 1);
variable_set2("sendmail_flags", "-bd", 1);
variable_set2("sendmail_outbound_enable", "NO", 1);
variable_set2("sendmail_submit_enable", "NO", 1);
variable_set2("sendmail_msp_queue_enable", "NO", 1);
perconf = fopen("/etc/periodic.conf", "a");
if (perconf == NULL) {
msgConfirm("Unable to open /etc/periodic.conf.\n"
"The daily cleanup scripts might generate errors when\n"
"trying to run some sendmail only cleanup scripts.\n"
"Please consult the documentation for the postfix port on how to\n"
"fix this.");
/* Not really a serious problem, so we return success */
return DITEM_SUCCESS;
}
fprintf(perconf, "# --- Generated by sysinstall ---\n");
fprintf(perconf, "daily_clean_hoststat_enable=\"NO\"\n");
fprintf(perconf, "daily_status_mail_rejects_enable=\"NO\"\n");
fprintf(perconf, "daily_status_include_submit_mailq=\"NO\"\n");
fprintf(perconf, "daily_submit_queuerun=\"NO\"\n");
fclose(perconf);
msgConfirm("Postfix is now installed and enabled as the default MTA.\n"
"Please check that the configuration works as expected.\n"
"See the Postfix documentation for more information.\n"
"The documentation can be found in /usr/local/share/doc/postfix/\n"
"or on the Postfix website at http://www.postfix.org/.");
return DITEM_SUCCESS;
}
int
configMTAExim(dialogMenuItem *self)
{
int ret;
FILE *perconf, *mailerconf, *newsyslogconf;
ret = package_add("exim");
if(DITEM_STATUS(ret) == DITEM_FAILURE) {
msgConfirm("An error occurred while adding the exim package\n"
"Please change installation media and try again.");
return ret;
}
variable_set2(VAR_SENDMAIL_ENABLE, "NONE", 1);
variable_set2("exim_enable", "YES", 1);
/* Update periodic.conf */
perconf = fopen("/etc/periodic.conf", "a");
if (perconf == NULL) {
/* Not really a serious problem, so we do not abort */
msgConfirm("Unable to open /etc/periodic.conf.\n"
"The daily cleanup scripts might generate errors when\n"
"trying to run some sendmail only cleanup scripts.\n"
"Please consult the documentation for the exim port on how to\n"
"fix this.");
} else {
fprintf(perconf, "# --- Generated by sysinstall ---\n");
fprintf(perconf, "daily_clean_hoststat_enable=\"NO\"\n");
fprintf(perconf, "daily_status_include_submit_mailq=\"NO\"\n");
fprintf(perconf, "daily_status_mail_rejects_enable=\"NO\"\n");
fprintf(perconf, "daily_submit_queuerun=\"NO\"\n");
fclose(perconf);
}
/* Update mailer.conf */
vsystem("mv -f /etc/mail/mailer.conf /etc/mail/mailer.conf.old");
mailerconf = fopen("/etc/mail/mailer.conf", "w");
if (mailerconf == NULL) {
/* Not really a serious problem, so we do not abort */
msgConfirm("Unable to open /etc/mailer.conf.\n"
"Some programs which use the sendmail wrappers may not work.\n"
"Please consult the documentation for the exim port on how\n"
"to correct this.");
} else {
fprintf(mailerconf, "# --- Generated by sysinstall ---\n");
fprintf(mailerconf, "# Execute exim instead of sendmail\n");
fprintf(mailerconf, "#\n");
fprintf(mailerconf, "sendmail /usr/local/sbin/exim\n");
fprintf(mailerconf, "send-mail /usr/local/sbin/exim\n");
fprintf(mailerconf, "mailq /usr/local/sbin/exim\n");
fprintf(mailerconf, "newaliases /usr/local/sbin/exim\n");
fprintf(mailerconf, "hoststat /usr/bin/true\n");
fprintf(mailerconf, "purgestat /usr/bin/true\n");
fclose(mailerconf);
}
/* Make newsyslog rotate exim logfiles */
newsyslogconf = fopen("/etc/newsyslog.conf", "a");
if (newsyslogconf == NULL) {
/* Not really a serious problem, so we do not abort */
msgConfirm("Unable to open /etc/newsyslog.conf.\n"
"The exim logfiles will not be rotated.\n"
"Please consult the documentation for the exim port on how to\n"
"rotate the logfiles.");
} else {
fprintf(newsyslogconf, "# --- Generated by sysinstall ---\n");
fprintf(newsyslogconf, "/var/log/exim/mainlog mailnull:mail 640 7 * @T00 ZN\n");
fprintf(newsyslogconf, "/var/log/exim/rejectlog mailnull:mail 640 7 * @T00 ZN\n");
fclose(newsyslogconf);
}
msgConfirm("Exim is now installed and enabled as the default MTA.\n"
"Please check that the configuration works as expected.\n"
"See the Exim documentation for more information.\n"
"The documentation can be found in /usr/local/share/doc/exim/\n"
"or on the Exim website at http://www.exim.org/.");
return DITEM_SUCCESS;
}

View File

@ -1,9 +1,4 @@
/*
* 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
@ -34,39 +29,27 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
#include <sys/fcntl.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
#include <sys/time.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_dl.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <ctype.h>
#include <libdisk.h>
/* how much to bias minor number for a given /dev/<ct#><un#>s<s#> slice */
#define SLICE_DELTA (0x10000)
static Device *Devices[DEV_MAX];
static int numDevs;
#define DEVICE_ENTRY(type, name, descr, max) { type, name, descr, max }
#define DEVICE_ENTRY(type, name, descr, max) { type, name, descr, max }
#define CDROM(name, descr, max) \
DEVICE_ENTRY(DEVICE_TYPE_CDROM, name, descr, max)
#define TAPE(name, descr, max) \
DEVICE_ENTRY(DEVICE_TYPE_TAPE, name, descr, max)
#define DISK(name, descr, max) \
#define DISK(name, descr, max) \
DEVICE_ENTRY(DEVICE_TYPE_DISK, name, descr, max)
#define FLOPPY(name, descr, max) \
DEVICE_ENTRY(DEVICE_TYPE_FLOPPY, name, descr, max)
#define NETWORK(name, descr) \
DEVICE_ENTRY(DEVICE_TYPE_NETWORK, name, descr, 0)
#define SERIAL(name, descr, max) \
DEVICE_ENTRY(DEVICE_TYPE_NETWORK, name, descr, max)
static struct _devname {
DeviceType type;
@ -74,83 +57,18 @@ static struct _devname {
char *description;
int max;
} device_names[] = {
CDROM("cd%d", "SCSI CDROM drive", 4),
CDROM("mcd%d", "Mitsumi (old model) CDROM drive", 4),
CDROM("scd%d", "Sony CDROM drive - CDU31/33A type", 4),
CDROM("acd%d", "ATAPI/IDE CDROM", 4),
TAPE("sa%d", "SCSI tape drive", 4),
TAPE("rwt%d", "Wangtek tape drive", 4),
DISK("da%d", "SCSI disk device", 16),
DISK("ad%d", "ATA/IDE disk device", 16),
DISK("ar%d", "ATA/IDE RAID device", 16),
DISK("afd%d", "ATAPI/IDE floppy device", 4),
DISK("mlxd%d", "Mylex RAID disk", 4),
DISK("amrd%d", "AMI MegaRAID drive", 4),
DISK("idad%d", "Compaq RAID array", 4),
DISK("twed%d", "3ware ATA RAID array", 4),
DISK("aacd%d", "Adaptec FSA RAID array", 4),
DISK("ipsd%d", "IBM ServeRAID RAID array", 4),
DISK("mfid%d", "LSI MegaRAID SAS array", 4),
FLOPPY("fd%d", "floppy drive unit A", 4),
SERIAL("cuad%d", "%s on device %s (COM%d)", 16),
NETWORK("an", "Aironet 4500/4800 802.11 wireless adapter"),
NETWORK("aue", "ADMtek USB ethernet adapter"),
NETWORK("axe", "ASIX Electronics USB ethernet adapter"),
NETWORK("bfe", "Broadcom BCM440x PCI ethernet card"),
NETWORK("bge", "Broadcom BCM570x PCI gigabit ethernet card"),
NETWORK("cue", "CATC USB ethernet adapter"),
NETWORK("fpa", "DEC DEFPA PCI FDDI card"),
NETWORK("sr", "SDL T1/E1 sync serial PCI card"),
NETWORK("cc3i", "SDL HSSI sync serial PCI card"),
NETWORK("en", "Efficient Networks ATM PCI card"),
NETWORK("dc", "DEC/Intel 21143 (and clones) PCI fast ethernet card"),
NETWORK("de", "DEC DE435 PCI NIC or other DC21040-AA based card"),
NETWORK("fxp", "Intel EtherExpress Pro/100B PCI Fast Ethernet card"),
NETWORK("ed", "Novell NE1000/2000; 3C503; NE2000-compatible PCMCIA"),
NETWORK("ep", "3Com 3C509 ethernet card/3C589 PCMCIA"),
NETWORK("el", "3Com 3C501 ethernet card"),
NETWORK("em", "Intel(R) PRO/1000 ethernet card"),
NETWORK("ex", "Intel EtherExpress Pro/10 ethernet card"),
NETWORK("fe", "Fujitsu MB86960A/MB86965A ethernet card"),
NETWORK("gem", "Apple/Sun GMAC ethernet adapter"),
NETWORK("ie", "AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210"),
NETWORK("ix", "Intel Etherexpress ethernet card"),
NETWORK("kue", "Kawasaki LSI USB ethernet adapter"),
NETWORK("le", "DEC EtherWorks 2 or 3 ethernet card"),
NETWORK("lnc", "Lance/PCnet (Isolan/Novell NE2100/NE32-VL) ethernet"),
NETWORK("lge", "Level 1 LXT1001 gigabit ethernet card"),
NETWORK("nge", "NatSemi PCI gigabit ethernet card"),
NETWORK("pcn", "AMD Am79c79x PCI ethernet card"),
NETWORK("ray", "Raytheon Raylink 802.11 wireless adaptor"),
NETWORK("re", "RealTek 8139C+/8169/8169S/8110S PCI ethernet card"),
NETWORK("rl", "RealTek 8129/8139 PCI ethernet card"),
NETWORK("rue", "RealTek USB ethernet card"),
NETWORK("sf", "Adaptec AIC-6915 PCI ethernet card"),
NETWORK("sis", "SiS 900/SiS 7016 PCI ethernet card"),
#ifdef PC98
NETWORK("snc", "SONIC ethernet card"),
#endif
NETWORK("sn", "SMC/Megahertz ethernet card"),
NETWORK("ste", "Sundance ST201 PCI ethernet card"),
NETWORK("sk", "SysKonnect PCI gigabit ethernet card"),
NETWORK("tx", "SMC 9432TX ethernet card"),
NETWORK("txp", "3Com 3cR990 ethernet card"),
NETWORK("ti", "Alteon Networks PCI gigabit ethernet card"),
NETWORK("tl", "Texas Instruments ThunderLAN PCI ethernet card"),
NETWORK("vge", "VIA VT612x PCI gigabit ethernet card"),
NETWORK("vr", "VIA VT3043/VT86C100A Rhine PCI ethernet card"),
NETWORK("vlan", "IEEE 802.1Q VLAN network interface"),
NETWORK("vx", "3COM 3c590 / 3c595 ethernet card"),
NETWORK("wb", "Winbond W89C840F PCI ethernet card"),
NETWORK("wi", "Lucent WaveLAN/IEEE 802.11 wireless adapter"),
NETWORK("wx", "Intel Gigabit Ethernet (82452) card"),
NETWORK("xe", "Xircom/Intel EtherExpress Pro100/16 ethernet card"),
NETWORK("xl", "3COM 3c90x / 3c90xB PCI ethernet card"),
NETWORK("fwe", "FireWire Ethernet emulation"),
NETWORK("plip", "Parallel Port IP (PLIP) peer connection"),
NETWORK("lo", "Loop-back (local) network interface"),
NETWORK("disc", "Software discard network interface"),
{ 0, NULL, NULL, 0 }
DISK("da%d", "SCSI disk device", 16),
DISK("ad%d", "ATA/IDE disk device", 16),
DISK("ar%d", "ATA/IDE RAID device", 16),
DISK("afd%d", "ATAPI/IDE floppy device", 4),
DISK("mlxd%d", "Mylex RAID disk", 4),
DISK("amrd%d", "AMI MegaRAID drive", 4),
DISK("idad%d", "Compaq RAID array", 4),
DISK("twed%d", "3ware ATA RAID array", 4),
DISK("aacd%d", "Adaptec FSA RAID array", 4),
DISK("ipsd%d", "IBM ServeRAID RAID array", 4),
DISK("mfid%d", "LSI MegaRAID SAS array", 4),
{ 0, NULL, NULL, 0 },
};
Device *
@ -189,6 +107,9 @@ deviceTry(struct _devname dev, char *try, int i)
{
int fd;
char unit[80];
mode_t m;
dev_t d;
int fail;
snprintf(unit, sizeof unit, dev.name, i);
snprintf(try, FILENAME_MAX, "/dev/%s", unit);
@ -197,10 +118,7 @@ deviceTry(struct _devname dev, char *try, int i)
fd = open(try, O_RDONLY);
if (fd >= 0) {
if (isDebug())
msgDebug("deviceTry: open of %s succeeded on first try.\n", try);
} else {
if (isDebug())
msgDebug("deviceTry: open of %s failed.\n", try);
msgDebug("deviceTry: open of %s succeeded.\n", try);
}
return fd;
}
@ -255,75 +173,10 @@ void
deviceGetAll(void)
{
int i, j, fd, s;
struct ifconf ifc;
struct ifreq *ifptr, *end;
int ifflags;
char buffer[INTERFACE_MAX * sizeof(struct ifreq)];
char **names;
msgNotify("Probing devices, please wait (this can take a while)...");
/* First go for the network interfaces. Stolen shamelessly from ifconfig! */
ifc.ifc_len = sizeof(buffer);
ifc.ifc_buf = buffer;
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
goto skipif; /* Jump over network iface probing */
if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0)
goto skipif; /* Jump over network iface probing */
close(s);
ifflags = ifc.ifc_req->ifr_flags;
end = (struct ifreq *) (ifc.ifc_buf + ifc.ifc_len);
for (ifptr = ifc.ifc_req; ifptr < end; ifptr++) {
char *descr;
/* If it's not a link entry, forget it */
if (ifptr->ifr_ifru.ifru_addr.sa_family != AF_LINK)
goto loopend;
/* Eliminate network devices that don't make sense */
if (!strncmp(ifptr->ifr_name, "lo", 2))
goto loopend;
/* If we have a slip device, don't register it */
if (!strncmp(ifptr->ifr_name, "sl", 2)) {
goto loopend;
}
/* And the same for ppp */
if (!strncmp(ifptr->ifr_name, "tun", 3) || !strncmp(ifptr->ifr_name, "ppp", 3)) {
goto loopend;
}
/* Try and find its description */
for (i = 0, descr = NULL; device_names[i].name; i++) {
int len = strlen(device_names[i].name);
if (!ifptr->ifr_name || !ifptr->ifr_name[0])
continue;
else if (!strncmp(ifptr->ifr_name, device_names[i].name, len)) {
descr = device_names[i].description;
break;
}
}
if (!descr)
descr = "<unknown network interface type>";
deviceRegister(ifptr->ifr_name, descr, strdup(ifptr->ifr_name), DEVICE_TYPE_NETWORK, TRUE,
mediaInitNetwork, NULL, mediaShutdownNetwork, NULL);
if (isDebug())
msgDebug("Found a network device named %s\n", ifptr->ifr_name);
close(s);
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
continue;
loopend:
if (ifptr->ifr_addr.sa_len) /* I'm not sure why this is here - it's inherited */
ifptr = (struct ifreq *)((caddr_t)ifptr + ifptr->ifr_addr.sa_len - sizeof(struct sockaddr));
close(s);
}
skipif:
/* Next, try to find all the types of devices one might need
* during the second stage of the installation.
*/
@ -332,75 +185,8 @@ deviceGetAll(void)
char try[FILENAME_MAX];
switch(device_names[i].type) {
case DEVICE_TYPE_CDROM:
fd = deviceTry(device_names[i], try, j);
if (fd >= 0 || errno == EBUSY) { /* EBUSY if already mounted */
char n[BUFSIZ];
if (fd >= 0) close(fd);
snprintf(n, sizeof n, device_names[i].name, j);
deviceRegister(strdup(n), device_names[i].description, strdup(try),
DEVICE_TYPE_CDROM, TRUE, mediaInitCDROM, mediaGetCDROM,
mediaShutdownCDROM, NULL);
if (isDebug())
msgDebug("Found a CDROM device for %s\n", try);
}
break;
case DEVICE_TYPE_TAPE:
fd = deviceTry(device_names[i], try, j);
if (fd >= 0) {
char n[BUFSIZ];
close(fd);
snprintf(n, sizeof n, device_names[i].name, j);
deviceRegister(strdup(n), device_names[i].description, strdup(try),
DEVICE_TYPE_TAPE, TRUE, mediaInitTape, mediaGetTape, mediaShutdownTape, NULL);
if (isDebug())
msgDebug("Found a TAPE device for %s\n", try);
}
break;
case DEVICE_TYPE_DISK:
/* nothing to do */
break;
case DEVICE_TYPE_FLOPPY:
fd = deviceTry(device_names[i], try, j);
if (fd >= 0) {
char n[BUFSIZ];
close(fd);
snprintf(n, sizeof n, device_names[i].name, j);
deviceRegister(strdup(n), device_names[i].description, strdup(try),
DEVICE_TYPE_FLOPPY, TRUE, mediaInitFloppy, mediaGetFloppy,
mediaShutdownFloppy, NULL);
if (isDebug())
msgDebug("Found a floppy device for %s\n", try);
}
break;
case DEVICE_TYPE_NETWORK:
fd = deviceTry(device_names[i], try, j);
/* The only network devices that you can open this way are serial ones */
if (fd >= 0) {
char *newdesc, *cp;
close(fd);
cp = device_names[i].description;
/* Serial devices get a slip and ppp device each, if supported */
newdesc = safe_malloc(strlen(cp) + 40);
sprintf(newdesc, cp, "SLIP interface", try, j + 1);
deviceRegister("sl0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
NULL, mediaShutdownNetwork, NULL);
msgDebug("Add mapping for %s to sl0\n", try);
newdesc = safe_malloc(strlen(cp) + 50);
sprintf(newdesc, cp, "PPP interface", try, j + 1);
deviceRegister("ppp0", newdesc, strdup(try), DEVICE_TYPE_NETWORK, TRUE, mediaInitNetwork,
NULL, mediaShutdownNetwork, NULL);
if (isDebug())
msgDebug("Add mapping for %s to ppp0\n", try);
}
break;
default:
@ -446,6 +232,7 @@ deviceGetAll(void)
if (isDebug())
msgDebug("Found a disk device named %s\n", names[i]);
#if 0
/* Look for existing DOS partitions to register as "DOS media devices" */
for (c1 = d->chunks->part; c1; c1 = c1->next) {
if (c1->type == fat || c1->type == efi || c1->type == extended) {
@ -455,12 +242,13 @@ deviceGetAll(void)
/* Got one! */
snprintf(devname, sizeof devname, "/dev/%s", c1->name);
dev = deviceRegister(c1->name, c1->name, strdup(devname), DEVICE_TYPE_DOS, TRUE,
mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
mediaInitDOS, mediaGetDOS, mediaShutdownDOS, NULL);
dev->private = c1;
if (isDebug())
msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
}
}
#endif
}
free(names);
}

View File

@ -1,9 +1,4 @@
/*
* 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
@ -34,7 +29,7 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
#include <ctype.h>
#include <fcntl.h>
#include <inttypes.h>
@ -136,6 +131,8 @@ print_chunks(Disk *d, int u)
"using. Do NOT use a ``physical geometry''.",
d->bios_cyl, d->bios_hd, d->bios_sect, d->name);
Sanitize_Bios_Geom(d);
msgDebug("Sanitized geometry for %s is %lu/%lu/%lu.\n",
d->name, d->bios_cyl, d->bios_hd, d->bios_sect);
}
attrset(A_NORMAL);
mvaddstr(0, 0, "Disk name:\t");
@ -186,8 +183,7 @@ print_command_summary(void)
mvprintw(16, 0, "A = Use Entire Disk G = set Drive Geometry C = Create Slice F = `DD' mode");
mvprintw(17, 0, "D = Delete Slice Z = Toggle Size Units S = Set Bootable | = Wizard m.");
mvprintw(18, 0, "T = Change Type U = Undo All Changes Q = Finish");
if (!RunningAsInit)
mvprintw(18, 47, "W = Write Changes");
mvprintw(18, 47, "W = Write Changes");
mvprintw(21, 0, "Use F1 or ? to get more help, arrow keys to select.");
move(0, 0);
}

View File

@ -1,9 +1,4 @@
/*
* 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
@ -34,7 +29,7 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
#include <ctype.h>
#include <errno.h>
#include <sys/signal.h>
@ -42,80 +37,22 @@
#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 },
};
@ -166,19 +103,11 @@ dispatch_add_command(qelement *head, char *string)
return new;
}
/*
* Command processing
*/
/* Just convenience */
static int
dispatch_shutdown(dialogMenuItem *unused)
{
systemShutdown(0);
return DITEM_FAILURE;
}
static int
dispatch_systemExecute(dialogMenuItem *unused)
{
@ -205,19 +134,6 @@ dispatch_msgConfirm(dialogMenuItem *unused)
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)
{
@ -350,99 +266,3 @@ dispatch_execute(qelement *head)
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;
}

View File

@ -1,9 +1,4 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $FreeBSD$
*
* Copyright (c) 1995
@ -34,8 +29,7 @@
*
*/
#include "sysinstall.h"
#include <sys/param.h>
#include "sade.h"
#include <errno.h>
#define MAX_MENU 15
@ -111,21 +105,6 @@ dmenuSetVariables(dialogMenuItem *tmp)
return DITEM_SUCCESS;
}
int
dmenuSetCountryVariable(dialogMenuItem *tmp)
{
variable_set((char *)tmp->data, FALSE);
#ifdef WITH_SYSCONS
/* Don't prompt the user for a keymap if they're using the default locale. */
if (!strcmp(variable_get(VAR_COUNTRY), DEFAULT_COUNTRY))
return DITEM_SUCCESS;
return keymapMenuSelect(tmp);
#else
return DITEM_SUCCESS;
#endif
}
int
dmenuSetKmapVariable(dialogMenuItem *tmp)
{
@ -261,7 +240,7 @@ dmenuVarsCheck(dialogMenuItem *item)
int
dmenuRadioCheck(dialogMenuItem *item)
{
return (*((int *)item->data) == item->aux);
return (*((unsigned int *)item->data) == item->aux);
}
static int
@ -280,60 +259,6 @@ menu_height(DMenu *menu, int n)
return n > max ? max : n;
}
/* Find a menu item that matches any field. */
int
dmenuFindItem(DMenu *menu, const char *prompt, const char *title, void *data)
{
dialogMenuItem *items = menu->items;
int i;
for (i = 0; items[i].prompt; ++i)
if ((prompt && !strcmp(items[i].prompt, prompt)) ||
(title && !strcmp(items[i].title, title)) ||
(data && items[i].data == data))
return i;
return -1;
}
/* Set the default item for a menu by index and scroll to it. */
void
dmenuSetDefaultIndex(DMenu *menu, int *choice, int *scroll, int *curr, int *max)
{
int nitem;
int height;
*curr = *max = 0;
for (nitem = 0; menu->items[nitem].prompt; ++nitem);
height = menu_height(menu, nitem);
if (*choice > height)
{
*scroll = MIN(nitem - height, *choice);
*choice = *choice - *scroll;
}
else
*scroll = 0;
}
/* Set the default menu item that matches any field and scroll to it. */
Boolean
dmenuSetDefaultItem(DMenu *menu, const char *prompt, const char *title, void *data,
int *choice, int *scroll, int *curr, int *max)
{
if ((*choice = dmenuFindItem(menu, prompt, title, data)) != -1)
{
dmenuSetDefaultIndex(menu, choice, scroll, curr, max);
return TRUE;
}
else
{
*choice = *scroll = *curr = *max = 0;
return FALSE;
}
}
/* Traverse over an internal menu */
Boolean
dmenuOpen(DMenu *menu, int *choice, int *scroll, int *curr, int *max, Boolean buttons)

View File

@ -1,9 +1,4 @@
/*
* 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
@ -34,7 +29,7 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
/*
* Various global variables and an initialization hook to set them to
@ -43,13 +38,11 @@
int DebugFD; /* Where diagnostic output goes */
Boolean Fake; /* Only pretend to be useful */
Boolean RunningAsInit; /* Are we running as init? */
Boolean DialogActive; /* Is libdialog initialized? */
Boolean ColorDisplay; /* Are we on a color display? */
Boolean OnVTY; /* Are we on a VTY? */
Boolean Restarting; /* Are we restarting sysinstall? */
Variable *VarHead; /* The head of the variable chain */
Device *mediaDevice; /* Where we're installing from */
int BootMgr; /* Which boot manager we're using */
int StatusLine; /* Where to stick our status messages */
jmp_buf BailOut; /* Beam me up, scotty! The natives are pissed! */
@ -78,8 +71,6 @@ globalsInit(void)
OnVTY = FALSE;
DialogActive = FALSE;
VarHead = NULL;
mediaDevice = NULL;
RunningAsInit = FALSE;
HomeChunk = NULL;
RootChunk = NULL;

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@ -50,79 +50,6 @@ struct keymapInfo {
* the language name only.
*/
#ifdef WITH_SYSCONS
static int
keymapSetDefault(const char *prefix)
{
dialogMenuItem *items = MenuSysconsKeymap.items;
int i;
size_t plen = strlen(prefix);
for (i = 0; items[i].data; ++i)
if (!strncmp(prefix, items[i].data, plen))
return i;
return -1;
}
int
keymapMenuSelect(dialogMenuItem *self)
{
static const struct {
const char *country, *lang;
} map[] = {
{"dk", "danish"},
{"ee", "estonian"},
{"fi", "finnish"},
{"de", "german"},
{"is", "icelandic"},
{"no", "norwegian"},
{"pl", "pl_PL"},
{"es", "spanish"},
{"se", "swedish"},
{"ch", "swiss"},
{"gb", "uk"},
{NULL, NULL}
};
const char *country, *lang;
int i;
int choice, scroll, curr, max;
char prefix[16 + 1];
if ((country = variable_get(VAR_COUNTRY)) != NULL)
{
lang = country;
for (i = 0; map[i].country; ++i)
if (!strcmp(country, map[i].country))
{
lang = map[i].lang;
break;
}
snprintf(prefix, sizeof(prefix), "keymap=%s.iso", lang);
if ((choice = keymapSetDefault(prefix)) == -1)
{
snprintf(prefix, sizeof(prefix), "keymap=%s", lang);
if ((choice = keymapSetDefault(prefix)) == -1) {
#ifdef PC98
snprintf(prefix, sizeof(prefix), "keymap=jp.pc98");
#else
snprintf(prefix, sizeof(prefix), "keymap=us.iso");
#endif
if ((choice = keymapSetDefault(prefix)) == -1)
choice = 0;
}
}
dmenuSetDefaultIndex(&MenuSysconsKeymap, &choice, &scroll, &curr, &max);
return dmenuOpen(&MenuSysconsKeymap, &choice, &scroll, &curr, &max, FALSE);
}
else
return dmenuOpenSimple(&MenuSysconsKeymap, FALSE) ? DITEM_SUCCESS :
DITEM_FAILURE;
}
#endif
/*
* Return values:
*

View File

@ -1,9 +1,4 @@
/*
* 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
@ -34,7 +29,7 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
#include <ctype.h>
#include <inttypes.h>
#include <libdisk.h>
@ -826,8 +821,7 @@ print_command_summary(void)
{
mvprintw(17, 0, "The following commands are valid here (upper or lower case):");
mvprintw(18, 0, "C = Create D = Delete M = Mount pt.");
if (!RunningAsInit)
mvprintw(18, 56, "W = Write");
mvprintw(18, 56, "W = Write");
mvprintw(19, 0, "N = Newfs Opts Q = Finish S = Toggle SoftUpdates Z = Custom Newfs");
mvprintw(20, 0, "T = Toggle Newfs U = Undo A = Auto Defaults R = Delete+Merge");
mvprintw(22, 0, "Use F1 or ? to get more help, arrow keys to select.");
@ -837,6 +831,7 @@ print_command_summary(void)
static void
clear_wins(void)
{
extern void print_label_chunks();
clear();
print_label_chunks();
}

View File

@ -1,9 +1,4 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $FreeBSD$
*
* Copyright (c) 1997 FreeBSD, Inc.

View File

@ -1,13 +1,8 @@
/*
* The new sysinstall program.
*
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated for what's essentially a complete rewrite.
*
* $FreeBSD$
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
* Jordan Hubbard. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -34,7 +29,7 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
#include <sys/signal.h>
#include <sys/fcntl.h>
@ -55,11 +50,6 @@ main(int argc, char **argv)
/* Record name to be able to restart */
StartName = argv[0];
/* Catch fatal signals and complain about them if running as init */
if (getpid() == 1) {
signal(SIGBUS, screech);
signal(SIGSEGV, screech);
}
signal(SIGPIPE, SIG_IGN);
/* We don't work too well when running as non-root anymore */
@ -82,9 +72,6 @@ main(int argc, char **argv)
/* Set default flag and variable values */
installVarDefaults(NULL);
/* only when multi-user is it reasonable to do this here */
if (!RunningAsInit)
installEnvironment();
if (argc > 1 && !strcmp(argv[1], "-fake")) {
variable_set2(VAR_DEBUG, "YES", 0);
@ -106,48 +93,13 @@ main(int argc, char **argv)
/* Initialize driver modules, if we haven't already done so (ie,
the user hit Ctrl-C -> Restart. */
if (!pvariable_get("modulesInitialize")) {
moduleInitialize();
pvariable_set("modulesInitialize=1");
}
/* Initialize PC Card, if we haven't already done so. */
#ifdef PCCARD_ARCH
if (!variable_cmp(VAR_SKIP_PCCARD, "YES") &&
variable_get(VAR_SKIP_PCCARD)!=1 &&
!pvariable_get("pccardInitialize")) {
pccardInitialize();
pvariable_set("pccardInitialize=1");
}
#endif
/* Probe for all relevant devices on the system */
deviceGetAll();
/* Prompt for the driver floppy if appropriate. */
if (!pvariable_get("driverFloppyCheck")) {
driverFloppyCheck();
pvariable_set("driverFloppyCheck=1");
}
/* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */
if (!RunningAsInit) {
int i, start_arg;
if (!strstr(argv[0], "sysinstall"))
start_arg = 0;
else if (Fake || Restarting)
start_arg = 2;
else
start_arg = 1;
for (i = start_arg; i < argc; i++) {
if (DITEM_STATUS(dispatchCommand(argv[i])) != DITEM_SUCCESS)
systemShutdown(1);
}
if (argc > start_arg)
systemShutdown(0);
}
else
dispatch_load_file_int(TRUE);
status = setjmp(BailOut);
if (status) {
@ -155,31 +107,19 @@ main(int argc, char **argv)
"down. If you can reproduce the problem, please turn Debug on\n"
"in the Options menu for the extra information it provides\n"
"in debugging problems like this.", status);
systemShutdown(status);
;
}
/* Get user's country and keymap */
if (RunningAsInit)
configCountry(NULL);
/* Begin user dialog at outer menu */
dialog_clear();
while (1) {
choice = scroll = curr = max = 0;
dmenuOpen(&MenuInitial, &choice, &scroll, &curr, &max, TRUE);
dmenuOpen(&MenuMain, &choice, &scroll, &curr, &max, FALSE);
if (getpid() != 1
#if defined(__alpha__) || defined(__sparc64__)
|| !msgNoYes("Are you sure you wish to exit? The system will halt.")
#else
|| !msgNoYes("Are you sure you wish to exit? The system will reboot\n"
"(be sure to remove any floppies/CDs/DVDs from the drives).")
#endif
|| !msgNoYes("Are you sure you wish to exit?")
)
break;
}
/* Say goodnight, Gracie */
systemShutdown(0);
return 0; /* We should never get here */
}

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
#include <ctype.h>
#include <unistd.h>
#include <sys/stat.h>
@ -327,8 +327,8 @@ Mount(char *mountp, void *dev)
return DITEM_SUCCESS;
if (*((char *)dev) != '/') {
sprintf(device, "%s/dev/%s", RunningAsInit ? "/mnt" : "", (char *)dev);
sprintf(mountpoint, "%s%s", RunningAsInit ? "/mnt" : "", mountp);
sprintf(device, "/dev/%s", (char *)dev);
sprintf(mountpoint, "%s", mountp);
}
else {
strcpy(device, dev);
@ -344,7 +344,7 @@ Mount(char *mountp, void *dev)
msgDebug("mount %s %s\n", device, mountpoint);
ufsargs.fspec = device;
if (mount("ufs", mountpoint, RunningAsInit ? MNT_ASYNC | MNT_NOATIME : 0,
if (mount("ufs", mountpoint, 0,
(caddr_t)&ufsargs) == -1) {
msgConfirm("Error mounting %s on %s : %s", device, mountpoint, strerror(errno));
return DITEM_FAILURE;
@ -352,6 +352,7 @@ Mount(char *mountp, void *dev)
return DITEM_SUCCESS;
}
#if 0
int
Mount_msdosfs(char *mountp, void *dev)
{
@ -363,8 +364,8 @@ Mount_msdosfs(char *mountp, void *dev)
return DITEM_SUCCESS;
if (*((char *)dev) != '/') {
sprintf(device, "%s/dev/%s", RunningAsInit ? "/mnt" : "", (char *)dev);
sprintf(mountpoint, "%s%s", RunningAsInit ? "/mnt" : "", mountp);
sprintf(device, "/dev/%s", (char *)dev);
sprintf(mountpoint, "%s", mountp);
}
else {
strcpy(device, dev);
@ -382,13 +383,14 @@ Mount_msdosfs(char *mountp, void *dev)
mount_args.fspec = device;
mount_args.magic = MSDOSFS_ARGSMAGIC;
mount_args.mask = S_IRWXU | S_IRWXG | S_IRWXO;
if (mount("msdosfs", mountpoint, RunningAsInit ? MNT_ASYNC|MNT_NOATIME : 0,
if (mount("msdosfs", mountpoint, 0,
(caddr_t)&mount_args) == -1) {
msgConfirm("Error mounting %s on %s : %s", device, mountpoint, strerror(errno));
return DITEM_FAILURE;
}
return DITEM_SUCCESS;
}
#endif
WINDOW *
openLayoutDialog(char *helpfile, char *title, int x, int y, int width, int height)

View File

@ -1,9 +1,4 @@
/*
* 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
@ -34,7 +29,7 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
#include <stdarg.h>
#include <sys/ioctl.h>
#include <sys/consio.h>
@ -175,7 +170,6 @@ msgFatal(char *fmt, ...)
if (OnVTY)
msgDebug("Fatal error `%s'!\n", errstr);
getch();
systemShutdown(1);
}
/* Put up a message in a popup confirmation box */

View File

@ -24,913 +24,44 @@
.\"
.\" $FreeBSD$
.\"
.Dd July 17, 2005
.Dt SYSINSTALL 8
.Dd August 08, 2006
.Dt SADE 8
.Os
.Sh NAME
.Nm sysinstall
.Nd system installation and configuration tool
.Nm sade
.Nd sysadmins disk editor
.Sh SYNOPSIS
.Nm
.Op Ar var=value
.Op Ar function
.Op Ar ...
.Sh DESCRIPTION
The
.Nm
utility is used for installing and configuring
utility is used for various disk administration tasks on
.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.
It is generally invoked without arguments for the default
behavior, where the main menu is presented.
.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.
utility aims to provide a handy tool for disk management
tasks on an already installed system. The goal is to save
some of the useful functionality of the old sysinstall, which
will be removed from the system in favour of the new installer.
.\".Sh FILES
.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.
sysinstall(8)
.Sh HISTORY
This version of
.Nm
first appeared in
.Fx 2.0 .
.Fx 7.0 . The code is extracted from the
sysinstall
utility.
.Sh AUTHORS
.An Jordan K. Hubbard Aq jkh@FreeBSD.org
.Sh BUGS
Editing slice and partition tables on disks which are currently mounted by
the system is not allowed.
This is generally only a problem when
.Nm
is run on a system that is already installed.
Use
.Xr fdisk 8
and
.Xr bsdlabel 8
for these tasks.
.Pp
This utility is a prototype which lasted several years past
its expiration date and is greatly in need of death.
The utility misses a lot of nice features, such as tools for
manipulating gmirror or gvinum stuff. These will be added
later.

View File

@ -1,9 +1,4 @@
/*
* 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.
*
@ -33,8 +28,8 @@
* $FreeBSD$
*/
#ifndef _SYSINSTALL_H_INCLUDE
#define _SYSINSTALL_H_INCLUDE
#ifndef _SADE_H_INCLUDE
#define _SADE_H_INCLUDE
#include <sys/types.h>
#include <sys/wait.h>
@ -48,11 +43,10 @@
#include "ui_objects.h"
#include "dir.h"
#include "colors.h"
#include "dist.h"
/*** Defines ***/
#if defined(__i386__) || defined(__alpha__) || defined(__amd64__)
#if defined(__i386__) || defined(__amd64__)
#define WITH_SYSCONS
#define WITH_MICE
#endif
@ -68,12 +62,8 @@
/* 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
@ -90,122 +80,42 @@
#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_COUNTRY "country"
#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_DIST_KERNEL "distKernel"
#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_NCPUS "ncpus"
#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"
#ifdef PC98
#define DEFAULT_COUNTRY "jp"
#else
#define DEFAULT_COUNTRY "us"
#endif
#define DEFAULT_TAPE_BLOCKSIZE "20"
/* One MB worth of blocks */
@ -270,30 +180,15 @@ typedef struct _layout {
void *obj; /* The obj pointer returned by libdialog */
} Layout;
/* Layout array terminator. */
#define LAYOUT_END { 0, 0, 0, 0, NULL, NULL, NULL, 0, NULL }
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 */
/* A "device" from sade's point of view */
typedef struct _device {
char name[DEV_NAME_MAX];
char *description;
@ -360,56 +255,15 @@ typedef struct _opt {
enum { OPT_IS_STRING, OPT_IS_INT, OPT_IS_FUNC, OPT_IS_VAR } type;
void *data;
void *aux;
char *(*check)(struct _opt *);
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? */
@ -419,16 +273,8 @@ 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 unsigned int KernelDists; /* Which kernel dists we want */
extern int BootMgr; /* Which boot manager to use */
extern int StatusLine; /* Where to print our status messages */
extern DMenu MenuCountry; /* Country menu */
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 */
@ -436,57 +282,9 @@ extern DMenu MenuIPLType; /* Type of IPL to write on the disk */
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 MenuKernelDistributions;/* Kernel 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 DMenu MenuMain; /* New main menu */
extern DMenu MenuDiskDevices; /* Disk type devices */
extern const char * StartName; /* Which name we were started as */
extern int NCpus; /* # cpus on machine */
/* Important chunks. */
extern Chunk *HomeChunk;
@ -505,17 +303,6 @@ extern void display_helpline(WINDOW *w, int y, int width);
/*** Prototypes ***/
/* acpi.c */
extern int acpi_detect(void);
/* 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);
@ -525,41 +312,10 @@ 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 configCountry(dialogMenuItem *self);
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),
@ -580,10 +336,6 @@ 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);
@ -598,25 +350,6 @@ 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 distSetKernel(dialogMenuItem *self);
extern int distExtractAll(dialogMenuItem *self);
/* dmenu.c */
extern int dmenuDisplayFile(dialogMenuItem *tmp);
extern int dmenuSubmenu(dialogMenuItem *tmp);
@ -625,16 +358,11 @@ extern int dmenuSystemCommandBox(dialogMenuItem *tmp);
extern int dmenuExit(dialogMenuItem *tmp);
extern int dmenuISetVariable(dialogMenuItem *tmp);
extern int dmenuSetVariable(dialogMenuItem *tmp);
extern int dmenuSetCountryVariable(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 int dmenuFindItem(DMenu *menu, const char *prompt, const char *title, void *data);
extern void dmenuSetDefaultIndex(DMenu *menu, int *choice, int *scroll, int *curr, int *max);
extern int dmenuSetDefaultItem(DMenu *menu, const char *prompt, const char *title, void *data,
int *choice, int *scroll, int *curr, int *max);
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);
@ -642,58 +370,19 @@ 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);
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);
/* 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 installFixupKernel(dialogMenuItem *self, int dists);
extern int installUpgrade(dialogMenuItem *self);
extern int installFilesystems(dialogMenuItem *self);
extern int installVarDefaults(dialogMenuItem *self);
extern void installEnvironment(void);
@ -703,7 +392,6 @@ extern Boolean copySelf(void);
extern int kget(char *out);
/* keymap.c */
extern int keymapMenuSelect(dialogMenuItem *self);
extern int loadKeymap(const char *lang);
/* label.c */
@ -727,30 +415,6 @@ 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);
@ -785,19 +449,6 @@ 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);
/* mptable.c */
extern int biosmptable_detect(void);
/* msg.c */
extern Boolean isDebug(void);
extern void msgInfo(char *fmt, ...) __printf0like(1, 2);
@ -815,24 +466,6 @@ 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);
@ -849,35 +482,11 @@ 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);

View File

@ -1,22 +1,17 @@
/*
* The new sysinstall program.
*
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
* $FreeBSD$
*
* Jordan Hubbard
*
* My contributions are in the public domain.
*
* Parts of this file are also blatantly stolen from Poul-Henning Kamp's
* Parts of this file are also blatently stolen from Poul-Henning Kamp's
* previous version of sysinstall, and as such fall under his "BEERWARE license"
* so buy him a beer if you like it! Buy him a beer for me, too!
* Heck, get him completely drunk and send me pictures! :-)
*/
#include "sysinstall.h"
#include "sade.h"
#include <signal.h>
#include <termios.h>
#include <sys/param.h>
@ -47,20 +42,11 @@ intr_continue(dialogMenuItem *self)
return DITEM_LEAVE_MENU;
}
static int
intr_reboot(dialogMenuItem *self)
{
systemShutdown(-1);
/* NOTREACHED */
return 0;
}
static int
intr_restart(dialogMenuItem *self)
{
int ret, fd, fdmax;
mediaClose();
free_variables();
fdmax = getdtablesize();
for (fd = 3; fd < fdmax; fd++)
@ -72,9 +58,8 @@ intr_restart(dialogMenuItem *self)
}
static dialogMenuItem intrmenu[] = {
{ "Abort", "Abort the installation", NULL, intr_reboot },
{ "Restart", "Restart the installation program", NULL, intr_restart },
{ "Continue", "Continue the installation", NULL, intr_continue },
{ "Restart", "Restart the program", NULL, intr_restart },
{ "Continue", "Continue without restarting", NULL, intr_continue },
};
@ -91,30 +76,15 @@ handle_intr(int sig)
}
(void)dialog_menu("Installation interrupt",
"Do you want to abort the installation?",
-1, -1, 3, -3, intrmenu, NULL, NULL, NULL);
-1, -1, 2, -2, intrmenu, NULL, NULL, NULL);
restorescr(save);
}
#if 0
/*
* Harvest children if we are init.
*/
static void
reap_children(int sig)
{
int errbak = errno;
while (waitpid(-1, NULL, WNOHANG) > 0)
;
errno = errbak;
}
#endif
/* Expand a file into a convenient location, nuking it each time */
static char *
expand(char *fname)
{
char *gunzip = RunningAsInit ? "/stand/gunzip" : "/usr/bin/gunzip";
char *gunzip = "/usr/bin/gunzip";
if (!directory_exists(DOC_TMP_DIR)) {
Mkdir(DOC_TMP_DIR);
@ -146,67 +116,8 @@ systemInitialize(int argc, char **argv)
(i == sizeof(boothowto)) && (boothowto & RB_VERBOSE))
variable_set2(VAR_DEBUG, "YES", 0);
/* Are we running as init? */
if (getpid() == 1) {
struct ufs_args ufs_args;
int fd;
RunningAsInit = 1;
setsid();
close(0);
fd = open("/dev/ttyv0", O_RDWR);
if (fd == -1) {
fd = open("/dev/console", O_RDWR); /* fallback */
variable_set2(VAR_FIXIT_TTY, "serial", 0); /* give fixit a hint */
} else
OnVTY = TRUE;
/*
* To make _sure_ we're on a VTY and don't have /dev/console switched
* away to a serial port or something, attempt to set the cursor appearance.
*/
if (OnVTY) {
int fd2, type;
type = 0; /* normal */
if ((fd2 = open("/dev/console", O_RDWR)) != -1) {
if (ioctl(fd2, CONS_CURSORTYPE, &type) == -1) {
OnVTY = FALSE;
variable_set2(VAR_FIXIT_TTY, "serial", 0); /* Tell Fixit
the console
type */
close(fd); close(fd2);
open("/dev/console", O_RDWR);
}
else
close(fd2);
}
}
close(1); dup(0);
close(2); dup(0);
printf("%s running as init on %s\n", argv[0], OnVTY ? "vty0" : "serial console");
ioctl(0, TIOCSCTTY, (char *)NULL);
setlogin("root");
setenv("PATH", "/stand:/bin:/sbin:/usr/sbin:/usr/bin:/mnt/bin:/mnt/sbin:/mnt/usr/sbin:/mnt/usr/bin:/usr/X11R6/bin", 1);
setbuf(stdin, 0);
setbuf(stderr, 0);
#ifdef __alpha__
i = 0;
sysctlbyname("machdep.unaligned_print", NULL, 0, &i, sizeof(i));
#endif
#if 0
signal(SIGCHLD, reap_children);
#endif
memset(&ufs_args, 0, sizeof(ufs_args));
mount("ufs", "/", MNT_UPDATE, &ufs_args);
}
else {
char hname[256];
/* Initalize various things for a multi-user environment */
if (!gethostname(hname, sizeof hname))
variable_set2(VAR_HOSTNAME, hname, 0);
}
if (set_termcap() == -1) {
printf("Can't find terminal entry\n");
exit(-1);
@ -219,8 +130,6 @@ systemInitialize(int argc, char **argv)
DialogActive = TRUE;
/* Make sure HOME is set for those utilities that need it */
if (!getenv("HOME"))
setenv("HOME", "/", 1);
signal(SIGINT, handle_intr);
/*
* Make sure we can be interrupted even if we were re-executed
@ -233,43 +142,6 @@ systemInitialize(int argc, char **argv)
(void)vsystem("rm -rf %s", DOC_TMP_DIR);
}
/* Close down and prepare to exit */
void
systemShutdown(int status)
{
/* If some media is open, close it down */
if (status >=0)
mediaClose();
/* write out any changes to rc.conf .. */
configRC_conf();
/* Shut down the dialog library */
if (DialogActive) {
end_dialog();
DialogActive = FALSE;
}
/* Shut down curses */
endwin();
/* If we have a temporary doc dir lying around, nuke it */
(void)vsystem("rm -rf %s", DOC_TMP_DIR);
/* REALLY exit! */
if (RunningAsInit) {
/* Put the console back */
ioctl(0, VT_ACTIVATE, 2);
#if defined(__alpha__) || defined(__sparc64__)
reboot(RB_HALT);
#else
reboot(0);
#endif
}
else
exit(status);
}
/* Run some general command */
int
systemExecute(char *command)
@ -328,6 +200,7 @@ systemDisplayHelp(char *file)
int ret = 0;
WINDOW *w = savescr();
printf("zzz");
fname = systemHelpFile(file, buf);
if (!fname) {
snprintf(buf, FILENAME_MAX, "The %s file is not provided on this particular floppy image.", file);
@ -364,10 +237,10 @@ systemHelpFile(char *file, char *buf)
snprintf(buf, FILENAME_MAX, "/stand/help/%s.TXT", file);
if (file_readable(buf))
return expand(buf);
snprintf(buf, FILENAME_MAX, "/usr/src/usr.sbin/sysinstall/help/%s.hlp", file);
snprintf(buf, FILENAME_MAX, "/usr/src/usr.sbin/sade/help/%s.hlp", file);
if (file_readable(buf))
return buf;
snprintf(buf, FILENAME_MAX, "/usr/src/usr.sbin/sysinstall/help/%s.TXT", file);
snprintf(buf, FILENAME_MAX, "/usr/src/usr.sbin/sade/help/%s.TXT", file);
if (file_readable(buf))
return buf;
return NULL;
@ -461,85 +334,3 @@ vsystem(char *fmt, ...)
return i;
}
void
systemCreateHoloshell(void)
{
int waitstatus;
if ((FixItMode || OnVTY) && RunningAsInit) {
if (ehs_pid != 0) {
int pstat;
if (kill(ehs_pid, 0) == 0) {
if (msgNoYes("There seems to be an emergency holographic shell\n"
"already running on VTY 4.\n\n"
"Kill it and start a new one?"))
return;
/* try cleaning up as much as possible */
(void) kill(ehs_pid, SIGHUP);
sleep(1);
(void) kill(ehs_pid, SIGKILL);
}
/* avoid too many zombies */
(void) waitpid(ehs_pid, &pstat, WNOHANG);
}
if (strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0)
systemSuspendDialog(); /* must be before the fork() */
if ((ehs_pid = fork()) == 0) {
int i, fd;
struct termios foo;
extern int login_tty(int);
ioctl(0, TIOCNOTTY, NULL);
for (i = getdtablesize(); i >= 0; --i)
close(i);
if (strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0)
fd = open("/dev/console", O_RDWR);
else
fd = open("/dev/ttyv3", O_RDWR);
ioctl(0, TIOCSCTTY, &fd);
dup2(0, 1);
dup2(0, 2);
DebugFD = 2;
if (login_tty(fd) == -1)
msgDebug("Doctor: I can't set the controlling terminal.\n");
signal(SIGTTOU, SIG_IGN);
if (tcgetattr(fd, &foo) != -1) {
foo.c_cc[VERASE] = '\010';
if (tcsetattr(fd, TCSANOW, &foo) == -1)
msgDebug("Doctor: I'm unable to set the erase character.\n");
}
else
msgDebug("Doctor: I'm unable to get the terminal attributes!\n");
if (strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0) {
printf("Type ``exit'' in this fixit shell to resume sysinstall.\n\n");
fflush(stdout);
}
execlp("sh", "-sh", 0);
msgDebug("Was unable to execute sh for Holographic shell!\n");
exit(1);
}
else {
if (strcmp(variable_get(VAR_FIXIT_TTY), "standard") == 0) {
WINDOW *w = savescr();
msgNotify("Starting an emergency holographic shell on VTY4");
sleep(2);
restorescr(w);
}
else {
(void)waitpid(ehs_pid, &waitstatus, 0); /* we only wait for
shell to finish
it serial mode
since there is no
virtual console */
systemResumeDialog();
}
}
}
}

View File

@ -13,7 +13,7 @@
* $FreeBSD$
*/
#include "sysinstall.h"
#include "sade.h"
#include <stdarg.h>
#include <fcntl.h>
#include <sys/errno.h>
@ -36,38 +36,11 @@ prompt_term(char **termp, char **termcapp)
{ "xterm", termcap_xterm },
{ "cons25w", termcap_cons25w } }; /* must be last */
if (RunningAsInit) {
while (1) {
int i;
printf("\nThese are the predefined terminal types available to\n");
printf("sysinstall when running stand-alone. Please choose the\n");
printf("closest match for your particular terminal.\n\n");
printf("1 ...................... Standard ANSI terminal.\n");
printf("2 ...................... VT100 or compatible terminal.\n");
printf("3 ...................... FreeBSD system console (color).\n");
printf("4 ...................... FreeBSD system console (monochrome).\n\n");
printf("5 ...................... xterm terminal emulator.\n\n");
printf("Your choice: (1-5) ");
fflush(stdout);
fgets(str, 80, stdin);
i = str[0] - '0';
if (i > 0 && i < 6) {
*termp = (char *)lookup[i - 1].term;
*termcapp = (char *)lookup[i - 1].termcap;
break;
}
else
printf("\007Invalid choice, please try again.\n\n");
}
}
else {
printf("\nPlease set your TERM variable before running this program.\n");
printf("Defaulting to an ANSI compatible terminal - please press RETURN\n");
fgets(str, 80, stdin); /* Just to make it interactive */
*termp = (char *)"ansi";
*termcapp = (char *)termcap_ansi;
}
}
int
@ -80,14 +53,12 @@ set_termcap(void)
term = getenv("TERM");
stat = ioctl(STDERR_FILENO, GIO_COLOR, &ColorDisplay);
if (!RunningAsInit) {
if (isDebug())
DebugFD = open("sysinstall.debug", O_WRONLY|O_CREAT|O_TRUNC, 0644);
else
DebugFD = -1;
if (DebugFD < 0)
DebugFD = open("/dev/null", O_RDWR, 0);
}
if (!OnVTY || (stat < 0)) {
if (!term) {

View File

@ -1,44 +0,0 @@
/*
* USB support for sysinstall
*
* $FreeBSD$
*
* Copyright (c) 2000 John Baldwin <jhb@FreeBSD.org>. All rights reserved.
*
* This software may be used, modified, copied, and distributed, in
* both source and binary form provided that the above copyright and
* these terms are retained. Under no circumstances is the author
* responsible for the proper functioning of this software, nor does
* the author assume any responsibility for damages incurred with its
* use.
*/
#include "sysinstall.h"
#include <sys/fcntl.h>
#include <sys/time.h>
void
usbInitialize(void)
{
int fd;
WINDOW *w;
if (!RunningAsInit && !Fake) {
/* It's not my job... */
return;
}
if ((fd = open("/dev/usb", O_RDONLY)) < 0) {
msgDebug("Can't open USB controller.\n");
return;
}
close(fd);
w = savescr();
msgNotify("Initializing USB controller....");
variable_set2("usbd_enable", "YES", 1);
vsystem("/stand/usbd");
restorescr(w);
}

View File

@ -1,9 +1,4 @@
/*
* 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
@ -36,7 +31,7 @@
*
*/
#include "sysinstall.h"
#include "sade.h"
/* Routines for dealing with variable lists */

View File

@ -7,10 +7,9 @@
* ----------------------------------------------------------------------------
*
* $FreeBSD$
*
*/
#include "sysinstall.h"
#include "sade.h"
#include <fcntl.h>
#include <err.h>
#include <libdisk.h>