summaryrefslogtreecommitdiffstats
path: root/release/sysinstall
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-12-29 05:51:40 +0000
committerjkh <jkh@FreeBSD.org>1996-12-29 05:51:40 +0000
commit5e34d5b143dabff5904dd8ddf328046ff144b0dc (patch)
treee7b58ba507e4925b6b451d933e56bd4542cc1220 /release/sysinstall
parent9e30bacfe68adadb16f589596d5c635134ac9755 (diff)
downloadFreeBSD-src-5e34d5b143dabff5904dd8ddf328046ff144b0dc.zip
FreeBSD-src-5e34d5b143dabff5904dd8ddf328046ff144b0dc.tar.gz
Support the use of the 2nd CDROM as a fixit aid. Also put the EHS
into a submenu in case you need to start it again (or at some other point in the installation). Submitted-By: joerg
Diffstat (limited to 'release/sysinstall')
-rw-r--r--release/sysinstall/install.c104
-rw-r--r--release/sysinstall/menus.c26
-rw-r--r--release/sysinstall/sysinstall.h4
-rw-r--r--release/sysinstall/system.c27
4 files changed, 142 insertions, 19 deletions
diff --git a/release/sysinstall/install.c b/release/sysinstall/install.c
index 1d09670..ba3b7c6 100644
--- a/release/sysinstall/install.c
+++ b/release/sysinstall/install.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: install.c,v 1.145 1996/12/12 23:12:44 jkh Exp $
+ * $Id: install.c,v 1.146 1996/12/26 03:32:50 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -48,9 +48,9 @@
#undef MSDOSFS
#include <sys/stat.h>
#include <unistd.h>
-#include <sys/mount.h>
static void create_termcap(void);
+static void fixit_common(void);
#ifdef SAVE_USERCONFIG
static void save_userconfig_to_kernel(char *);
#endif
@@ -243,11 +243,75 @@ installInitial(void)
}
int
+installFixitHoloShell(dialogMenuItem *self)
+{
+ systemCreateHoloshell();
+ return DITEM_SUCCESS;
+}
+
+
+int
installFixitCDROM(dialogMenuItem *self)
{
- 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.");
+ struct stat sb;
+
+ variable_set2(SYSTEM_STATE, "fixit");
+ (void)unlink("/mnt2");
+ (void)rmdir("/mnt2");
+
+ while (1) {
+ msgConfirm("Please insert the second CD-ROM and press return");
+ if (DITEM_STATUS(mediaSetCDROM(NULL)) != DITEM_SUCCESS || !mediaDevice->init(mediaDevice)) {
+ /* If we can't initialize it, it's probably not a FreeBSD CDROM so punt on it */
+ mediaDevice = NULL;
+ if (msgYesNo("Unable to mount the CD-ROM - do you want to try again?") != 0)
+ return DITEM_FAILURE;
+ }
+ }
+
+ /* Since the fixit code expects everything to be in /mnt2, and the CDROM mounting stuff /cdrom, do
+ * a little kludge dance here..
+ */
+ if (symlink("/cdrom", "/mnt2")) {
+ msgConfirm("Unable to symlink /mnt2 to the CDROM mount point. Please report this\n"
+ "unexpected failure to bugs@freebsd.org.");
+ return DITEM_FAILURE;
+ }
+
+ /*
+ * If /tmp points to /mnt2/tmp from a previous fixit floppy session, it's
+ * not very good for us if we point it to the CD-ROM now. Rather make it
+ * a directory in the root MFS then. Experienced admins will still be
+ * able to mount their disk's /tmp over this if they need.
+ */
+ if (lstat("/tmp", &sb) == 0 && (sb.st_mode & S_IFMT) == S_IFLNK)
+ (void)unlink("/tmp");
+ Mkdir("/tmp");
+
+ /*
+ * Since setuid binaries ignore LD_LIBRARY_PATH, we indeed need the
+ * ld.so.hints file. Fortunately, it's fairly small (~ 3 KB).
+ */
+ if (!file_readable("/var/run/ld.so.hints")) {
+ Mkdir("/var/run");
+ if (vsystem("/mnt2/sbin/ldconfig -s /mnt2/usr/lib")) {
+ msgConfirm("Warning: ldconfig could not create the ld.so hints file.\n"
+ "Dynamic executables from the CD-ROM likely won't work.");
+ }
+ }
+
+ /* Yet another iggly hardcoded pathname. */
+ if (!file_readable("/usr/libexec/ld.so")) {
+ Mkdir("/usr/libexec");
+ if (symlink("/mnt2/usr/libexec/ld.so", "/usr/libexec/ld.so")) {
+ msgConfirm("Warning: could not create the symlink for ld.so.\n"
+ "Dynamic executables from the CD-ROM likely won't work.");
+ }
+ }
+
+ fixit_common();
+
+ msgConfirm("Please remove the CD-ROM now.");
return DITEM_SUCCESS;
}
@@ -255,8 +319,6 @@ int
installFixitFloppy(dialogMenuItem *self)
{
struct ufs_args args;
- pid_t child;
- int waitstatus;
variable_set2(SYSTEM_STATE, "fixit");
memset(&args, 0, sizeof(args));
@@ -277,6 +339,22 @@ installFixitFloppy(dialogMenuItem *self)
if (!directory_exists("/tmp"))
(void)symlink("/mnt2/tmp", "/tmp");
+
+ fixit_common();
+
+ msgConfirm("Please remove the fixit floppy now.");
+ return DITEM_SUCCESS;
+}
+
+/*
+ * The common code for both fixit variants.
+ */
+static void
+fixit_common(void)
+{
+ pid_t child;
+ int waitstatus;
+
if (!directory_exists("/var/tmp/vi.recover")) {
if (DITEM_STATUS(Mkdir("/var/tmp/vi.recover")) != DITEM_SUCCESS) {
msgConfirm("Warning: Was unable to create a /var/tmp/vi.recover directory.\n"
@@ -320,13 +398,14 @@ installFixitFloppy(dialogMenuItem *self)
}
else
msgDebug("fixit shell: Unable to get terminal attributes!\n");
- setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/stand:/mnt2/stand", 1);
- /* use the .profile from the fixit floppy */
+ setenv("PATH", "/bin:/sbin:/usr/bin:/usr/sbin:/stand:"
+ "/mnt2/stand:/mnt2/bin:/mnt2/sbin:/mnt2/usr/bin:/mnt2/usr/sbin", 1);
+ /* use the .profile from the fixit medium */
setenv("HOME", "/mnt2", 1);
chdir("/mnt2");
execlp("sh", "-sh", 0);
msgDebug("fixit shell: Failed to execute shell!\n");
- return -1;
+ _exit(1);;
}
else {
msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n"
@@ -336,10 +415,9 @@ installFixitFloppy(dialogMenuItem *self)
}
unmount("/mnt2", MNT_FORCE);
dialog_clear();
- msgConfirm("Please remove the fixit floppy now.");
- return DITEM_SUCCESS;
}
-
+
+
int
installExpress(dialogMenuItem *self)
{
diff --git a/release/sysinstall/menus.c b/release/sysinstall/menus.c
index ae2c2aa..f855faf 100644
--- a/release/sysinstall/menus.c
+++ b/release/sysinstall/menus.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: menus.c,v 1.101 1996/12/12 22:38:40 jkh Exp $
+ * $Id: menus.c,v 1.102 1996/12/29 05:28:41 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -229,8 +229,9 @@ DMenu MenuIndex = {
{ "Doc, Copyright", "The distribution copyright notices.", NULL, dmenuDisplayFile, NULL, "COPYRIGHT" },
{ "Doc, Release", "The distribution release notes.", NULL, dmenuDisplayFile, NULL, "relnotes" },
{ "Doc, HTML", "The HTML documentation menu.", NULL, docBrowser },
+ { "Emergency shell", "Start an Emergency Holographic shell.", NULL, installFixitHoloShell },
{ "Extract", "Extract selected distributions from media.", NULL, distExtractAll },
- { "Fixit", "Repair mode with fixit floppy.", NULL, installFixitFloppy },
+ { "Fixit", "Repair mode with CDROM or fixit floppy.", NULL, dmenuSubmenu, NULL, &MenuFixit },
{ "FTP sites", "The FTP mirror site listing.", NULL, dmenuSubmenu, NULL, &MenuMediaFTP },
{ "Gateway", "Set flag to route packets between interfaces.", dmenuVarCheck, dmenuToggleVariable, NULL, "gateway=YES" },
{ "HTML Docs", "The HTML documentation menu", NULL, docBrowser },
@@ -295,7 +296,7 @@ DMenu MenuInitial = {
{ "5 Novice", "Begin a novice installation (for beginners)", NULL, installNovice },
{ "6 Express", "Begin a quick installation (for the impatient)", NULL, installExpress },
{ "7 Custom", "Begin a custom installation (for experts)", NULL, dmenuSubmenu, NULL, &MenuInstallCustom },
- { "8 Fixit", "Go into repair mode with a fixit floppy", NULL, installFixitFloppy },
+ { "8 Fixit", "Go into repair mode with CDROM or floppy, or start a shell.", NULL, dmenuSubmenu, NULL, &MenuFixit },
{ "9 Upgrade", "Upgrade an existing system", NULL, installUpgrade },
{ "c Configure", "Do post-install configuration of FreeBSD", NULL, dmenuSubmenu, NULL, &MenuConfigure },
{ "0 Index", "Glossary of functions", NULL, dmenuSubmenu, NULL, &MenuIndex },
@@ -1283,3 +1284,22 @@ DMenu MenuUsermgmt = {
{ "Exit", "Exit this menu (returning to previous)", NULL, dmenuExit },
{ NULL } },
};
+
+DMenu MenuFixit = {
+ DMENU_NORMAL_TYPE,
+ "Please choose a fixit option",
+ "There are three ways of going into \"fixit\" mode:\n"
+ "- you can use the 2nd FreeBSD CDROM, in which case there will be\n"
+ " full access to the complete set of FreeBSD commands and utilities,\n"
+ "- you can use the more limited (but perhaps customized) fixit floppy,\n"
+ "- or you can start an Emergency Holographic Shell now, which is\n"
+ " limited to the subset of commands that is already available right now.",
+ "Press F1 for more detailed repair instructions",
+ "fixit",
+{ { "1 CDROM", "Use the 2nd \"live\" CDROM from the distribution", NULL, installFixitCDROM },
+ { "2 Floppy", "Use a floppy generated from the fixit image", NULL, installFixitFloppy },
+ { "3 Shell", "Start an Emergency Holographic Shell", NULL, installFixitHoloShell },
+ { NULL } },
+};
+
+
diff --git a/release/sysinstall/sysinstall.h b/release/sysinstall/sysinstall.h
index fd8b255..af1cbf3 100644
--- a/release/sysinstall/sysinstall.h
+++ b/release/sysinstall/sysinstall.h
@@ -4,7 +4,7 @@
* This is probably the last attempt in the `sysinstall' line, the next
* generation being slated to essentially a complete rewrite.
*
- * $Id: sysinstall.h,v 1.94 1996/12/14 23:09:07 jkh Exp $
+ * $Id: sysinstall.h,v 1.95 1996/12/17 00:00:15 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -340,6 +340,7 @@ extern DMenu MenuXF86SelectFonts; /* XFree86 font selection menu */
extern DMenu MenuDiskDevices; /* Disk devices menu */
extern DMenu MenuHTMLDoc; /* HTML Documentation menu */
extern DMenu MenuUsermgmt; /* User management menu */
+extern DMenu MenuFixit; /* Fixit floppy/CDROM/shell menu */
/*** Prototypes ***/
@@ -486,6 +487,7 @@ extern int installCommit(dialogMenuItem *self);
extern int installCustomCommit(dialogMenuItem *self);
extern int installExpress(dialogMenuItem *self);
extern int installNovice(dialogMenuItem *self);
+extern int installFixitHoloShell(dialogMenuItem *self);
extern int installFixitCDROM(dialogMenuItem *self);
extern int installFixitFloppy(dialogMenuItem *self);
extern int installFixup(dialogMenuItem *self);
diff --git a/release/sysinstall/system.c b/release/sysinstall/system.c
index 3424070..1161ce6 100644
--- a/release/sysinstall/system.c
+++ b/release/sysinstall/system.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: system.c,v 1.68 1996/12/11 19:35:26 jkh Exp $
+ * $Id: system.c,v 1.69 1996/12/12 08:23:51 jkh Exp $
*
* Jordan Hubbard
*
@@ -29,6 +29,8 @@
#define DOC_TMP_DIR "/tmp"
#define DOC_TMP_FILE "/tmp/doc.tmp"
+static pid_t ehs_pid;
+
/*
* Handle interrupt signals - this probably won't work in all cases
* due to our having bogotified the internal state of dialog or curses,
@@ -294,7 +296,28 @@ void
systemCreateHoloshell(void)
{
if (OnVTY && RunningAsInit) {
- if (!fork()) {
+
+ if (ehs_pid != 0) {
+ int pstat;
+
+ if (kill(ehs_pid, 0) == 0) {
+
+ if (msgYesNo("There seems to be an emergency holographic shell\n"
+ "already running von VTY 4.\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 ((ehs_pid = fork()) == 0) {
int i, fd;
struct termios foo;
extern int login_tty(int);
OpenPOWER on IntegriCloud