install.c revision 107560
138774Snsouch/* 293023Snsouch * The new sysinstall program. 338774Snsouch * 438774Snsouch * This is probably the last program in the `sysinstall' line - the next 538774Snsouch * generation being essentially a complete rewrite. 638774Snsouch * 738774Snsouch * $FreeBSD: head/usr.sbin/sade/install.c 107560 2002-12-03 19:36:12Z jhb $ 838774Snsouch * 938774Snsouch * Copyright (c) 1995 1038774Snsouch * Jordan Hubbard. All rights reserved. 1138774Snsouch * 1238774Snsouch * Redistribution and use in source and binary forms, with or without 1338774Snsouch * modification, are permitted provided that the following conditions 1438774Snsouch * are met: 1538774Snsouch * 1. Redistributions of source code must retain the above copyright 1638774Snsouch * notice, this list of conditions and the following disclaimer, 1738774Snsouch * verbatim and that no modifications are made prior to this 1838774Snsouch * point in the file. 1938774Snsouch * 2. Redistributions in binary form must reproduce the above copyright 2038774Snsouch * notice, this list of conditions and the following disclaimer in the 2138774Snsouch * documentation and/or other materials provided with the distribution. 2238774Snsouch * 2338774Snsouch * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND 2438774Snsouch * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2538774Snsouch * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2638774Snsouch * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE 27119418Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28119418Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29119418Sobrien * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) 3038774Snsouch * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3138774Snsouch * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3238774Snsouch * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3338774Snsouch * SUCH DAMAGE. 3438774Snsouch * 3538774Snsouch */ 3638774Snsouch 37181304Sjhb#include "sysinstall.h" 38167856Simp#include <ctype.h> 3938774Snsouch#include <sys/disklabel.h> 40181304Sjhb#include <sys/errno.h> 41282674Sloos#include <sys/ioctl.h> 42274641Sian#include <sys/fcntl.h> 4338774Snsouch#include <sys/wait.h> 4438774Snsouch#include <sys/uio.h> 4538774Snsouch#include <sys/param.h> 4638774Snsouch#define MSDOSFS 4738774Snsouch#include <sys/mount.h> 4838774Snsouch#include <ufs/ufs/ufsmount.h> 4938774Snsouch#include <fs/msdosfs/msdosfsmount.h> 50129152Sjoerg#undef MSDOSFS 51129152Sjoerg#include <sys/stat.h> 52129152Sjoerg#include <sys/sysctl.h> 5340782Snsouch#include <unistd.h> 5440782Snsouch#include <termios.h> 5540782Snsouch 56160372Simp/* Hack for rsaref package add, which displays interactive license. 5742442Snsouch * Used by package.c 58186833Snwhitehorn */ 59186833Snwhitehornint _interactiveHack; 60187457Snwhitehornint FixItMode = 0; 6140782Snsouch 6240782Snsouchstatic void create_termcap(void); 63129152Sjoergstatic void fixit_common(void); 6440782Snsouch 6540782Snsouch#define TERMCAP_FILE "/usr/share/misc/termcap" 6640782Snsouch 6740782Snsouchstatic void installConfigure(void); 6840782Snsouch 6940782SnsouchBoolean 7040782SnsouchcheckLabels(Boolean whinge, Chunk **rdev, Chunk **sdev, Chunk **udev, Chunk **vdev, Chunk **tdev, Chunk **hdev) 7140782Snsouch{ 7240782Snsouch Device **devs; 7340782Snsouch Boolean status; 7440782Snsouch Disk *disk; 7540782Snsouch Chunk *c1, *c2, *rootdev, *swapdev, *usrdev, *vardev, *tmpdev, *homedev; 7640782Snsouch int i; 7740782Snsouch 7840782Snsouch /* Don't allow whinging if noWarn is set */ 7940782Snsouch if (variable_get(VAR_NO_WARN)) 8040782Snsouch whinge = FALSE; 8140782Snsouch 8240782Snsouch status = TRUE; 8340782Snsouch if (rdev) 8442442Snsouch *rdev = NULL; 8540782Snsouch if (sdev) 8638774Snsouch *sdev = NULL; 8740782Snsouch if (udev) 8840782Snsouch *udev = NULL; 8938774Snsouch if (vdev) 9038774Snsouch *vdev = NULL; 9140782Snsouch if (tdev) 9238774Snsouch *tdev = NULL; 93129152Sjoerg if (hdev) 94129152Sjoerg *hdev = NULL; 95129152Sjoerg rootdev = swapdev = usrdev = vardev = tmpdev = homedev = NULL; 96167856Simp 97228257Sadrian /* We don't need to worry about root/usr/swap if we're already multiuser */ 98129152Sjoerg if (!RunningAsInit) 99167856Simp return status; 100181304Sjhb 101274641Sian devs = deviceFind(NULL, DEVICE_TYPE_DISK); 10240782Snsouch /* First verify that we have a root device */ 103228257Sadrian for (i = 0; devs[i]; i++) { 104228257Sadrian if (!devs[i]->enabled) 105228257Sadrian continue; 106228257Sadrian disk = (Disk *)devs[i]->private; 107228257Sadrian msgDebug("Scanning disk %s for root filesystem\n", disk->name); 10838774Snsouch if (!disk->chunks) 10942442Snsouch msgFatal("No chunk list found for %s!", disk->name); 11042442Snsouch for (c1 = disk->chunks->part; c1; c1 = c1->next) { 11142442Snsouch if (c1->type == freebsd) { 11242442Snsouch for (c2 = c1->part; c2; c2 = c2->next) { 11342442Snsouch if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) { 114129152Sjoerg if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/")) { 11540782Snsouch if (rootdev) { 11638774Snsouch if (whinge) 11740782Snsouch msgConfirm("WARNING: You have more than one root device set?!\n" 118129152Sjoerg "Using the first one found."); 11940782Snsouch continue; 12040782Snsouch } 12140782Snsouch else { 12240782Snsouch rootdev = c2; 12340782Snsouch if (isDebug()) 12442442Snsouch msgDebug("Found rootdev at %s!\n", rootdev->name); 125181304Sjhb } 126167856Simp } 12738774Snsouch else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/usr")) { 12838774Snsouch if (usrdev) { 12938774Snsouch if (whinge) 13093023Snsouch msgConfirm("WARNING: You have more than one /usr filesystem.\n" 13193023Snsouch "Using the first one found."); 13293023Snsouch continue; 13393023Snsouch } 134181304Sjhb else { 135160372Simp usrdev = c2; 13693023Snsouch if (isDebug()) 13793023Snsouch msgDebug("Found usrdev at %s!\n", usrdev->name); 138181304Sjhb } 13993023Snsouch } 14093023Snsouch else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/var")) { 14193023Snsouch if (vardev) { 14293023Snsouch if (whinge) 143167856Simp msgConfirm("WARNING: You have more than one /var filesystem.\n" 14493023Snsouch "Using the first one found."); 145167856Simp continue; 146167856Simp } 147160372Simp else { 148167856Simp vardev = c2; 149167856Simp if (isDebug()) 150167856Simp msgDebug("Found vardev at %s!\n", vardev->name); 151282674Sloos } 152167856Simp } else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/tmp")) { 153167856Simp if (tmpdev) { 154167856Simp if (whinge) 155167856Simp msgConfirm("WARNING: You have more than one /tmp filesystem.\n" 156167856Simp "Using the first one found."); 157167856Simp continue; 158167856Simp } 159167856Simp else { 160167856Simp tmpdev = c2; 161167856Simp if (isDebug()) 162282702Sloos msgDebug("Found tmpdev at %s!\n", tmpdev->name); 163167856Simp } 164167856Simp } else if (!strcmp(((PartInfo *)c2->private_data)->mountpoint, "/home")) { 165167856Simp if (homedev) { 166167856Simp if (whinge) 167167856Simp msgConfirm("WARNING: You have more than one /home filesystem.\n" 168167856Simp "Using the first one found."); 169167856Simp continue; 170167856Simp } 171167856Simp else { 17293023Snsouch homedev = c2; 17393023Snsouch if (isDebug()) 17493023Snsouch msgDebug("Found homedev at %s!\n", homedev->name); 175167856Simp } 176167856Simp } 177167856Simp } 178167856Simp } 179167856Simp } 180167856Simp } 181167856Simp } 182167856Simp 183167856Simp /* Now check for swap devices */ 184188461Simp for (i = 0; devs[i]; i++) { 185167856Simp if (!devs[i]->enabled) 186167856Simp continue; 187167856Simp disk = (Disk *)devs[i]->private; 188167856Simp msgDebug("Scanning disk %s for swap partitions\n", disk->name); 189167856Simp if (!disk->chunks) 190167856Simp msgFatal("No chunk list found for %s!", disk->name); 191167856Simp for (c1 = disk->chunks->part; c1; c1 = c1->next) { 192209800Snwhitehorn if (c1->type == freebsd) { 193167856Simp for (c2 = c1->part; c2; c2 = c2->next) { 194167856Simp if (c2->type == part && c2->subtype == FS_SWAP && !swapdev) { 195167856Simp swapdev = c2; 196167856Simp if (isDebug()) 197167856Simp msgDebug("Found swapdev at %s!\n", swapdev->name); 198167856Simp break; 199212413Savg } 200167856Simp } 201167856Simp } 202167856Simp } 203167856Simp } 204167856Simp 205167856Simp /* Copy our values over */ 206167856Simp if (rdev) 207167856Simp *rdev = rootdev; 208167856Simp if (sdev) 209167856Simp *sdev = swapdev; 210167856Simp if (udev) 211167856Simp *udev = usrdev; 212282674Sloos if (vdev) 213167856Simp *vdev = vardev; 214167856Simp if (tdev) 215167856Simp *tdev = tmpdev; 216167856Simp if (hdev) 217167856Simp *hdev = homedev; 218167856Simp 219167856Simp if (!rootdev && whinge) { 220167856Simp msgConfirm("No root device found - you must label a partition as /\n" 221282674Sloos "in the label editor."); 222167856Simp status = FALSE; 223167856Simp } 224167856Simp if (!swapdev && whinge) { 225167856Simp msgConfirm("No swap devices found - you must create at least one\n" 226167856Simp "swap partition."); 227282674Sloos status = FALSE; 228282674Sloos } 229282674Sloos return status; 230282674Sloos} 231282674Sloos 232167856Simpstatic int 233167856SimpinstallInitial(void) 234282674Sloos{ 235282674Sloos static Boolean alreadyDone = FALSE; 236282674Sloos int status = DITEM_SUCCESS; 237282674Sloos 238282674Sloos if (alreadyDone) 239282674Sloos return DITEM_SUCCESS; 240282674Sloos 241282674Sloos if (!variable_get(DISK_LABELLED)) { 242282674Sloos msgConfirm("You need to assign disk labels before you can proceed with\n" 24338774Snsouch "the installation."); 24438774Snsouch return DITEM_FAILURE; 24538774Snsouch } 246160372Simp /* If it's labelled, assume it's also partitioned */ 24738774Snsouch if (!variable_get(DISK_PARTITIONED)) 24838774Snsouch variable_set2(DISK_PARTITIONED, "yes", 0); 24938774Snsouch 25040782Snsouch /* If we refuse to proceed, bail. */ 25140782Snsouch dialog_clear_norefresh(); 25240782Snsouch if (!variable_get(VAR_NO_WARN)) { 253160372Simp if (msgYesNo( 25440782Snsouch "Last Chance! Are you SURE you want continue the installation?\n\n" 25540782Snsouch "If you're running this on a disk with data you wish to save\n" 25640782Snsouch "then WE STRONGLY ENCOURAGE YOU TO MAKE PROPER BACKUPS before\n" 25740782Snsouch "proceeding!\n\n" 25840782Snsouch "We can take no responsibility for lost disk contents!") != 0) 25940782Snsouch return DITEM_FAILURE; 260160372Simp } 26140782Snsouch 26240782Snsouch if (DITEM_STATUS(diskLabelCommit(NULL)) != DITEM_SUCCESS) { 26340782Snsouch msgConfirm("Couldn't make filesystems properly. Aborting."); 264274641Sian return DITEM_FAILURE; 265274641Sian } 266274641Sian 267274641Sian if (!copySelf()) { 268274641Sian msgConfirm("installInitial: Couldn't clone the boot floppy onto the\n" 269274641Sian "root file system. Aborting!"); 270274641Sian return DITEM_FAILURE; 271274641Sian } 272274641Sian 273274641Sian if (!Restarting && chroot("/mnt") == -1) { 274274641Sian msgConfirm("installInitial: Unable to chroot to %s - this is bad!", 275274641Sian "/mnt"); 276274641Sian return DITEM_FAILURE; 277274641Sian } 278274641Sian 279274641Sian chdir("/"); 280274641Sian variable_set2(RUNNING_ON_ROOT, "yes", 0); 281274641Sian 282274641Sian /* Configure various files in /etc */ 283274641Sian if (DITEM_STATUS(configResolv(NULL)) == DITEM_FAILURE) 284274641Sian status = DITEM_FAILURE; 285274641Sian if (DITEM_STATUS(configFstab(NULL)) == DITEM_FAILURE) 286274641Sian status = DITEM_FAILURE; 287274641Sian 288274641Sian /* stick a helpful shell over on the 4th VTY */ 289274641Sian if (!variable_get(VAR_NO_HOLOSHELL)) 290274641Sian systemCreateHoloshell(); 291274641Sian 292274641Sian alreadyDone = TRUE; 293274641Sian return status; 294274641Sian} 295274641Sian 296274641Sianint 297274641SianinstallFixitHoloShell(dialogMenuItem *self) 298274641Sian{ 299274641Sian FixItMode = 1; 300274641Sian systemCreateHoloshell(); 301274641Sian return DITEM_SUCCESS; 302274641Sian FixItMode = 0; 303274641Sian} 304274641Sian 305274641Sianint 306274641SianinstallFixitCDROM(dialogMenuItem *self) 307274641Sian{ 308274641Sian struct stat sb; 309167856Simp 310282668Sloos if (!RunningAsInit) 311282668Sloos return DITEM_SUCCESS; 312282668Sloos 313282668Sloos variable_set2(SYSTEM_STATE, "fixit", 0); 314167856Simp (void)unlink("/mnt2"); 315282668Sloos (void)rmdir("/mnt2"); 316282674Sloos 317282674Sloos while (1) { 318282674Sloos msgConfirm("Please insert a FreeBSD live filesystem CD/DVD and press return"); 319282674Sloos if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS 320282674Sloos || !DEVICE_INIT(mediaDevice)) { 321282702Sloos /* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */ 322282674Sloos mediaClose(); 323282702Sloos if (msgYesNo("Unable to mount the disc - do you want to try again?") != 0) 324282702Sloos return DITEM_FAILURE; 325282674Sloos } 326282668Sloos else 327282668Sloos break; 328167856Simp } 329167856Simp 330167856Simp /* Since the fixit code expects everything to be in /mnt2, and the CDROM mounting stuff /dist, do 331167856Simp * a little kludge dance here.. 332167856Simp */ 333167856Simp if (symlink("/dist", "/mnt2")) { 334167856Simp msgConfirm("Unable to symlink /mnt2 to the disc mount point. Please report this\n" 335167856Simp "unexpected failure to freebsd-bugs@FreeBSD.org."); 336274641Sian return DITEM_FAILURE; 337167856Simp } 338227843Smarius 339167856Simp /* 340167856Simp * If /tmp points to /mnt2/tmp from a previous fixit floppy session, it's 341167856Simp * not very good for us if we point it to the CDROM now. Rather make it 342167856Simp * a directory in the root MFS then. Experienced admins will still be 343167856Simp * able to mount their disk's /tmp over this if they need. 344167856Simp */ 345167856Simp if (lstat("/tmp", &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFLNK) 346167856Simp (void)unlink("/tmp"); 347167856Simp Mkdir("/tmp"); 348167856Simp 34993023Snsouch /* 350187261Snwhitehorn * Since setuid binaries ignore LD_LIBRARY_PATH, we indeed need the 351 * ld.so.hints file. Fortunately, it's fairly small (~ 3 KB). 352 */ 353 if (!file_readable("/var/run/ld.so.hints")) { 354 Mkdir("/var/run"); 355 if (vsystem("/mnt2/sbin/ldconfig -s /mnt2/usr/lib")) { 356 msgConfirm("Warning: ldconfig could not create the ld.so hints file.\n" 357 "Dynamic executables from the disc likely won't work."); 358 } 359 } 360 361 /* Yet more iggly hardcoded pathnames. */ 362 Mkdir("/usr/libexec"); 363 if (!file_readable("/usr/libexec/ld.so") && file_readable("/mnt2/usr/libexec/ld.so")) { 364 if (symlink("/mnt2/usr/libexec/ld.so", "/usr/libexec/ld.so")) 365 msgDebug("Couldn't link to ld.so - not necessarily a problem for ELF\n"); 366 } 367 if (!file_readable("/usr/libexec/ld-elf.so.1")) { 368 if (symlink("/mnt2/usr/libexec/ld-elf.so.1", "/usr/libexec/ld-elf.so.1")) { 369 msgConfirm("Warning: could not create the symlink for ld-elf.so.1\n" 370 "Dynamic executables from the disc likely won't work."); 371 } 372 } 373 /* optional nicety */ 374 if (!file_readable("/usr/bin/vi")) 375 symlink("/mnt2/usr/bin/vi", "/usr/bin/vi"); 376 fixit_common(); 377 mediaClose(); 378 msgConfirm("Please remove the FreeBSD fixit CDROM/DVD now."); 379 return DITEM_SUCCESS; 380} 381 382int 383installFixitFloppy(dialogMenuItem *self) 384{ 385 struct ufs_args args; 386 extern char *distWanted; 387 388 if (!RunningAsInit) 389 return DITEM_SUCCESS; 390 391 /* Try to open the floppy drive */ 392 if (DITEM_STATUS(mediaSetFloppy(NULL)) == DITEM_FAILURE || !mediaDevice) { 393 msgConfirm("Unable to set media device to floppy."); 394 mediaClose(); 395 return DITEM_FAILURE; 396 } 397 398 memset(&args, 0, sizeof(args)); 399 args.fspec = mediaDevice->devname; 400 mediaDevice->private = "/mnt2"; 401 distWanted = NULL; 402 Mkdir("/mnt2"); 403 404 variable_set2(SYSTEM_STATE, "fixit", 0); 405 406 while (1) { 407 if (!DEVICE_INIT(mediaDevice)) { 408 if (msgYesNo("The attempt to mount the fixit floppy failed, bad floppy\n" 409 "or unclean filesystem. Do you want to try again?")) 410 return DITEM_FAILURE; 411 } 412 else 413 break; 414 } 415 if (!directory_exists("/tmp")) 416 (void)symlink("/mnt2/tmp", "/tmp"); 417 fixit_common(); 418 mediaClose(); 419 msgConfirm("Please remove the fixit floppy now."); 420 return DITEM_SUCCESS; 421} 422 423/* 424 * The common code for both fixit variants. 425 */ 426static void 427fixit_common(void) 428{ 429 pid_t child; 430 int waitstatus; 431 432 if (!directory_exists("/var/tmp/vi.recover")) { 433 if (DITEM_STATUS(Mkdir("/var/tmp/vi.recover")) != DITEM_SUCCESS) { 434 msgConfirm("Warning: Was unable to create a /var/tmp/vi.recover directory.\n" 435 "vi will kvetch and moan about it as a result but should still\n" 436 "be essentially usable."); 437 } 438 } 439 if (!directory_exists("/bin")) 440 (void)Mkdir("/bin"); 441 (void)symlink("/stand/sh", "/bin/sh"); 442 /* Link the /etc/ files */ 443 if (DITEM_STATUS(Mkdir("/etc")) != DITEM_SUCCESS) 444 msgConfirm("Unable to create an /etc directory! Things are weird on this floppy.."); 445 else if ((symlink("/mnt2/etc/spwd.db", "/etc/spwd.db") == -1 && errno != EEXIST) || 446 (symlink("/mnt2/etc/protocols", "/etc/protocols") == -1 && errno != EEXIST) || 447 (symlink("/mnt2/etc/group", "/etc/group") == -1 && errno != EEXIST) || 448 (symlink("/mnt2/etc/services", "/etc/services") == -1 && errno != EEXIST)) 449 msgConfirm("Couldn't symlink the /etc/ files! I'm not sure I like this.."); 450 if (!file_readable(TERMCAP_FILE)) 451 create_termcap(); 452 if (strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0) 453 systemSuspendDialog(); /* must be before the fork() */ 454 if (!(child = fork())) { 455 int i, fd; 456 struct termios foo; 457 extern int login_tty(int); 458 459 ioctl(0, TIOCNOTTY, NULL); 460 for (i = getdtablesize(); i >= 0; --i) 461 close(i); 462 463 if (strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0) 464 fd = open("/dev/console", O_RDWR); 465 else 466 fd = open("/dev/ttyv3", O_RDWR); 467 ioctl(0, TIOCSCTTY, &fd); 468 dup2(0, 1); 469 dup2(0, 2); 470 DebugFD = 2; 471 if (login_tty(fd) == -1) 472 msgDebug("fixit: I can't set the controlling terminal.\n"); 473 474 signal(SIGTTOU, SIG_IGN); 475 if (tcgetattr(0, &foo) != -1) { 476 foo.c_cc[VERASE] = '\010'; 477 if (tcsetattr(0, TCSANOW, &foo) == -1) 478 msgDebug("fixit shell: Unable to set erase character.\n"); 479 } 480 else 481 msgDebug("fixit shell: Unable to get terminal attributes!\n"); 482 setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/stand:" 483 "/mnt2/stand:/mnt2/bin:/mnt2/sbin:/mnt2/usr/bin:/mnt2/usr/sbin", 1); 484 if (strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0) { 485 printf("Waiting for fixit shell to exit.\n" 486 "When you are done, type ``exit'' to exit\n" 487 "the fixit shell and be returned here.\n\n"); 488 fflush(stdout); 489 } 490 491 /* use the .profile from the fixit medium */ 492 setenv("HOME", "/mnt2", 1); 493 chdir("/mnt2"); 494 execlp("sh", "-sh", (char *)0); 495 msgDebug("fixit shell: Failed to execute shell!\n"); 496 _exit(1);; 497 } 498 else { 499 if (strcmp(variable_get(VAR_FIXIT_TTY), "standard") == 0) { 500 dialog_clear_norefresh(); 501 msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n" 502 "typing ALT-F4. When you are done, type ``exit'' to exit\n" 503 "the fixit shell and be returned here\n."); 504 } 505 (void)waitpid(child, &waitstatus, 0); 506 if (strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0) 507 systemResumeDialog(); 508 } 509 dialog_clear(); 510} 511 512 513int 514installExpress(dialogMenuItem *self) 515{ 516 int i; 517 518 dialog_clear_norefresh(); 519 variable_set2(SYSTEM_STATE, "express", 0); 520#ifdef WITH_SLICES 521 if (DITEM_STATUS((i = diskPartitionEditor(self))) == DITEM_FAILURE) 522 return i; 523#endif 524 525 if (DITEM_STATUS((i = diskLabelEditor(self))) == DITEM_FAILURE) 526 return i; 527 528 if (DITEM_STATUS((i = installCommit(self))) == DITEM_SUCCESS) { 529 i |= DITEM_LEAVE_MENU; 530 /* Set default security level */ 531 configSecurityModerate(NULL); 532 533 /* Give user the option of one last configuration spree */ 534 installConfigure(); 535 } 536 return i; 537} 538 539/* Standard mode installation */ 540int 541installStandard(dialogMenuItem *self) 542{ 543 int i, tries = 0; 544 Device **devs; 545 546 variable_set2(SYSTEM_STATE, "standard", 0); 547 dialog_clear_norefresh(); 548#ifdef WITH_SLICES 549 msgConfirm("In the next menu, you will need to set up a DOS-style (\"fdisk\") partitioning\n" 550 "scheme for your hard disk. If you simply wish to devote all disk space\n" 551 "to FreeBSD (overwriting anything else that might be on the disk(s) selected)\n" 552 "then use the (A)ll command to select the default partitioning scheme followed\n" 553 "by a (Q)uit. If you wish to allocate only free space to FreeBSD, move to a\n" 554 "partition marked \"unused\" and use the (C)reate command."); 555 556nodisks: 557 if (DITEM_STATUS(diskPartitionEditor(self)) == DITEM_FAILURE) 558 return DITEM_FAILURE; 559 560 if (diskGetSelectCount(&devs) <= 0 && tries < 3) { 561 msgConfirm("You need to select some disks to operate on! Be sure to use SPACE\n" 562 "instead of RETURN in the disk selection menu when selecting a disk."); 563 ++tries; 564 goto nodisks; 565 } 566 567 msgConfirm("Now you need to create BSD partitions inside of the fdisk partition(s)\n" 568 "just created. If you have a reasonable amount of disk space (200MB or more)\n" 569 "and don't have any special requirements, simply use the (A)uto command to\n" 570 "allocate space automatically. If you have more specific needs or just don't\n" 571 "care for the layout chosen by (A)uto, press F1 for more information on\n" 572 "manual layout."); 573#else 574 msgConfirm("First you need to create BSD partitions on the disk which you are\n" 575 "installing to. If you have a reasonable amount of disk space (200MB or more)\n" 576 "and don't have any special requirements, simply use the (A)uto command to\n" 577 "allocate space automatically. If you have more specific needs or just don't\n" 578 "care for the layout chosen by (A)uto, press F1 for more information on\n" 579 "manual layout."); 580#endif 581 582 if (DITEM_STATUS(diskLabelEditor(self)) == DITEM_FAILURE) 583 return DITEM_FAILURE; 584 585 if (DITEM_STATUS((i = installCommit(self))) == DITEM_FAILURE) { 586 dialog_clear(); 587 msgConfirm("Installation completed with some errors. You may wish to\n" 588 "scroll through the debugging messages on VTY1 with the\n" 589 "scroll-lock feature. You can also choose \"No\" at the next\n" 590 "prompt and go back into the installation menus to try and retry\n" 591 "whichever operations have failed."); 592 return i; 593 594 } 595 else { 596 dialog_clear(); 597 msgConfirm("Congratulations! You now have FreeBSD installed on your system.\n\n" 598 "We will now move on to the final configuration questions.\n" 599 "For any option you do not wish to configure, simply select\n" 600 "No.\n\n" 601 "If you wish to re-enter this utility after the system is up, you\n" 602 "may do so by typing: /usr/sbin/sysinstall."); 603 } 604 if (mediaDevice->type != DEVICE_TYPE_FTP && mediaDevice->type != DEVICE_TYPE_NFS) { 605 if (!msgYesNo("Would you like to configure any Ethernet or SLIP/PPP network devices?")) { 606 Device *tmp = tcpDeviceSelect(); 607 608 if (tmp && !((DevInfo *)tmp->private)->use_dhcp && !msgYesNo("Would you like to bring the %s interface up right now?", tmp->name)) 609 if (!DEVICE_INIT(tmp)) 610 msgConfirm("Initialization of %s device failed.", tmp->name); 611 } 612 dialog_clear_norefresh(); 613 } 614 615 if (!msgNoYes("Do you want this machine to function as a network gateway?")) 616 variable_set2("gateway_enable", "YES", 1); 617 618 dialog_clear_norefresh(); 619 if (!msgNoYes("Do you want to configure inetd and the network services that it provides?")) 620 configInetd(self); 621 622 dialog_clear_norefresh(); 623 if (!msgNoYes("Do you want to have anonymous FTP access to this machine?")) 624 configAnonFTP(self); 625 626 dialog_clear_norefresh(); 627 if (!msgNoYes("Do you want to configure this machine as an NFS server?")) 628 configNFSServer(self); 629 630 dialog_clear_norefresh(); 631 if (!msgNoYes("Do you want to configure this machine as an NFS client?")) 632 variable_set2("nfs_client_enable", "YES", 1); 633 634 if (!msgNoYes("Do you want to select a default security profile for\n" 635 "this host (select No for \"moderate\" security)?")) 636 configSecurityProfile(self); 637 else 638 configSecurityModerate(self); 639 640#ifdef WITH_SYSCONS 641 dialog_clear_norefresh(); 642 if (!msgNoYes("Would you like to customize your system console settings?")) 643 dmenuOpenSimple(&MenuSyscons, FALSE); 644#endif 645 646 dialog_clear_norefresh(); 647 if (!msgYesNo("Would you like to set this machine's time zone now?")) 648 systemExecute("tzsetup"); 649 650#ifdef WITH_LINUX 651 dialog_clear_norefresh(); 652 if (!msgYesNo("Would you like to enable Linux binary compatibility?")) 653 (void)configLinux(self); 654#endif 655 656#ifdef __alpha__ 657 dialog_clear_norefresh(); 658 if (!msgYesNo("Would you like to enable OSF/1 binary compatibility?")) 659 (void)configOSF1(self); 660#endif 661 662#ifdef WITH_MICE 663 dialog_clear_norefresh(); 664 if (!msgNoYes("Does this system have a non-USB mouse attached to it?")) 665 dmenuOpenSimple(&MenuMouse, FALSE); 666#endif 667 668 /* Now would be a good time to checkpoint the configuration data */ 669 configRC_conf(); 670 sync(); 671 672 if (directory_exists("/usr/X11R6")) { 673 dialog_clear_norefresh(); 674 if (!msgYesNo("Would you like to configure your X server at this time?")) 675 (void)configXSetup(self); 676 } 677 678 dialog_clear_norefresh(); 679 if (!msgYesNo("The FreeBSD package collection is a collection of thousands of ready-to-run\n" 680 "applications, from text editors to games to WEB servers and more. Would you\n" 681 "like to browse the collection now?")) { 682 (void)configPackages(self); 683 } 684 685 if (!msgYesNo("Would you like to add any initial user accounts to the system?\n" 686 "Adding at least one account for yourself at this stage is suggested\n" 687 "since working as the \"root\" user is dangerous (it is easy to do\n" 688 "things which adversely affect the entire system).")) 689 (void)configUsers(self); 690 691 msgConfirm("Now you must set the system manager's password.\n" 692 "This is the password you'll use to log in as \"root\"."); 693 if (!systemExecute("passwd root")) 694 variable_set2("root_password", "YES", 0); 695 696 /* XXX Put whatever other nice configuration questions you'd like to ask the user here XXX */ 697 698 /* Give user the option of one last configuration spree */ 699 dialog_clear_norefresh(); 700 installConfigure(); 701 return DITEM_LEAVE_MENU; 702} 703 704/* The version of commit we call from the Install Custom menu */ 705int 706installCustomCommit(dialogMenuItem *self) 707{ 708 int i; 709 710 i = installCommit(self); 711 if (DITEM_STATUS(i) == DITEM_SUCCESS) { 712 /* Set default security level */ 713 configSecurityModerate(NULL); 714 715 /* Give user the option of one last configuration spree */ 716 installConfigure(); 717 return i; 718 } 719 else 720 msgConfirm("The commit operation completed with errors. Not\n" 721 "updating /etc files."); 722 return i; 723} 724 725/* 726 * What happens when we finally decide to going ahead with the installation. 727 * 728 * This is broken into multiple stages so that the user can do a full 729 * installation but come back here again to load more distributions, 730 * perhaps from a different media type. This would allow, for 731 * example, the user to load the majority of the system from CDROM and 732 * then use ftp to load just the CRYPTO dist. 733 */ 734int 735installCommit(dialogMenuItem *self) 736{ 737 int i; 738 char *str; 739 740 dialog_clear_norefresh(); 741 if (!Dists) 742 distConfig(NULL); 743 744 if (!Dists) { 745 (void)dmenuOpenSimple(&MenuDistributions, FALSE); 746 /* select reasonable defaults if necessary */ 747 if (!Dists) 748 Dists = _DIST_USER; 749 } 750 751 if (!mediaVerify()) 752 return DITEM_FAILURE; 753 754 str = variable_get(SYSTEM_STATE); 755 if (isDebug()) 756 msgDebug("installCommit: System state is `%s'\n", str); 757 758 /* Installation stuff we wouldn't do to a running system */ 759 if (RunningAsInit && DITEM_STATUS((i = installInitial())) == DITEM_FAILURE) 760 return i; 761 762try_media: 763 if (!DEVICE_INIT(mediaDevice)) { 764 if (!msgYesNo("Unable to initialize selected media. Would you like to\n" 765 "adjust your media configuration and try again?")) { 766 mediaDevice = NULL; 767 if (!mediaVerify()) 768 return DITEM_FAILURE; 769 else 770 goto try_media; 771 } 772 else 773 return DITEM_FAILURE; 774 } 775 776 /* Now go get it all */ 777 i = distExtractAll(self); 778 779 /* When running as init, *now* it's safe to grab the rc.foo vars */ 780 installEnvironment(); 781 782 variable_set2(SYSTEM_STATE, DITEM_STATUS(i) == DITEM_FAILURE ? "error-install" : "full-install", 0); 783 784 return i; 785} 786 787static void 788installConfigure(void) 789{ 790 /* Final menu of last resort */ 791 if (!msgNoYes("Visit the general configuration menu for a chance to set\n" 792 "any last options?")) 793 dmenuOpenSimple(&MenuConfigure, FALSE); 794 configRC_conf(); 795 sync(); 796} 797 798int 799installFixupBin(dialogMenuItem *self) 800{ 801 Device **devs; 802 char *cp; 803 int i; 804 FILE *fp; 805 int kstat = 1; 806 807 /* All of this is done only as init, just to be safe */ 808 if (RunningAsInit) { 809#ifdef __i386__ 810 if ((fp = fopen("/boot/loader.conf", "a")) != NULL) { 811 if (!kstat || !OnVTY) 812 fprintf(fp, "# -- sysinstall generated deltas -- #\n"); 813 if (!kstat) 814 fprintf(fp, "userconfig_script_load=\"YES\"\n"); 815 if (!OnVTY) 816 fprintf(fp, "console=\"comconsole\"\n"); 817 fclose(fp); 818 } 819#endif 820 821 /* BOGON #2: We leave /etc in a bad state */ 822 chmod("/etc", 0755); 823 824 /* BOGON #3: No /var/db/mountdtab complains */ 825 Mkdir("/var/db"); 826 creat("/var/db/mountdtab", 0644); 827 828 /* BOGON #4: /compat created by default in root fs */ 829 Mkdir("/usr/compat"); 830 vsystem("ln -s usr/compat /compat"); 831 832 /* BOGON #5: aliases database not build for bin */ 833 vsystem("newaliases"); 834 835 /* Now run all the mtree stuff to fix things up */ 836 vsystem("mtree -deU -f /etc/mtree/BSD.root.dist -p /"); 837 vsystem("mtree -deU -f /etc/mtree/BSD.var.dist -p /var"); 838 vsystem("mtree -deU -f /etc/mtree/BSD.usr.dist -p /usr"); 839 840 /* Do all the last ugly work-arounds here */ 841 } 842 return DITEM_SUCCESS | DITEM_RESTORE; 843} 844 845int 846installPackage(dialogMenuItem *self, char *desc, char *package) 847{ 848 WINDOW *w = savescr(); 849 int i; 850 851 dialog_clear_norefresh(); 852 msgNotify("Installing %s package...", desc); 853 i = package_add(package); 854 restorescr(w); 855 return i; 856} 857 858/* Fix side-effects from the the XFree86 installation */ 859int 860installFixupXFree(dialogMenuItem *self) 861{ 862 /* BOGON #1: XFree86 requires various specialized fixups */ 863 if (directory_exists("/usr/X11R6")) { 864 dialog_clear_norefresh(); 865 msgNotify("Fixing permissions in XFree86 tree.."); 866 vsystem("chmod -R a+r /usr/X11R6"); 867 vsystem("find /usr/X11R6 -type d | xargs chmod a+x"); 868 869#ifndef X_AS_PKG 870 /* Also do bogus minimal package registration so ports don't whine */ 871 if (file_readable("/usr/X11R6/lib/X11/pkgreg.tar.gz")) { 872 dialog_clear_norefresh(); 873 msgNotify("Installing package metainfo.."); 874 vsystem("tar xpzf /usr/X11R6/lib/X11/pkgreg.tar.gz -C / && rm /usr/X11R6/lib/X11/pkgreg.tar.gz"); 875 } 876#endif 877 } 878 return DITEM_SUCCESS | DITEM_RESTORE; 879} 880 881/* Go newfs and/or mount all the filesystems we've been asked to */ 882int 883installFilesystems(dialogMenuItem *self) 884{ 885 int i; 886 Disk *disk; 887 Chunk *c1, *c2, *rootdev, *swapdev; 888 Device **devs; 889 PartInfo *root; 890 char dname[80]; 891 Boolean upgrade = FALSE; 892#if defined(__ia64__) 893 char efi_bootdir[FILENAME_MAX]; 894#endif 895 896 /* If we've already done this, bail out */ 897 if (!variable_cmp(DISK_LABELLED, "written")) 898 return DITEM_SUCCESS; 899 900 upgrade = !variable_cmp(SYSTEM_STATE, "upgrade"); 901 if (!checkLabels(TRUE, &rootdev, &swapdev, NULL, NULL, NULL, NULL)) 902 return DITEM_FAILURE; 903 904 if (rootdev) 905 root = (PartInfo *)rootdev->private_data; 906 else 907 root = NULL; 908 909 command_clear(); 910 if (swapdev && RunningAsInit) { 911 /* As the very first thing, try to get ourselves some swap space */ 912 sprintf(dname, "/dev/%s", swapdev->name); 913 if (!Fake && !file_readable(dname)) { 914 msgConfirm("Unable to find device node for %s in /dev!\n" 915 "The creation of filesystems will be aborted.", dname); 916 return DITEM_FAILURE; 917 } 918 919 if (!Fake) { 920 if (!swapon(dname)) { 921 dialog_clear_norefresh(); 922 msgNotify("Added %s as initial swap device", dname); 923 } 924 else { 925 msgConfirm("WARNING! Unable to swap to %s: %s\n" 926 "This may cause the installation to fail at some point\n" 927 "if you don't have a lot of memory.", dname, strerror(errno)); 928 } 929 } 930 } 931 932 if (rootdev && RunningAsInit) { 933 /* Next, create and/or mount the root device */ 934 sprintf(dname, "/dev/%s", rootdev->name); 935 if (!Fake && !file_readable(dname)) { 936 msgConfirm("Unable to make device node for %s in /dev!\n" 937 "The creation of filesystems will be aborted.", dname); 938 return DITEM_FAILURE | DITEM_RESTORE; 939 } 940 if (strcmp(root->mountpoint, "/")) 941 msgConfirm("Warning: %s is marked as a root partition but is mounted on %s", rootdev->name, root->mountpoint); 942 943 if (root->newfs && (!upgrade || !msgNoYes("You are upgrading - are you SURE you want to newfs the root partition?"))) { 944 int i; 945 946 dialog_clear_norefresh(); 947 msgNotify("Making a new root filesystem on %s", dname); 948 i = vsystem("%s %s", root->newfs_cmd, dname); 949 if (i) { 950 msgConfirm("Unable to make new root filesystem on %s!\n" 951 "Command returned status %d", dname, i); 952 return DITEM_FAILURE | DITEM_RESTORE; 953 } 954 } 955 else { 956 if (!upgrade) { 957 msgConfirm("Warning: Using existing root partition. It will be assumed\n" 958 "that you have the appropriate device entries already in /dev."); 959 } 960 dialog_clear_norefresh(); 961 msgNotify("Checking integrity of existing %s filesystem.", dname); 962 i = vsystem("fsck_ffs -y %s", dname); 963 if (i) 964 msgConfirm("Warning: fsck returned status of %d for %s.\n" 965 "This partition may be unsafe to use.", i, dname); 966 } 967 if (root->soft) { 968 i = vsystem("tunefs -n enable %s", dname); 969 if (i) 970 msgConfirm("Warning: Unable to enable softupdates for root filesystem on %s", dname); 971 } 972 973 /* Switch to block device */ 974 sprintf(dname, "/dev/%s", rootdev->name); 975 if (Mount("/mnt", dname)) { 976 msgConfirm("Unable to mount the root file system on %s! Giving up.", dname); 977 return DITEM_FAILURE | DITEM_RESTORE; 978 } 979 980 /* Mount devfs for other partitions to mount */ 981 Mkdir("/mnt/dev"); 982 if (!Fake) { 983 struct iovec iov[4]; 984 985 iov[0].iov_base = "fstype"; 986 iov[0].iov_len = strlen(iov[0].iov_base) + 1; 987 iov[1].iov_base = "devfs"; 988 iov[1].iov_len = strlen(iov[1].iov_base) + 1; 989 iov[2].iov_base = "fspath"; 990 iov[2].iov_len = strlen(iov[2].iov_base) + 1; 991 iov[3].iov_base = "/mnt/dev"; 992 iov[3].iov_len = strlen(iov[3].iov_base) + 1; 993 i = nmount(iov, 4, 0); 994 995 if (i) { 996 dialog_clear_norefresh(); 997 msgConfirm("Unable to mount DEVFS (error %d)", errno); 998 return DITEM_FAILURE | DITEM_RESTORE; 999 } 1000 } 1001 } 1002 1003 /* Now buzz through the rest of the partitions and mount them too */ 1004 devs = deviceFind(NULL, DEVICE_TYPE_DISK); 1005 for (i = 0; devs[i]; i++) { 1006 if (!devs[i]->enabled) 1007 continue; 1008 1009 disk = (Disk *)devs[i]->private; 1010 if (!disk->chunks) { 1011 msgConfirm("No chunk list found for %s!", disk->name); 1012 return DITEM_FAILURE | DITEM_RESTORE; 1013 } 1014 for (c1 = disk->chunks->part; c1; c1 = c1->next) { 1015 if (c1->type == freebsd) { 1016 for (c2 = c1->part; c2; c2 = c2->next) { 1017 if (c2->type == part && c2->subtype != FS_SWAP && c2->private_data) { 1018 PartInfo *tmp = (PartInfo *)c2->private_data; 1019 1020 /* Already did root */ 1021 if (c2 == rootdev) 1022 continue; 1023 1024 if (tmp->newfs && (!upgrade || !msgNoYes("You are upgrading - are you SURE you want to newfs /dev/%s?", c2->name))) 1025 command_shell_add(tmp->mountpoint, "%s %s/dev/%s", tmp->newfs_cmd, RunningAsInit ? "/mnt" : "", c2->name); 1026 else 1027 command_shell_add(tmp->mountpoint, "fsck_ffs -y %s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name); 1028 if (tmp->soft) 1029 command_shell_add(tmp->mountpoint, "tunefs -n enable %s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name); 1030 command_func_add(tmp->mountpoint, Mount, c2->name); 1031 } 1032 else if (c2->type == part && c2->subtype == FS_SWAP) { 1033 char fname[80]; 1034 int i; 1035 1036 if (c2 == swapdev) 1037 continue; 1038 sprintf(fname, "%s/dev/%s", RunningAsInit ? "/mnt" : "", c2->name); 1039 i = (Fake || swapon(fname)); 1040 if (!i) { 1041 dialog_clear_norefresh(); 1042 msgNotify("Added %s as an additional swap device", fname); 1043 } 1044 else { 1045 msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno)); 1046 } 1047 } 1048 } 1049 } 1050 else if (c1->type == fat && c1->private_data && (root->newfs || upgrade)) { 1051 char name[FILENAME_MAX]; 1052 1053 sprintf(name, "%s/%s", RunningAsInit ? "/mnt" : "", ((PartInfo *)c1->private_data)->mountpoint); 1054 Mkdir(name); 1055 } 1056#if defined(__ia64__) 1057 else if (c1->type == efi && c1->private_data) { 1058 char bootdir[FILENAME_MAX]; 1059 PartInfo *pi = (PartInfo *)c1->private_data; 1060 char *p; 1061 1062 if (pi->newfs && (!upgrade || !msgNoYes("You are upgrading - are you SURE you want to newfs /dev/%s?", c1->name))) 1063 command_shell_add(pi->mountpoint, "%s %s/dev/%s", pi->newfs_cmd, RunningAsInit ? "/mnt" : "", c1->name); 1064 1065 command_func_add(pi->mountpoint, Mount_msdosfs, c1->name); 1066 1067 /* 1068 * Create a directory boot on the EFI filesystem and create a 1069 * link boot on the root filesystem pointing to the one on the 1070 * EFI filesystem. That way, we install the loader, kernel 1071 * and modules on the EFI filesystem. 1072 */ 1073 sprintf(bootdir, "%s", RunningAsInit ? "/mnt" : ""); 1074 sprintf(efi_bootdir, "%s/%s", bootdir, pi->mountpoint); 1075 strcat(bootdir, "/boot"); 1076 strcat(efi_bootdir, "/boot"); 1077 command_func_add(pi->mountpoint, Mkdir_command, efi_bootdir); 1078 1079 /* Make a relative link. */ 1080 p = &efi_bootdir[(RunningAsInit) ? 4 : 0]; 1081 while (*p == '/') 1082 p++; 1083 symlink(p, bootdir); 1084 } 1085#endif 1086 } 1087 } 1088 1089 command_sort(); 1090 command_execute(); 1091 dialog_clear_norefresh(); 1092 return DITEM_SUCCESS | DITEM_RESTORE; 1093} 1094 1095static char * 1096getRelname(void) 1097{ 1098 static char buf[64]; 1099 size_t sz = (sizeof buf) - 1; 1100 1101 if (sysctlbyname("kern.osrelease", buf, &sz, NULL, 0) != -1) { 1102 buf[sz] = '\0'; 1103 return buf; 1104 } 1105 else 1106 return "<unknown>"; 1107} 1108 1109/* Initialize various user-settable values to their defaults */ 1110int 1111installVarDefaults(dialogMenuItem *self) 1112{ 1113 char *cp; 1114 1115 /* Set default startup options */ 1116 variable_set2(VAR_RELNAME, getRelname(), 0); 1117 variable_set2(VAR_CPIO_VERBOSITY, "high", 0); 1118 variable_set2(VAR_TAPE_BLOCKSIZE, DEFAULT_TAPE_BLOCKSIZE, 0); 1119 variable_set2(VAR_INSTALL_ROOT, "/", 0); 1120 variable_set2(VAR_INSTALL_CFG, "install.cfg", 0); 1121 cp = getenv("EDITOR"); 1122 if (!cp) 1123 cp = "/usr/bin/ee"; 1124 variable_set2(VAR_EDITOR, cp, 0); 1125 variable_set2(VAR_FTP_USER, "ftp", 0); 1126 variable_set2(VAR_BROWSER_PACKAGE, "links", 0); 1127 variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/links", 0); 1128 variable_set2(VAR_FTP_STATE, "passive", 0); 1129 variable_set2(VAR_NFS_SECURE, "NO", -1); 1130 if (OnVTY) 1131 variable_set2(VAR_FIXIT_TTY, "standard", 0); 1132 else 1133 variable_set2(VAR_FIXIT_TTY, "serial", 0); 1134 variable_set2(VAR_PKG_TMPDIR, "/var/tmp", 0); 1135 variable_set2(VAR_MEDIA_TIMEOUT, itoa(MEDIA_TIMEOUT), 0); 1136 if (getpid() != 1) 1137 variable_set2(SYSTEM_STATE, "update", 0); 1138 else 1139 variable_set2(SYSTEM_STATE, "init", 0); 1140 variable_set2(VAR_NEWFS_ARGS, "-b 16384 -f 2048", 0); 1141 variable_set2(VAR_CONSTERM, "NO", 0); 1142 return DITEM_SUCCESS; 1143} 1144 1145/* Load the environment up from various system configuration files */ 1146void 1147installEnvironment(void) 1148{ 1149 configEnvironmentRC_conf(); 1150 if (file_readable("/etc/resolv.conf")) 1151 configEnvironmentResolv("/etc/resolv.conf"); 1152} 1153 1154/* Copy the boot floppy contents into /stand */ 1155Boolean 1156copySelf(void) 1157{ 1158 int i; 1159 1160 if (file_readable("/boot.help")) 1161 vsystem("cp /boot.help /mnt"); 1162 msgWeHaveOutput("Copying the boot floppy to /stand on root filesystem"); 1163 i = vsystem("find -x /stand | cpio %s -pdum /mnt", cpioVerbosity()); 1164 if (i) { 1165 msgConfirm("Copy returned error status of %d!", i); 1166 return FALSE; 1167 } 1168 1169 /* Copy the /etc files into their rightful place */ 1170 if (vsystem("cd /mnt/stand; find etc | cpio %s -pdum /mnt", cpioVerbosity())) { 1171 msgConfirm("Couldn't copy up the /etc files!"); 1172 return TRUE; 1173 } 1174 return TRUE; 1175} 1176 1177static void 1178create_termcap(void) 1179{ 1180 FILE *fp; 1181 1182 const char *caps[] = { 1183 termcap_vt100, termcap_cons25, termcap_cons25_m, termcap_cons25r, 1184 termcap_cons25r_m, termcap_cons25l1, termcap_cons25l1_m, 1185 termcap_xterm, NULL, 1186 }; 1187 const char **cp; 1188 1189 if (!file_readable(TERMCAP_FILE)) { 1190 Mkdir("/usr/share/misc"); 1191 fp = fopen(TERMCAP_FILE, "w"); 1192 if (!fp) { 1193 msgConfirm("Unable to initialize termcap file. Some screen-oriented\nutilities may not work."); 1194 return; 1195 } 1196 cp = caps; 1197 while (*cp) 1198 fprintf(fp, "%s\n", *(cp++)); 1199 fclose(fp); 1200 } 1201} 1202