2 * The new sysinstall program.
4 * This is probably the last attempt in the `sysinstall' line, the next
5 * generation being slated for what's essentially a complete rewrite.
7 * $FreeBSD: src/release/sysinstall/main.c,v 1.57.2.9 2002/07/03 00:05:02 jhb Exp $
8 * $DragonFly: src/release/sysinstall/Attic/main.c,v 1.2 2003/06/17 04:27:21 dillon Exp $
11 * Jordan Hubbard. All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer,
18 * verbatim and that no modifications are made prior to this
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
24 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 #include "sysinstall.h"
39 #include <sys/signal.h>
40 #include <sys/fcntl.h>
42 const char *StartName; /* Initial contents of argv[0] */
47 msgDebug("\007Signal %d caught! That's bad!\n", sig);
48 longjmp(BailOut, sig);
52 main(int argc, char **argv)
54 int choice, scroll, curr, max, status;
56 /* Record name to be able to restart */
59 /* Catch fatal signals and complain about them if running as init */
61 signal(SIGBUS, screech);
62 signal(SIGSEGV, screech);
64 signal(SIGPIPE, SIG_IGN);
66 /* We don't work too well when running as non-root anymore */
68 fprintf(stderr, "Error: This utility should only be run as root.\n");
75 char *p = getenv("TERM");
76 if (p && strcmp(p, "cons25") == 0)
77 putenv("TERM=cons25w");
81 /* Set up whatever things need setting up */
82 systemInitialize(argc, argv);
84 /* Set default flag and variable values */
85 installVarDefaults(NULL);
86 /* only when multi-user is it reasonable to do this here */
90 if (argc > 1 && !strcmp(argv[1], "-fake")) {
91 variable_set2(VAR_DEBUG, "YES", 0);
93 msgConfirm("I'll be just faking it from here on out, OK?");
95 if (argc > 1 && !strcmp(argv[1], "-restart"))
98 /* Try to preserve our scroll-back buffer */
100 for (curr = 0; curr < 25; curr++)
103 /* Move stderr aside */
107 /* Initialize driver modules */
111 /* Initialize PC-card */
121 /* Probe for all relevant devices on the system */
124 /* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */
125 if (!RunningAsInit) {
128 if (!strstr(argv[0], "sysinstall"))
130 else if (Fake || Restarting)
134 for (i = start_arg; i < argc; i++) {
135 if (DITEM_STATUS(dispatchCommand(argv[i])) != DITEM_SUCCESS)
138 if (argc > start_arg)
142 dispatch_load_file_int(TRUE);
144 status = setjmp(BailOut);
146 msgConfirm("A signal %d was caught - I'm saving what I can and shutting\n"
147 "down. If you can reproduce the problem, please turn Debug on\n"
148 "in the Options menu for the extra information it provides\n"
149 "in debugging problems like this.", status);
150 systemShutdown(status);
153 /* Begin user dialog at outer menu */
156 choice = scroll = curr = max = 0;
157 dmenuOpen(&MenuInitial, &choice, &scroll, &curr, &max, TRUE);
160 || !msgNoYes("Are you sure you wish to exit? The system will halt.")
162 || !msgNoYes("Are you sure you wish to exit? The system will reboot\n"
163 "(be sure to remove any floppies/CDs/DVDs from the drives).")
169 /* Say goodnight, Gracie */
172 return 0; /* We should never get here */