1995-04-27 12:50:35 +00:00
|
|
|
/*
|
|
|
|
* The new sysinstall program.
|
|
|
|
*
|
|
|
|
* This is probably the last program in the `sysinstall' line - the next
|
|
|
|
* generation being essentially a complete rewrite.
|
|
|
|
*
|
1996-04-28 00:37:38 +00:00
|
|
|
* $Id: install.c,v 1.86 1996/04/25 18:00:28 jkh Exp $
|
1995-04-27 12:50:35 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 1995
|
|
|
|
* Jordan Hubbard. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
1995-05-30 08:29:07 +00:00
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
* verbatim and that no modifications are made prior to this
|
1995-04-27 12:50:35 +00:00
|
|
|
* point in the file.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysinstall.h"
|
1995-12-07 10:34:59 +00:00
|
|
|
#include <ctype.h>
|
1995-05-08 06:06:30 +00:00
|
|
|
#include <sys/disklabel.h>
|
|
|
|
#include <sys/errno.h>
|
1995-05-25 18:48:33 +00:00
|
|
|
#include <sys/ioctl.h>
|
1995-05-08 06:06:30 +00:00
|
|
|
#include <sys/fcntl.h>
|
1995-05-20 10:33:14 +00:00
|
|
|
#include <sys/wait.h>
|
1995-12-07 10:34:59 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#define MSDOSFS
|
|
|
|
#include <sys/mount.h>
|
|
|
|
#undef MSDOSFS
|
1995-09-18 16:53:06 +00:00
|
|
|
#include <sys/stat.h>
|
1995-05-08 06:06:30 +00:00
|
|
|
#include <unistd.h>
|
1995-12-07 10:34:59 +00:00
|
|
|
#include <sys/mount.h>
|
1995-04-27 12:50:35 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
static void create_termcap(void);
|
1995-05-04 23:36:23 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
#define TERMCAP_FILE "/usr/share/misc/termcap"
|
1995-05-22 14:10:25 +00:00
|
|
|
|
|
|
|
static Boolean
|
1995-12-07 10:34:59 +00:00
|
|
|
checkLabels(Chunk **rdev, Chunk **sdev, Chunk **udev)
|
1995-05-22 14:10:25 +00:00
|
|
|
{
|
|
|
|
Device **devs;
|
1995-12-07 10:34:59 +00:00
|
|
|
Boolean status;
|
1995-05-22 14:10:25 +00:00
|
|
|
Disk *disk;
|
1995-12-07 10:34:59 +00:00
|
|
|
Chunk *c1, *c2, *rootdev, *swapdev, *usrdev;
|
1995-05-22 14:10:25 +00:00
|
|
|
int i;
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
status = TRUE;
|
|
|
|
*rdev = *sdev = *udev = rootdev = swapdev = usrdev = NULL;
|
1995-05-22 14:10:25 +00:00
|
|
|
devs = deviceFind(NULL, DEVICE_TYPE_DISK);
|
|
|
|
/* First verify that we have a root device */
|
|
|
|
for (i = 0; devs[i]; i++) {
|
|
|
|
if (!devs[i]->enabled)
|
|
|
|
continue;
|
|
|
|
disk = (Disk *)devs[i]->private;
|
|
|
|
msgDebug("Scanning disk %s for root filesystem\n", disk->name);
|
|
|
|
if (!disk->chunks)
|
|
|
|
msgFatal("No chunk list found for %s!", disk->name);
|
|
|
|
for (c1 = disk->chunks->part; c1; c1 = c1->next) {
|
|
|
|
if (c1->type == freebsd) {
|
|
|
|
for (c2 = c1->part; c2; c2 = c2->next) {
|
1996-03-24 18:57:37 +00:00
|
|
|
if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) {
|
1995-06-11 19:33:05 +00:00
|
|
|
if (c2->flags & CHUNK_IS_ROOT) {
|
|
|
|
if (rootdev) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("WARNING: You have more than one root device set?!\n"
|
|
|
|
"Using the first one found.");
|
1995-06-11 19:33:05 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
rootdev = c2;
|
1995-12-07 10:34:59 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("Found rootdev at %s!\n", rootdev->name);
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
1996-03-24 18:57:37 +00:00
|
|
|
else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/usr")) {
|
1995-06-11 19:33:05 +00:00
|
|
|
if (usrdev) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("WARNING: You have more than one /usr filesystem.\n"
|
|
|
|
"Using the first one found.");
|
1995-06-11 19:33:05 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
usrdev = c2;
|
1995-12-07 10:34:59 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("Found usrdev at %s!\n", usrdev->name);
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
1995-05-22 14:10:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
swapdev = NULL;
|
1995-05-23 02:41:18 +00:00
|
|
|
/* Now check for swap devices */
|
1995-05-22 14:10:25 +00:00
|
|
|
for (i = 0; devs[i]; i++) {
|
1996-01-14 11:45:05 +00:00
|
|
|
if (!devs[i]->enabled)
|
|
|
|
continue;
|
1995-05-22 14:10:25 +00:00
|
|
|
disk = (Disk *)devs[i]->private;
|
|
|
|
msgDebug("Scanning disk %s for swap partitions\n", disk->name);
|
|
|
|
if (!disk->chunks)
|
|
|
|
msgFatal("No chunk list found for %s!", disk->name);
|
|
|
|
for (c1 = disk->chunks->part; c1; c1 = c1->next) {
|
|
|
|
if (c1->type == freebsd) {
|
|
|
|
for (c2 = c1->part; c2; c2 = c2->next) {
|
1995-12-07 10:34:59 +00:00
|
|
|
if (c2->type == part && c2->subtype == FS_SWAP && !swapdev) {
|
1995-05-22 14:10:25 +00:00
|
|
|
swapdev = c2;
|
1995-12-07 10:34:59 +00:00
|
|
|
if (isDebug())
|
|
|
|
msgDebug("Found swapdev at %s!\n", swapdev->name);
|
1995-05-22 14:10:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
*rdev = rootdev;
|
1995-05-22 14:10:25 +00:00
|
|
|
if (!rootdev) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("No root device found - you must label a partition as /\n"
|
|
|
|
"in the label editor.");
|
|
|
|
status = FALSE;
|
1995-05-28 23:12:09 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
*sdev = swapdev;
|
1995-05-22 14:10:25 +00:00
|
|
|
if (!swapdev) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("No swap devices found - you must create at least one\n"
|
|
|
|
"swap partition.");
|
|
|
|
status = FALSE;
|
1995-05-22 14:10:25 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
*udev = usrdev;
|
|
|
|
if (!usrdev) {
|
|
|
|
msgConfirm("WARNING: No /usr filesystem found. This is not technically\n"
|
|
|
|
"an error if your root filesystem is big enough (or you later\n"
|
|
|
|
"intend to mount your /usr filesystem over NFS), but it may otherwise\n"
|
|
|
|
"cause you trouble if you're not exactly sure what you are doing!");
|
|
|
|
}
|
|
|
|
return status;
|
1995-05-22 14:10:25 +00:00
|
|
|
}
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
static int
|
1995-05-20 00:13:14 +00:00
|
|
|
installInitial(void)
|
1995-05-18 09:02:06 +00:00
|
|
|
{
|
1995-05-20 00:13:14 +00:00
|
|
|
static Boolean alreadyDone = FALSE;
|
|
|
|
|
|
|
|
if (alreadyDone)
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_SUCCESS;
|
1995-05-18 09:02:06 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!variable_get(DISK_LABELLED)) {
|
1995-05-21 15:40:54 +00:00
|
|
|
msgConfirm("You need to assign disk labels before you can proceed with\nthe installation.");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-05-21 15:40:54 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
/* If it's labelled, assume it's also partitioned */
|
|
|
|
if (!variable_get(DISK_PARTITIONED))
|
|
|
|
variable_set2(DISK_PARTITIONED, "yes");
|
1995-05-21 15:40:54 +00:00
|
|
|
|
|
|
|
/* If we refuse to proceed, bail. */
|
1995-12-07 10:34:59 +00:00
|
|
|
if (msgYesNo("Last Chance! Are you SURE you want continue the installation?\n\n"
|
|
|
|
"If you're running this on a disk with data you wish to save\n"
|
|
|
|
"then WE STRONGLY ENCOURAGE YOU TO MAKE PROPER BACKUPS before\n"
|
|
|
|
"proceeding!\n\n"
|
|
|
|
"We can take no responsibility for lost disk contents!"))
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
if (diskLabelCommit(NULL) != DITEM_SUCCESS) {
|
1995-06-11 19:33:05 +00:00
|
|
|
msgConfirm("Couldn't make filesystems properly. Aborting.");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
1995-09-18 16:53:06 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!copySelf()) {
|
|
|
|
msgConfirm("Couldn't clone the boot floppy onto the root file system.\n"
|
|
|
|
"Aborting.");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
1995-09-18 16:53:06 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
if (chroot("/mnt") == -1) {
|
|
|
|
msgConfirm("Unable to chroot to /mnt - this is bad!");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
|
1995-05-20 23:33:14 +00:00
|
|
|
chdir("/");
|
1995-05-23 18:06:16 +00:00
|
|
|
variable_set2(RUNNING_ON_ROOT, "yes");
|
1995-12-07 10:34:59 +00:00
|
|
|
|
1996-03-23 07:28:22 +00:00
|
|
|
/* stick a helpful shell over on the 4th VTY */
|
|
|
|
systemCreateHoloshell();
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
alreadyDone = TRUE;
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_SUCCESS;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-04-13 13:32:15 +00:00
|
|
|
installFixitCDROM(dialogMenuItem *self)
|
|
|
|
{
|
1996-04-25 18:00:28 +00:00
|
|
|
msgConfirm("Sorry, this feature is currently unimplemented but will,\n"
|
|
|
|
"at some point in the future, support the use of the live\n"
|
|
|
|
"filesystem CD (CD 2) in fixing your system.");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
installFixitFloppy(dialogMenuItem *self)
|
1995-12-07 10:34:59 +00:00
|
|
|
{
|
|
|
|
struct ufs_args args;
|
|
|
|
pid_t child;
|
|
|
|
int waitstatus;
|
|
|
|
|
1996-04-07 03:52:36 +00:00
|
|
|
variable_set2(SYSTEM_STATE, "fixit");
|
1995-12-07 10:34:59 +00:00
|
|
|
memset(&args, 0, sizeof(args));
|
|
|
|
args.fspec = "/dev/fd0";
|
|
|
|
Mkdir("/mnt2", NULL);
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
msgConfirm("Please insert a writable fixit floppy and press return");
|
|
|
|
if (mount(MOUNT_UFS, "/mnt2", 0, (caddr_t)&args) != -1)
|
|
|
|
break;
|
|
|
|
if (msgYesNo("Unable to mount the fixit floppy - do you want to try again?"))
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
dialog_clear();
|
|
|
|
dialog_update();
|
|
|
|
end_dialog();
|
|
|
|
DialogActive = FALSE;
|
1996-03-18 15:28:10 +00:00
|
|
|
if (!directory_exists("/tmp"))
|
1995-12-07 10:34:59 +00:00
|
|
|
(void)symlink("/mnt2/tmp", "/tmp");
|
1996-03-18 15:28:10 +00:00
|
|
|
if (!directory_exists("/var/tmp/vi.recover")) {
|
1996-04-13 13:32:15 +00:00
|
|
|
if (Mkdir("/var/tmp/vi.recover", NULL) != DITEM_SUCCESS) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Warning: Was unable to create a /var/tmp/vi.recover directory.\n"
|
|
|
|
"vi will kvetch and moan about it as a result but should still\n"
|
|
|
|
"be essentially usable.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Link the spwd.db file */
|
1996-04-23 01:29:35 +00:00
|
|
|
if (Mkdir("/etc", NULL) != DITEM_SUCCESS)
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Unable to create an /etc directory! Things are weird on this floppy..");
|
1996-04-23 01:29:35 +00:00
|
|
|
else if (symlink("/mnt2/etc/spwd.db", "/etc/spwd.db") == -1)
|
|
|
|
msgConfirm("Couldn't symlink the /etc/spwd.db file! I'm not sure I like this..");
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!file_readable(TERMCAP_FILE))
|
|
|
|
create_termcap();
|
|
|
|
if (!(child = fork())) {
|
|
|
|
struct termios foo;
|
|
|
|
|
|
|
|
signal(SIGTTOU, SIG_IGN);
|
|
|
|
if (tcgetattr(0, &foo) != -1) {
|
|
|
|
foo.c_cc[VERASE] = '\010';
|
|
|
|
if (tcsetattr(0, TCSANOW, &foo) == -1)
|
|
|
|
msgDebug("fixit shell: Unable to set erase character.\n");
|
1995-05-29 00:50:05 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
else
|
|
|
|
msgDebug("fixit shell: Unable to get terminal attributes!\n");
|
|
|
|
printf("When you're finished with this shell, please type exit.\n");
|
|
|
|
printf("The fixit floppy itself is mounted as /mnt2\n");
|
|
|
|
setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/stand:/mnt2/stand", 1);
|
1995-05-25 18:48:33 +00:00
|
|
|
execlp("sh", "-sh", 0);
|
1995-12-07 10:34:59 +00:00
|
|
|
msgDebug("fixit shell: Failed to execute shell!\n");
|
|
|
|
return -1;
|
1995-05-25 18:48:33 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
else
|
|
|
|
(void)waitpid(child, &waitstatus, 0);
|
1995-05-20 08:31:43 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
DialogActive = TRUE;
|
|
|
|
clear();
|
|
|
|
dialog_clear();
|
|
|
|
dialog_update();
|
|
|
|
unmount("/mnt2", MNT_FORCE);
|
|
|
|
msgConfirm("Please remove the fixit floppy now.");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_SUCCESS;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
|
1995-09-18 16:53:06 +00:00
|
|
|
int
|
1996-04-07 03:52:36 +00:00
|
|
|
installExpress(dialogMenuItem *self)
|
1995-09-18 16:53:06 +00:00
|
|
|
{
|
1996-04-07 03:52:36 +00:00
|
|
|
variable_set2(SYSTEM_STATE, "express");
|
1996-04-13 13:32:15 +00:00
|
|
|
if (diskPartitionEditor(self) == DITEM_FAILURE)
|
|
|
|
return DITEM_FAILURE;
|
1995-09-18 16:53:06 +00:00
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
if (diskLabelEditor(self) == DITEM_FAILURE)
|
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
if (!Dists) {
|
1996-04-28 00:37:38 +00:00
|
|
|
if (!dmenuOpenSimple(&MenuDistributions) && !Dists)
|
1996-04-25 17:31:27 +00:00
|
|
|
return DITEM_FAILURE | DITEM_RESTORE | DITEM_RECREATE;
|
1995-09-18 16:53:06 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
if (!mediaDevice) {
|
|
|
|
if (!dmenuOpenSimple(&MenuMedia) || !mediaDevice)
|
1996-04-25 17:31:27 +00:00
|
|
|
return DITEM_FAILURE | DITEM_RESTORE | DITEM_RECREATE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
if (installCommit(self) == DITEM_FAILURE)
|
1996-04-25 17:31:27 +00:00
|
|
|
return DITEM_FAILURE | DITEM_RESTORE | DITEM_RECREATE;
|
1995-12-07 10:34:59 +00:00
|
|
|
|
1996-04-25 17:31:27 +00:00
|
|
|
return DITEM_LEAVE_MENU | DITEM_RESTORE | DITEM_RECREATE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Novice mode installation */
|
|
|
|
int
|
1996-04-07 03:52:36 +00:00
|
|
|
installNovice(dialogMenuItem *self)
|
1995-12-07 10:34:59 +00:00
|
|
|
{
|
1996-04-07 03:52:36 +00:00
|
|
|
variable_set2(SYSTEM_STATE, "novice");
|
1996-04-25 17:31:27 +00:00
|
|
|
dialog_clear();
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("In the next menu, you will need to set up a DOS-style (\"fdisk\") partitioning\n"
|
|
|
|
"scheme for your hard disk. If you simply wish to devote all disk space\n"
|
|
|
|
"to FreeBSD (overwritting anything else that might be on the disk(s) selected)\n"
|
|
|
|
"then use the (A)ll command to select the default partitioning scheme followed\n"
|
|
|
|
"by a (Q)uit. If you wish to allocate only free space to FreeBSD, move to a\n"
|
|
|
|
"partition marked \"unused\" and use the (C)reate command.");
|
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
if (diskPartitionEditor(self) == DITEM_FAILURE)
|
|
|
|
return DITEM_FAILURE;
|
1995-09-18 16:53:06 +00:00
|
|
|
|
1996-04-25 17:31:27 +00:00
|
|
|
dialog_clear();
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Next, you need to create BSD partitions inside of the fdisk partition(s)\n"
|
|
|
|
"just created. If you have a reasonable amount of disk space (200MB or more)\n"
|
|
|
|
"and don't have any special requirements, simply use the (A)uto command to\n"
|
|
|
|
"allocate space automatically. If you have more specific needs or just don't\n"
|
|
|
|
"care for the layout chosen by (A)uto, press F1 for more information on\n"
|
|
|
|
"manual layout.");
|
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
if (diskLabelEditor(self) == DITEM_FAILURE)
|
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
|
1996-04-25 17:31:27 +00:00
|
|
|
dialog_clear();
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Now it is time to select an installation subset. There are a number of\n"
|
|
|
|
"canned distribution sets, ranging from minimal installation sets to full\n"
|
|
|
|
"X11 developer oriented configurations. You can also select a custom set\n"
|
|
|
|
"of distributions if none of the provided ones are suitable.");
|
|
|
|
while (1) {
|
1996-04-28 00:37:38 +00:00
|
|
|
if (!dmenuOpenSimple(&MenuDistributions) && !Dists)
|
1996-04-25 17:31:27 +00:00
|
|
|
return DITEM_FAILURE | DITEM_RESTORE | DITEM_RECREATE;
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
if (Dists || !msgYesNo("No distributions selected. Are you sure you wish to continue?"))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mediaDevice) {
|
1996-04-25 17:31:27 +00:00
|
|
|
dialog_clear();
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Finally, you must specify an installation medium.");
|
|
|
|
if (!dmenuOpenSimple(&MenuMedia) || !mediaDevice)
|
1996-04-25 17:31:27 +00:00
|
|
|
return DITEM_FAILURE | DITEM_RESTORE | DITEM_RECREATE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
if (installCommit(self) == DITEM_FAILURE)
|
1996-04-25 17:31:27 +00:00
|
|
|
return DITEM_FAILURE | DITEM_RESTORE | DITEM_RECREATE;
|
1995-12-07 10:34:59 +00:00
|
|
|
|
1996-04-25 17:31:27 +00:00
|
|
|
return DITEM_LEAVE_MENU | DITEM_RESTORE | DITEM_RECREATE;
|
1995-09-18 16:53:06 +00:00
|
|
|
}
|
|
|
|
|
1995-05-21 15:40:54 +00:00
|
|
|
/*
|
1995-09-18 16:53:06 +00:00
|
|
|
* What happens when we select "Commit" in the custom installation menu.
|
|
|
|
*
|
1995-12-07 10:34:59 +00:00
|
|
|
* This is broken into multiple stages so that the user can do a full installation but come back here
|
|
|
|
* again to load more distributions, perhaps from a different media type. This would allow, for
|
|
|
|
* example, the user to load the majority of the system from CDROM and then use ftp to load just the
|
|
|
|
* DES dist.
|
1995-05-21 15:40:54 +00:00
|
|
|
*/
|
1995-05-20 00:13:14 +00:00
|
|
|
int
|
1996-04-07 03:52:36 +00:00
|
|
|
installCommit(dialogMenuItem *self)
|
1995-05-20 00:13:14 +00:00
|
|
|
{
|
1995-06-11 19:33:05 +00:00
|
|
|
int i;
|
1996-03-18 15:28:10 +00:00
|
|
|
extern int cdromMounted;
|
1996-04-07 03:52:36 +00:00
|
|
|
char *str;
|
1995-05-28 09:31:44 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!mediaVerify())
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
|
1996-04-07 03:52:36 +00:00
|
|
|
str = variable_get(SYSTEM_STATE);
|
1996-04-13 13:32:15 +00:00
|
|
|
i = DITEM_LEAVE_MENU;
|
1995-12-07 10:34:59 +00:00
|
|
|
if (RunningAsInit) {
|
1996-04-13 13:32:15 +00:00
|
|
|
if (installInitial() == DITEM_FAILURE)
|
|
|
|
return DITEM_FAILURE;
|
|
|
|
if (configFstab() == DITEM_FAILURE)
|
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!rootExtract()) {
|
|
|
|
msgConfirm("Failed to load the ROOT distribution. Please correct\n"
|
|
|
|
"this problem and try again.");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
1995-05-21 15:40:54 +00:00
|
|
|
}
|
1995-09-18 16:53:06 +00:00
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
if (distExtractAll(self) == DITEM_FAILURE)
|
|
|
|
i = DITEM_FAILURE;
|
1995-05-21 15:40:54 +00:00
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
if (installFixup(self) == DITEM_FAILURE)
|
|
|
|
i = DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
|
1996-04-13 13:32:15 +00:00
|
|
|
if (i != DITEM_FAILURE && !strcmp(str, "novice")) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Since you're running the novice installation, a few post-configuration\n"
|
|
|
|
"questions will be asked at this point. For any option you do not wish\n"
|
|
|
|
"to configure, select Cancel.");
|
|
|
|
|
|
|
|
if (mediaDevice->type != DEVICE_TYPE_FTP && mediaDevice->type != DEVICE_TYPE_NFS) {
|
|
|
|
if (!msgYesNo("Would you like to configure this machine's network interfaces?")) {
|
|
|
|
Device *save = mediaDevice;
|
1995-06-11 19:33:05 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
/* This will also set the media device, which we don't want */
|
|
|
|
tcpDeviceSelect();
|
|
|
|
mediaDevice = save;
|
|
|
|
}
|
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!msgYesNo("Would you like to configure Samba for connecting NETBUI clients to this\n"
|
|
|
|
"machine? Windows 95, Windows NT and Windows for Workgroups\n"
|
|
|
|
"machines can use NETBUI transport for disk and printer sharing."))
|
1996-04-07 03:52:36 +00:00
|
|
|
configSamba(self);
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
if (!msgYesNo("Will this machine be an IP gateway (e.g. will it forward packets\n"
|
|
|
|
"between interfaces)?"))
|
|
|
|
variable_set2("gateway", "YES");
|
|
|
|
|
|
|
|
if (!msgYesNo("Do you want to allow anonymous FTP connections to this machine?"))
|
1996-04-07 03:52:36 +00:00
|
|
|
configAnonFTP(self);
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
if (!msgYesNo("Do you want to configure this machine as an NFS server?"))
|
1996-04-07 03:52:36 +00:00
|
|
|
configNFSServer(self);
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
if (!msgYesNo("Do you want to configure this machine as an NFS client?"))
|
|
|
|
variable_set2("nfs_client", "YES");
|
|
|
|
|
|
|
|
if (!msgYesNo("Do you want to configure this machine as a WEB server?"))
|
1996-04-07 03:52:36 +00:00
|
|
|
configApache(self);
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
if (!msgYesNo("Would you like to customize your system console settings?"))
|
|
|
|
dmenuOpenSimple(&MenuSyscons);
|
|
|
|
|
1996-04-23 01:29:35 +00:00
|
|
|
if (!msgYesNo("Would you like to set this machine's time zone now?")) {
|
|
|
|
WINDOW *w = savescr();
|
|
|
|
|
|
|
|
dialog_clear();
|
1995-12-07 10:34:59 +00:00
|
|
|
systemExecute("rm -f /etc/wall_cmos_clock /etc/localtime; tzsetup");
|
1996-04-23 01:29:35 +00:00
|
|
|
restorescr(w);
|
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
if (!msgYesNo("Does this system have a mouse attached to it?"))
|
|
|
|
dmenuOpenSimple(&MenuMouse);
|
|
|
|
|
1996-03-18 15:28:10 +00:00
|
|
|
if (directory_exists("/usr/X11R6")) {
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!msgYesNo("Would you like to configure your X server at this time?"))
|
1996-04-23 01:29:35 +00:00
|
|
|
configXFree86(self);
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
1995-05-28 09:31:44 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
if (cdromMounted) {
|
|
|
|
if (!msgYesNo("Would you like to link to the ports tree on your CDROM?\n\n"
|
|
|
|
"This will require that you have your FreeBSD CD in the CDROM\n"
|
|
|
|
"drive to use the ports collection, but at a substantial savings\n"
|
|
|
|
"in disk space (NOTE: This may take as long as 15 or 20 minutes\n"
|
|
|
|
"depending on the speed of your CDROM drive)."))
|
1996-04-07 03:52:36 +00:00
|
|
|
configPorts(self);
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
if (!msgYesNo("The FreeBSD package collection is a collection of over 300 ready-to-run\n"
|
|
|
|
"applications, from text editors to games to WEB servers. Would you like\n"
|
|
|
|
"to browse the collection now?"))
|
1996-04-07 03:52:36 +00:00
|
|
|
configPackages(self);
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
/* XXX Put whatever other nice configuration questions you'd like to ask the user here XXX */
|
|
|
|
|
1995-05-28 09:31:44 +00:00
|
|
|
}
|
1995-05-29 11:01:42 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
/* Final menu of last resort */
|
|
|
|
if (!msgYesNo("Would you like to go to the general configuration menu for a chance to set\n"
|
1996-04-25 17:31:27 +00:00
|
|
|
"any last options?"))
|
1995-12-07 10:34:59 +00:00
|
|
|
dmenuOpenSimple(&MenuConfigure);
|
|
|
|
|
|
|
|
/* Write out any changes .. */
|
|
|
|
configResolv();
|
|
|
|
configSysconfig();
|
|
|
|
|
|
|
|
/* Don't print this if we're express or novice installing */
|
|
|
|
if (strcmp(str, "express") && strcmp(str, "novice")) {
|
1996-04-23 01:29:35 +00:00
|
|
|
if (Dists || i == DITEM_FAILURE)
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Installation completed with some errors. You may wish to\n"
|
|
|
|
"scroll through the debugging messages on VTY1 with the\n"
|
|
|
|
"scroll-lock feature.");
|
1996-04-23 01:29:35 +00:00
|
|
|
else
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Installation completed successfully.\n\n"
|
|
|
|
"If you have any network devices you have not yet configured,\n"
|
|
|
|
"see the Interfaces configuration item on the Configuration menu.");
|
|
|
|
}
|
|
|
|
else if (!strcmp(str, "novice")) {
|
1996-04-25 17:31:27 +00:00
|
|
|
if (Dists || DITEM_STATUS(i) == DITEM_FAILURE) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Installation completed with some errors. You may wish to\n"
|
|
|
|
"scroll through the debugging messages on VTY1 with the\n"
|
|
|
|
"scroll-lock feature. You can also chose \"No\" at the next\n"
|
|
|
|
"prompt and go back into the installation menus to try and retry\n"
|
|
|
|
"whichever operations have failed.");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msgConfirm("Congradulations! You now have FreeBSD installed on your system.\n"
|
|
|
|
"At this stage, there shouldn't be much left to do from this\n"
|
|
|
|
"installation utility so if you wish to come up from the hard disk\n"
|
|
|
|
"now, simply select \"Yes\" at the next prompt to reboot.\n"
|
|
|
|
"If you wish to re-enter this utility after the system is up, you\n"
|
|
|
|
"may do so by typing: /stand/sysinstall.");
|
|
|
|
}
|
|
|
|
}
|
1996-04-25 17:31:27 +00:00
|
|
|
variable_set2(SYSTEM_STATE, DITEM_STATUS(i) == DITEM_FAILURE ? "error-install" : "full-install");
|
1996-04-07 03:52:36 +00:00
|
|
|
|
1996-04-25 17:31:27 +00:00
|
|
|
return i | DITEM_RESTORE | DITEM_RECREATE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-04-07 03:52:36 +00:00
|
|
|
installFixup(dialogMenuItem *self)
|
1995-12-07 10:34:59 +00:00
|
|
|
{
|
|
|
|
Device **devs;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!file_readable("/kernel")) {
|
|
|
|
if (file_readable("/kernel.GENERIC")) {
|
|
|
|
if (vsystem("cp -p /kernel.GENERIC /kernel")) {
|
|
|
|
msgConfirm("Unable to link /kernel into place!");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
msgConfirm("Can't find a kernel image to link to on the root file system!\n"
|
|
|
|
"You're going to have a hard time getting this system to\n"
|
|
|
|
"boot from the hard disk, I'm afraid!");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
/* Resurrect /dev after bin distribution screws it up */
|
1995-12-07 10:34:59 +00:00
|
|
|
if (RunningAsInit) {
|
1995-06-11 19:33:05 +00:00
|
|
|
msgNotify("Remaking all devices.. Please wait!");
|
1995-12-07 10:34:59 +00:00
|
|
|
if (vsystem("cd /dev; sh MAKEDEV all")) {
|
1995-06-11 19:33:05 +00:00
|
|
|
msgConfirm("MAKEDEV returned non-zero status");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
msgNotify("Resurrecting /dev entries for slices..");
|
|
|
|
devs = deviceFind(NULL, DEVICE_TYPE_DISK);
|
|
|
|
if (!devs)
|
|
|
|
msgFatal("Couldn't get a disk device list!");
|
1995-12-07 10:34:59 +00:00
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
/* Resurrect the slices that the former clobbered */
|
|
|
|
for (i = 0; devs[i]; i++) {
|
|
|
|
Disk *disk = (Disk *)devs[i]->private;
|
|
|
|
Chunk *c1;
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!devs[i]->enabled)
|
|
|
|
continue;
|
1995-06-11 19:33:05 +00:00
|
|
|
if (!disk->chunks)
|
|
|
|
msgFatal("No chunk list found for %s!", disk->name);
|
|
|
|
for (c1 = disk->chunks->part; c1; c1 = c1->next) {
|
|
|
|
if (c1->type == freebsd) {
|
|
|
|
msgNotify("Making slice entries for %s", c1->name);
|
1995-12-07 10:34:59 +00:00
|
|
|
if (vsystem("cd /dev; sh MAKEDEV %sh", c1->name)) {
|
1995-06-11 19:33:05 +00:00
|
|
|
msgConfirm("Unable to make slice entries for %s!", c1->name);
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
/* XXX Do all the last ugly work-arounds here which we'll try and excise someday right?? XXX */
|
1995-06-11 19:33:05 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
msgNotify("Fixing permissions..");
|
|
|
|
/* BOGON #1: XFree86 extracting /usr/X11R6 with root-only perms */
|
1996-03-18 15:28:10 +00:00
|
|
|
if (directory_exists("/usr/X11R6")) {
|
1995-12-07 10:34:59 +00:00
|
|
|
system("chmod -R a+r /usr/X11R6");
|
|
|
|
system("find /usr/X11R6 -type d | xargs chmod a+x");
|
|
|
|
}
|
|
|
|
/* BOGON #2: We leave /etc in a bad state */
|
|
|
|
chmod("/etc", 0755);
|
1995-06-11 19:33:05 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
/* BOGON #3: No /var/db/mountdtab complains */
|
|
|
|
Mkdir("/var/db", NULL);
|
|
|
|
creat("/var/db/mountdtab", 0644);
|
1995-06-11 19:33:05 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
/* Now run all the mtree stuff to fix things up */
|
|
|
|
vsystem("mtree -deU -f /etc/mtree/BSD.root.dist -p /");
|
|
|
|
vsystem("mtree -deU -f /etc/mtree/BSD.var.dist -p /var");
|
|
|
|
vsystem("mtree -deU -f /etc/mtree/BSD.usr.dist -p /usr");
|
1995-09-18 16:53:06 +00:00
|
|
|
}
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_SUCCESS;
|
1995-05-01 21:56:32 +00:00
|
|
|
}
|
1995-05-06 09:34:24 +00:00
|
|
|
|
|
|
|
/* Go newfs and/or mount all the filesystems we've been asked to */
|
1995-12-07 10:34:59 +00:00
|
|
|
int
|
1996-04-07 03:52:36 +00:00
|
|
|
installFilesystems(dialogMenuItem *self)
|
1995-05-06 09:34:24 +00:00
|
|
|
{
|
|
|
|
int i;
|
1995-05-16 02:53:31 +00:00
|
|
|
Disk *disk;
|
1995-12-07 10:34:59 +00:00
|
|
|
Chunk *c1, *c2, *rootdev, *swapdev, *usrdev;
|
1995-05-16 11:37:27 +00:00
|
|
|
Device **devs;
|
1995-12-07 10:34:59 +00:00
|
|
|
PartInfo *root;
|
1996-04-07 03:52:36 +00:00
|
|
|
char dname[80], *str;
|
1995-12-07 10:34:59 +00:00
|
|
|
extern int MakeDevChunk(Chunk *c, char *n);
|
|
|
|
Boolean upgrade = FALSE;
|
|
|
|
|
1996-04-07 03:52:36 +00:00
|
|
|
str = variable_get(SYSTEM_STATE);
|
|
|
|
|
|
|
|
if (!checkLabels(&rootdev, &swapdev, &usrdev))
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-05-06 09:34:24 +00:00
|
|
|
|
1996-03-24 18:57:37 +00:00
|
|
|
root = (PartInfo *)rootdev->private_data;
|
1995-05-08 06:06:30 +00:00
|
|
|
command_clear();
|
1995-12-07 10:34:59 +00:00
|
|
|
upgrade = str && !strcmp(str, "upgrade");
|
|
|
|
|
|
|
|
/* As the very first thing, try to get ourselves some swap space */
|
|
|
|
sprintf(dname, "/dev/%s", swapdev->name);
|
|
|
|
if (!MakeDevChunk(swapdev, "/dev") || !file_readable(dname)) {
|
|
|
|
msgConfirm("Unable to make device node for %s in /dev!\n"
|
|
|
|
"The creation of filesystems will be aborted.", dname);
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
if (!swapon(dname))
|
|
|
|
msgNotify("Added %s as initial swap device", dname);
|
|
|
|
else
|
|
|
|
msgConfirm("WARNING! Unable to swap to %s: %s\n"
|
|
|
|
"This may cause the installation to fail at some point\n"
|
|
|
|
"if you don't have a lot of memory.", dname, strerror(errno));
|
|
|
|
|
|
|
|
/* Next, create and/or mount the root device */
|
|
|
|
sprintf(dname, "/dev/r%sa", rootdev->disk->name);
|
|
|
|
if (!MakeDevChunk(rootdev, "/dev") || !file_readable(dname)) {
|
|
|
|
msgConfirm("Unable to make device node for %s in /dev!\n"
|
|
|
|
"The creation of filesystems will be aborted.", dname);
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
1995-05-16 02:53:31 +00:00
|
|
|
|
1996-04-23 01:29:35 +00:00
|
|
|
if (strcmp(root->mountpoint, "/"))
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Warning: %s is marked as a root partition but is mounted on %s", rootdev->name, root->mountpoint);
|
1995-05-16 11:37:27 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
if (root->newfs) {
|
1995-05-22 14:10:25 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
msgNotify("Making a new root filesystem on %s", dname);
|
1995-12-07 10:34:59 +00:00
|
|
|
i = vsystem("%s %s", root->newfs_cmd, dname);
|
1995-05-22 14:10:25 +00:00
|
|
|
if (i) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Unable to make new root filesystem on %s!\n"
|
|
|
|
"Command returned status %d", dname, i);
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-05-16 11:37:27 +00:00
|
|
|
}
|
|
|
|
}
|
1995-05-24 17:49:20 +00:00
|
|
|
else {
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!upgrade) {
|
|
|
|
msgConfirm("Warning: Root device is selected read-only. It will be assumed\n"
|
|
|
|
"that you have the appropriate device entries already in /dev.");
|
|
|
|
}
|
|
|
|
msgNotify("Checking integrity of existing %s filesystem.", dname);
|
1995-05-24 17:49:20 +00:00
|
|
|
i = vsystem("fsck -y %s", dname);
|
1996-04-23 01:29:35 +00:00
|
|
|
if (i)
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Warning: fsck returned status of %d for %s.\n"
|
|
|
|
"This partition may be unsafe to use.", i, dname);
|
1995-05-24 17:49:20 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
/* Switch to block device */
|
1995-05-28 20:28:15 +00:00
|
|
|
sprintf(dname, "/dev/%sa", rootdev->disk->name);
|
1995-05-22 14:10:25 +00:00
|
|
|
if (Mount("/mnt", dname)) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Unable to mount the root file system on %s! Giving up.", dname);
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-05-22 14:10:25 +00:00
|
|
|
}
|
1995-05-16 11:37:27 +00:00
|
|
|
|
1995-05-18 09:02:06 +00:00
|
|
|
/* Now buzz through the rest of the partitions and mount them too */
|
1995-12-07 10:34:59 +00:00
|
|
|
devs = deviceFind(NULL, DEVICE_TYPE_DISK);
|
1995-05-16 11:37:27 +00:00
|
|
|
for (i = 0; devs[i]; i++) {
|
1995-05-28 20:28:15 +00:00
|
|
|
if (!devs[i]->enabled)
|
|
|
|
continue;
|
|
|
|
|
1995-05-16 11:37:27 +00:00
|
|
|
disk = (Disk *)devs[i]->private;
|
1995-06-11 19:33:05 +00:00
|
|
|
if (!disk->chunks) {
|
|
|
|
msgConfirm("No chunk list found for %s!", disk->name);
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
if (root->newfs || upgrade) {
|
1995-06-11 19:33:05 +00:00
|
|
|
Mkdir("/mnt/dev", NULL);
|
|
|
|
MakeDevDisk(disk, "/mnt/dev");
|
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
|
1995-05-16 11:37:27 +00:00
|
|
|
for (c1 = disk->chunks->part; c1; c1 = c1->next) {
|
|
|
|
if (c1->type == freebsd) {
|
|
|
|
for (c2 = c1->part; c2; c2 = c2->next) {
|
1996-03-24 18:57:37 +00:00
|
|
|
if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) {
|
|
|
|
PartInfo *tmp = (PartInfo *)c2->private_data;
|
1995-05-08 06:06:30 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
/* Already did root */
|
|
|
|
if (c2 == rootdev)
|
1995-05-16 11:37:27 +00:00
|
|
|
continue;
|
|
|
|
|
1995-05-08 06:06:30 +00:00
|
|
|
if (tmp->newfs)
|
1995-05-22 14:10:25 +00:00
|
|
|
command_shell_add(tmp->mountpoint, "%s /mnt/dev/r%s", tmp->newfs_cmd, c2->name);
|
1995-05-24 17:49:20 +00:00
|
|
|
else
|
|
|
|
command_shell_add(tmp->mountpoint, "fsck -y /mnt/dev/r%s", c2->name);
|
1995-05-16 02:53:31 +00:00
|
|
|
command_func_add(tmp->mountpoint, Mount, c2->name);
|
1995-05-08 06:06:30 +00:00
|
|
|
}
|
1995-05-22 14:10:25 +00:00
|
|
|
else if (c2->type == part && c2->subtype == FS_SWAP) {
|
|
|
|
char fname[80];
|
|
|
|
int i;
|
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
if (c2 == swapdev)
|
|
|
|
continue;
|
1995-05-22 14:10:25 +00:00
|
|
|
sprintf(fname, "/mnt/dev/%s", c2->name);
|
|
|
|
i = swapon(fname);
|
|
|
|
if (!i)
|
1995-12-07 10:34:59 +00:00
|
|
|
msgNotify("Added %s as an additional swap device", fname);
|
1996-04-23 01:29:35 +00:00
|
|
|
else
|
1995-05-22 14:10:25 +00:00
|
|
|
msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno));
|
|
|
|
}
|
1995-05-06 09:34:24 +00:00
|
|
|
}
|
|
|
|
}
|
1996-03-24 18:57:37 +00:00
|
|
|
else if (c1->type == fat && c1->private_data && (root->newfs || upgrade)) {
|
1995-06-11 19:33:05 +00:00
|
|
|
char name[FILENAME_MAX];
|
1995-05-24 17:49:20 +00:00
|
|
|
|
1996-03-24 18:57:37 +00:00
|
|
|
sprintf(name, "/mnt%s", ((PartInfo *)c1->private_data)->mountpoint);
|
1995-06-11 19:33:05 +00:00
|
|
|
Mkdir(name, NULL);
|
1995-05-24 17:49:20 +00:00
|
|
|
}
|
1995-05-06 09:34:24 +00:00
|
|
|
}
|
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
msgNotify("Copying initial device files..");
|
1995-06-11 19:33:05 +00:00
|
|
|
/* Copy the boot floppy's dev files */
|
1996-01-29 20:17:27 +00:00
|
|
|
if ((root->newfs || upgrade) && vsystem("find -x /dev | cpio -pdumv /mnt")) {
|
1995-06-11 19:33:05 +00:00
|
|
|
msgConfirm("Couldn't clone the /dev files!");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_FAILURE;
|
1995-06-11 19:33:05 +00:00
|
|
|
}
|
|
|
|
|
1995-05-08 06:06:30 +00:00
|
|
|
command_sort();
|
|
|
|
command_execute();
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_SUCCESS;
|
1995-12-07 10:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1996-04-07 03:52:36 +00:00
|
|
|
installVarDefaults(dialogMenuItem *self)
|
1995-12-07 10:34:59 +00:00
|
|
|
{
|
|
|
|
/* Set default startup options */
|
|
|
|
variable_set2(VAR_ROUTEDFLAGS, "-q");
|
|
|
|
variable_set2(VAR_RELNAME, RELEASE_NAME);
|
|
|
|
variable_set2(VAR_CPIO_VERBOSITY, "high");
|
|
|
|
variable_set2(VAR_TAPE_BLOCKSIZE, DEFAULT_TAPE_BLOCKSIZE);
|
1996-03-23 07:21:31 +00:00
|
|
|
variable_set2(VAR_EDITOR, "/stand/ee");
|
1995-12-07 10:34:59 +00:00
|
|
|
variable_set2(VAR_FTP_USER, "ftp");
|
1996-03-24 09:43:53 +00:00
|
|
|
variable_set2(VAR_BROWSER_PACKAGE, "lynx-2.4fm");
|
1995-12-07 10:34:59 +00:00
|
|
|
variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx");
|
|
|
|
variable_set2(VAR_CONFIG_FILE, "freebsd.cfg");
|
|
|
|
variable_set2(VAR_FTP_STATE, "passive");
|
|
|
|
variable_set2(VAR_FTP_ONERROR, "abort");
|
|
|
|
variable_set2(VAR_FTP_RETRIES, MAX_FTP_RETRIES);
|
|
|
|
if (getpid() != 1)
|
|
|
|
variable_set2(SYSTEM_STATE, "update");
|
|
|
|
else
|
|
|
|
variable_set2(SYSTEM_STATE, "init");
|
1996-04-13 13:32:15 +00:00
|
|
|
return DITEM_SUCCESS;
|
1995-05-06 09:34:24 +00:00
|
|
|
}
|
|
|
|
|
1995-05-19 15:56:02 +00:00
|
|
|
/* Copy the boot floppy contents into /stand */
|
1995-12-07 10:34:59 +00:00
|
|
|
Boolean
|
|
|
|
copySelf(void)
|
1995-05-19 15:56:02 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
1995-05-23 02:41:18 +00:00
|
|
|
msgWeHaveOutput("Copying the boot floppy to /stand on root filesystem");
|
1996-01-29 20:17:27 +00:00
|
|
|
i = vsystem("find -x /stand | cpio -pdumv /mnt");
|
1995-06-11 19:33:05 +00:00
|
|
|
if (i) {
|
1995-05-19 15:56:02 +00:00
|
|
|
msgConfirm("Copy returned error status of %d!", i);
|
1995-06-11 19:33:05 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
1995-05-28 23:12:09 +00:00
|
|
|
|
|
|
|
/* Copy the /etc files into their rightful place */
|
1996-01-29 20:17:27 +00:00
|
|
|
if (vsystem("cd /mnt/stand; find etc | cpio -pdumv /mnt")) {
|
1995-06-11 19:33:05 +00:00
|
|
|
msgConfirm("Couldn't copy up the /etc files!");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
1995-05-19 15:56:02 +00:00
|
|
|
}
|
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
static Boolean loop_on_root_floppy(void);
|
1995-05-24 17:49:20 +00:00
|
|
|
|
1995-12-07 10:34:59 +00:00
|
|
|
Boolean
|
|
|
|
rootExtract(void)
|
1995-05-06 09:34:24 +00:00
|
|
|
{
|
1995-05-27 10:47:44 +00:00
|
|
|
int fd;
|
1995-06-11 19:33:05 +00:00
|
|
|
static Boolean alreadyExtracted = FALSE;
|
|
|
|
|
|
|
|
if (alreadyExtracted)
|
|
|
|
return TRUE;
|
1995-05-24 09:00:58 +00:00
|
|
|
|
1995-05-26 08:41:52 +00:00
|
|
|
if (mediaDevice) {
|
1995-06-11 19:33:05 +00:00
|
|
|
if (isDebug())
|
1995-12-07 10:34:59 +00:00
|
|
|
msgDebug("Attempting to extract root image from %s\n", mediaDevice->name);
|
1995-05-26 08:41:52 +00:00
|
|
|
switch(mediaDevice->type) {
|
|
|
|
|
1995-05-30 05:50:53 +00:00
|
|
|
case DEVICE_TYPE_FLOPPY:
|
1995-06-11 19:33:05 +00:00
|
|
|
alreadyExtracted = loop_on_root_floppy();
|
1995-05-30 05:50:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
1995-12-07 10:34:59 +00:00
|
|
|
if (!mediaDevice->init(mediaDevice))
|
1995-06-11 19:33:05 +00:00
|
|
|
break;
|
1995-12-07 10:34:59 +00:00
|
|
|
fd = mediaDevice->get(mediaDevice, "floppies/root.flp", FALSE);
|
1995-06-11 19:33:05 +00:00
|
|
|
if (fd < 0) {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgConfirm("Couldn't get root image from %s!\n"
|
|
|
|
"Will try to get it from floppy.", mediaDevice->name);
|
|
|
|
mediaDevice->shutdown(mediaDevice);
|
1995-06-11 19:33:05 +00:00
|
|
|
alreadyExtracted = loop_on_root_floppy();
|
1995-05-29 13:37:43 +00:00
|
|
|
}
|
|
|
|
else {
|
1995-12-07 10:34:59 +00:00
|
|
|
msgNotify("Loading root image from:\n%s", mediaDevice->name);
|
1995-06-11 19:33:05 +00:00
|
|
|
alreadyExtracted = mediaExtractDist("/", fd);
|
1995-12-07 10:34:59 +00:00
|
|
|
mediaDevice->close(mediaDevice, fd);
|
1995-05-20 08:31:43 +00:00
|
|
|
}
|
1995-05-26 08:41:52 +00:00
|
|
|
break;
|
1995-05-20 08:31:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
1995-06-11 19:33:05 +00:00
|
|
|
alreadyExtracted = loop_on_root_floppy();
|
|
|
|
return alreadyExtracted;
|
1995-05-26 08:41:52 +00:00
|
|
|
}
|
|
|
|
|
1995-06-11 19:33:05 +00:00
|
|
|
static Boolean
|
1995-05-26 08:41:52 +00:00
|
|
|
loop_on_root_floppy(void)
|
|
|
|
{
|
|
|
|
int fd;
|
1995-06-11 19:33:05 +00:00
|
|
|
int status = FALSE;
|
1995-05-26 08:41:52 +00:00
|
|
|
|
1995-05-29 11:01:42 +00:00
|
|
|
while (1) {
|
|
|
|
fd = getRootFloppy();
|
|
|
|
if (fd != -1) {
|
1995-06-11 19:33:05 +00:00
|
|
|
msgNotify("Extracting root floppy..");
|
|
|
|
status = mediaExtractDist("/", fd);
|
|
|
|
close(fd);
|
1995-05-29 11:01:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1995-06-11 19:33:05 +00:00
|
|
|
return status;
|
1995-05-06 09:34:24 +00:00
|
|
|
}
|
1995-12-07 10:34:59 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
create_termcap(void)
|
|
|
|
{
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
const char *caps[] = {
|
|
|
|
termcap_vt100, termcap_cons25, termcap_cons25_m, termcap_cons25r,
|
|
|
|
termcap_cons25r_m, termcap_cons25l1, termcap_cons25l1_m, NULL,
|
|
|
|
};
|
|
|
|
const char **cp;
|
|
|
|
|
|
|
|
if (!file_readable(TERMCAP_FILE)) {
|
|
|
|
Mkdir("/usr/share/misc", NULL);
|
|
|
|
fp = fopen(TERMCAP_FILE, "w");
|
|
|
|
if (!fp) {
|
|
|
|
msgConfirm("Unable to initialize termcap file. Some screen-oriented\nutilities may not work.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cp = caps;
|
|
|
|
while (*cp)
|
|
|
|
fprintf(fp, "%s\n", *(cp++));
|
|
|
|
fclose(fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|