main.c (161059) | main.c (161060) |
---|---|
1/* | 1/* |
2 * The new sysinstall program. | 2 * $FreeBSD: head/usr.sbin/sade/main.c 161060 2006-08-07 23:35:49Z netchild $ |
3 * | 3 * |
4 * This is probably the last attempt in the `sysinstall' line, the next 5 * generation being slated for what's essentially a complete rewrite. 6 * 7 * $FreeBSD: head/usr.sbin/sade/main.c 156118 2006-02-28 20:29:43Z jhb $ 8 * | |
9 * Copyright (c) 1995 | 4 * Copyright (c) 1995 |
10 * Jordan Hubbard. All rights reserved. | 5 * Jordan Hubbard. All rights reserved. |
11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer, 17 * verbatim and that no modifications are made prior to this 18 * point in the file. --- 10 unchanged lines hidden (view full) --- 29 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * 35 */ 36 | 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer, 12 * verbatim and that no modifications are made prior to this 13 * point in the file. --- 10 unchanged lines hidden (view full) --- 24 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 */ 31 |
37#include "sysinstall.h" | 32#include "sade.h" |
38#include <sys/signal.h> 39#include <sys/fcntl.h> 40 41const char *StartName; /* Initial contents of argv[0] */ 42 43static void 44screech(int sig) 45{ --- 4 unchanged lines hidden (view full) --- 50int 51main(int argc, char **argv) 52{ 53 int choice, scroll, curr, max, status; 54 55 /* Record name to be able to restart */ 56 StartName = argv[0]; 57 | 33#include <sys/signal.h> 34#include <sys/fcntl.h> 35 36const char *StartName; /* Initial contents of argv[0] */ 37 38static void 39screech(int sig) 40{ --- 4 unchanged lines hidden (view full) --- 45int 46main(int argc, char **argv) 47{ 48 int choice, scroll, curr, max, status; 49 50 /* Record name to be able to restart */ 51 StartName = argv[0]; 52 |
58 /* Catch fatal signals and complain about them if running as init */ 59 if (getpid() == 1) { 60 signal(SIGBUS, screech); 61 signal(SIGSEGV, screech); 62 } | |
63 signal(SIGPIPE, SIG_IGN); 64 65 /* We don't work too well when running as non-root anymore */ 66 if (geteuid() != 0) { 67 fprintf(stderr, "Error: This utility should only be run as root.\n"); 68 return 1; 69 } 70 --- 6 unchanged lines hidden (view full) --- 77 } 78#endif 79 80 /* Set up whatever things need setting up */ 81 systemInitialize(argc, argv); 82 83 /* Set default flag and variable values */ 84 installVarDefaults(NULL); | 53 signal(SIGPIPE, SIG_IGN); 54 55 /* We don't work too well when running as non-root anymore */ 56 if (geteuid() != 0) { 57 fprintf(stderr, "Error: This utility should only be run as root.\n"); 58 return 1; 59 } 60 --- 6 unchanged lines hidden (view full) --- 67 } 68#endif 69 70 /* Set up whatever things need setting up */ 71 systemInitialize(argc, argv); 72 73 /* Set default flag and variable values */ 74 installVarDefaults(NULL); |
85 /* only when multi-user is it reasonable to do this here */ 86 if (!RunningAsInit) 87 installEnvironment(); | |
88 89 if (argc > 1 && !strcmp(argv[1], "-fake")) { 90 variable_set2(VAR_DEBUG, "YES", 0); 91 Fake = TRUE; 92 msgConfirm("I'll be just faking it from here on out, OK?"); 93 } 94 if (argc > 1 && !strcmp(argv[1], "-restart")) 95 Restarting = TRUE; --- 5 unchanged lines hidden (view full) --- 101 } 102 /* Move stderr aside */ 103 if (DebugFD) 104 dup2(DebugFD, 2); 105 106 /* Initialize driver modules, if we haven't already done so (ie, 107 the user hit Ctrl-C -> Restart. */ 108 if (!pvariable_get("modulesInitialize")) { | 75 76 if (argc > 1 && !strcmp(argv[1], "-fake")) { 77 variable_set2(VAR_DEBUG, "YES", 0); 78 Fake = TRUE; 79 msgConfirm("I'll be just faking it from here on out, OK?"); 80 } 81 if (argc > 1 && !strcmp(argv[1], "-restart")) 82 Restarting = TRUE; --- 5 unchanged lines hidden (view full) --- 88 } 89 /* Move stderr aside */ 90 if (DebugFD) 91 dup2(DebugFD, 2); 92 93 /* Initialize driver modules, if we haven't already done so (ie, 94 the user hit Ctrl-C -> Restart. */ 95 if (!pvariable_get("modulesInitialize")) { |
109 moduleInitialize(); | |
110 pvariable_set("modulesInitialize=1"); 111 } 112 | 96 pvariable_set("modulesInitialize=1"); 97 } 98 |
113 /* Initialize PC Card, if we haven't already done so. */ 114#ifdef PCCARD_ARCH 115 if (!variable_cmp(VAR_SKIP_PCCARD, "YES") && 116 variable_get(VAR_SKIP_PCCARD)!=1 && 117 !pvariable_get("pccardInitialize")) { 118 pccardInitialize(); 119 pvariable_set("pccardInitialize=1"); 120 } 121#endif 122 | |
123 /* Probe for all relevant devices on the system */ 124 deviceGetAll(); 125 | 99 /* Probe for all relevant devices on the system */ 100 deviceGetAll(); 101 |
126 /* Prompt for the driver floppy if appropriate. */ 127 if (!pvariable_get("driverFloppyCheck")) { 128 driverFloppyCheck(); 129 pvariable_set("driverFloppyCheck=1"); 130 } 131 | |
132 /* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */ | 102 /* First, see if we have any arguments to process (and argv[0] counts if it's not "sysinstall") */ |
133 if (!RunningAsInit) { 134 int i, start_arg; | |
135 | 103 |
136 if (!strstr(argv[0], "sysinstall")) 137 start_arg = 0; 138 else if (Fake || Restarting) 139 start_arg = 2; 140 else 141 start_arg = 1; 142 for (i = start_arg; i < argc; i++) { 143 if (DITEM_STATUS(dispatchCommand(argv[i])) != DITEM_SUCCESS) 144 systemShutdown(1); 145 } 146 if (argc > start_arg) 147 systemShutdown(0); 148 } 149 else 150 dispatch_load_file_int(TRUE); 151 | |
152 status = setjmp(BailOut); 153 if (status) { 154 msgConfirm("A signal %d was caught - I'm saving what I can and shutting\n" 155 "down. If you can reproduce the problem, please turn Debug on\n" 156 "in the Options menu for the extra information it provides\n" 157 "in debugging problems like this.", status); | 104 status = setjmp(BailOut); 105 if (status) { 106 msgConfirm("A signal %d was caught - I'm saving what I can and shutting\n" 107 "down. If you can reproduce the problem, please turn Debug on\n" 108 "in the Options menu for the extra information it provides\n" 109 "in debugging problems like this.", status); |
158 systemShutdown(status); | 110 ; |
159 } 160 | 111 } 112 |
161 /* Get user's country and keymap */ 162 if (RunningAsInit) 163 configCountry(NULL); 164 | |
165 /* Begin user dialog at outer menu */ 166 dialog_clear(); 167 while (1) { 168 choice = scroll = curr = max = 0; | 113 /* Begin user dialog at outer menu */ 114 dialog_clear(); 115 while (1) { 116 choice = scroll = curr = max = 0; |
169 dmenuOpen(&MenuInitial, &choice, &scroll, &curr, &max, TRUE); | 117 dmenuOpen(&MenuMain, &choice, &scroll, &curr, &max, FALSE); |
170 if (getpid() != 1 | 118 if (getpid() != 1 |
171#if defined(__alpha__) || defined(__sparc64__) 172 || !msgNoYes("Are you sure you wish to exit? The system will halt.") 173#else 174 || !msgNoYes("Are you sure you wish to exit? The system will reboot\n" 175 "(be sure to remove any floppies/CDs/DVDs from the drives).") 176#endif | 119 || !msgNoYes("Are you sure you wish to exit?") |
177 ) 178 break; 179 } 180 | 120 ) 121 break; 122 } 123 |
181 /* Say goodnight, Gracie */ 182 systemShutdown(0); 183 | |
184 return 0; /* We should never get here */ 185} | 124 return 0; /* We should never get here */ 125} |