]>
Commit | Line | Data |
---|---|---|
d6aaa55d MT |
1 | /* SmoothWall install program. |
2 | * | |
3 | * This program is distributed under the terms of the GNU General Public | |
4 | * Licence. See the file COPYING for details. | |
5 | * | |
6 | * (c) Lawrence Manning, 2001 | |
7 | * Contains main entry point, and misc functions. | |
8 | * | |
d6aaa55d | 9 | */ |
10bc6f06 | 10 | |
d6aaa55d MT |
11 | #include "install.h" |
12 | ||
13 | #define CDROM_INSTALL 0 | |
14 | #define URL_INSTALL 1 | |
15 | ||
16 | int raid_disk = 0; | |
17 | FILE *flog = NULL; | |
18 | char *mylog; | |
10bc6f06 | 19 | |
d6aaa55d MT |
20 | char **ctr; |
21 | ||
22 | char *pcmcia = NULL; | |
23 | extern char url[STRING_SIZE]; | |
24 | ||
10bc6f06 | 25 | extern char *en_tr[]; |
10bc6f06 | 26 | extern char *de_tr[]; |
d6aaa55d MT |
27 | |
28 | int main(int argc, char *argv[]) | |
29 | { | |
30 | #ifdef LANG_EN_ONLY | |
31 | char *langnames[] = { "English", NULL }; | |
32 | char *shortlangnames[] = { "en", NULL }; | |
33 | char **langtrs[] = { en_tr, NULL }; | |
1217aa01 | 34 | #else |
b4e3cd7f HS |
35 | char *langnames[] = { "Deutsch", "English", NULL }; |
36 | char *shortlangnames[] = { "de", "en", NULL }; | |
37 | char **langtrs[] = { de_tr, en_tr, NULL }; | |
d6aaa55d MT |
38 | #endif |
39 | char hdletter, cdletter; | |
40 | char harddrive[5], cdromdrive[5]; /* Device holder. */ | |
41 | struct devparams hdparams, cdromparams; /* Params for CDROM and HD */ | |
42 | int cdmounted = 0; /* Loop flag for inserting a cd. */ | |
43 | int rc; | |
44 | char commandstring[STRING_SIZE]; | |
10bc6f06 | 45 | char *installtypes[] = { "CDROM", "HTTP/FTP", NULL }; |
d6aaa55d MT |
46 | int installtype = CDROM_INSTALL; |
47 | char insertmessage[STRING_SIZE]; | |
48 | char insertdevnode[STRING_SIZE]; | |
49 | int choice; | |
50 | char shortlangname[10]; | |
51 | char message[1000]; | |
52 | char title[STRING_SIZE]; | |
53 | int allok = 0; | |
10bc6f06 | 54 | int allok_fastexit=0; |
d6aaa55d MT |
55 | int unmount_before=0; |
56 | struct keyvalue *ethernetkv = initkeyvalues(); | |
57 | FILE *handle, *cmdfile; | |
58 | char line[STRING_SIZE]; | |
59 | char string[STRING_SIZE]; | |
60 | int maximum_free = 0, current_free; | |
61 | int memory = 0; | |
62 | int log_partition, boot_partition, root_partition, swap_file; | |
63 | int scsi_disk = 0; | |
64 | int pcmcia_disk = 0; | |
65 | int pcmcia_cdrom = 0; | |
66 | int scsi_cdrom = 0; | |
67 | int ide_cdrom = 0; | |
68 | int fdisk = 0; | |
10bc6f06 | 69 | |
d6aaa55d MT |
70 | |
71 | setlocale (LC_ALL, ""); | |
10bc6f06 | 72 | sethostname( SNAME , 10); |
d6aaa55d MT |
73 | |
74 | memset(&hdparams, 0, sizeof(struct devparams)); | |
75 | memset(&cdromparams, 0, sizeof(struct devparams)); | |
76 | ||
77 | /* Log file/terminal stuff. */ | |
78 | if (argc >= 2) | |
79 | { | |
80 | if (!(flog = fopen(argv[1], "w+"))) | |
81 | return 0; | |
82 | } | |
83 | else | |
84 | return 0; | |
85 | ||
86 | mylog = argv[1]; | |
87 | ||
88 | fprintf(flog, "Install program started.\n"); | |
89 | ||
90 | newtInit(); | |
91 | newtCls(); | |
92 | ||
93 | /* Do usb detection first for usb keyboard */ | |
94 | if (! (cmdfile = fopen("/proc/cmdline", "r"))) | |
95 | { | |
96 | fprintf(flog, "Couldn't open commandline: /proc/cmdline\n"); | |
97 | } else { | |
98 | fgets(line, STRING_SIZE, cmdfile); | |
99 | if (strstr (line, "fdisk") != NULL) { | |
100 | fprintf(flog, "Manual FDISK selected.\n"); | |
101 | fdisk = 1; | |
102 | } | |
103 | if (strstr (line, "nopcmcia") == NULL) { | |
104 | fprintf(flog, "Initializing PCMCIA controllers.\n"); | |
105 | pcmcia = initialize_pcmcia(); | |
106 | if (pcmcia) { | |
107 | fprintf (flog, "Detected PCMCIA Controller: %s.\n", pcmcia); | |
108 | sprintf(commandstring, "/sbin/modprobe %s", pcmcia); | |
109 | mysystem("/sbin/modprobe pcmcia_core"); | |
110 | mysystem(commandstring); | |
111 | mysystem("/sbin/modprobe ds"); | |
112 | /* pcmcia netcard drivers are not available from Boot floppy, | |
113 | * they will be loaded from Drivers floppy later */ | |
114 | } else { | |
115 | fprintf (flog, "Detected No PCMCIA Controller.\n"); | |
116 | } | |
117 | } else { | |
118 | fprintf(flog, "Skipping PCMCIA detection.\n"); | |
119 | } | |
120 | if (strstr (line, "nousb") == NULL) { | |
121 | fprintf(flog, "Initializing USB controllers.\n"); | |
122 | initialize_usb(); | |
123 | } else { | |
124 | fprintf(flog, "Skipping USB detection.\n"); | |
125 | } | |
126 | } | |
127 | ||
b4e3cd7f | 128 | /* Deutsch is the default */ |
d6aaa55d MT |
129 | for (choice = 0; langnames[choice]; choice++) |
130 | { | |
b4e3cd7f | 131 | if (strcmp(langnames[choice], "Deutsch") == 0) |
d6aaa55d MT |
132 | break; |
133 | } | |
134 | if (!langnames[choice]) | |
135 | goto EXIT; | |
136 | ||
137 | #ifdef LANG_EN_ONLY | |
138 | /* No need to ask. "choice" already has the index for English */ | |
139 | #else | |
140 | rc = newtWinMenu("Language selection", | |
3d6e1202 MT |
141 | "Select the language you wish to use for your " NAME ".", 50, 5, 5, 8, |
142 | langnames, &choice, "OK", NULL); | |
d6aaa55d MT |
143 | #endif |
144 | ctr = langtrs[choice]; | |
145 | strcpy(shortlangname, shortlangnames[choice]); | |
3d6e1202 MT |
146 | |
147 | mysystem("/bin/setfont lat0-16"); | |
10bc6f06 | 148 | |
d6aaa55d MT |
149 | newtDrawRootText(14, 0, NAME " v" VERSION " - " SLOGAN ); |
150 | newtPushHelpLine(ctr[TR_HELPLINE]); | |
151 | ||
10bc6f06 MT |
152 | sprintf(message, ctr[TR_WELCOME], NAME); |
153 | sprintf (title, "%s v%s - %s", NAME, VERSION, SLOGAN); | |
d6aaa55d MT |
154 | newtWinMessage(title, ctr[TR_OK], message); |
155 | ||
5433e2c9 MT |
156 | sprintf(message, ctr[TR_SELECT_INSTALLATION_MEDIA_LONG], NAME); |
157 | rc = newtWinMenu(ctr[TR_SELECT_INSTALLATION_MEDIA], message, | |
158 | 50, 5, 5, 6, installtypes, &installtype, ctr[TR_OK], | |
159 | ctr[TR_CANCEL], NULL); | |
160 | ||
161 | if (rc == 2) | |
162 | goto EXIT; | |
e57bc1fd | 163 | |
10bc6f06 MT |
164 | if (installtype == CDROM_INSTALL) |
165 | { | |
166 | /* First look for an IDE CDROM. */ | |
167 | if (!(cdletter = findidetype(IDE_CDROM))) | |
d6aaa55d | 168 | { |
10bc6f06 MT |
169 | /* If we have a USB attached CDROM then it will |
170 | * have already appeared at /dev/scd0, so we | |
171 | * try to access it first, before asking for the | |
172 | * SCSI drivers disk. | |
173 | */ | |
174 | if (!(try_scsi("scd0"))) { | |
175 | sprintf(insertmessage, ctr[TR_INSERT_FLOPPY], NAME" SCSI"); | |
176 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], insertmessage); | |
177 | if (rc != 1) | |
178 | { | |
179 | errorbox(ctr[TR_INSTALLATION_CANCELED]); | |
180 | goto EXIT; | |
181 | } | |
182 | ||
183 | if (runcommandwithstatus("/bin/tar -C / -xvzf /dev/floppy", ctr[TR_EXTRACTING_MODULES])) | |
184 | { | |
185 | errorbox(ctr[TR_UNABLE_TO_EXTRACT_MODULES]); | |
186 | goto EXIT; | |
187 | } | |
188 | ||
189 | if (pcmcia) | |
190 | { | |
191 | /* trying to support SCSI pcmcia :-) */ | |
192 | runcommandwithstatus("cardmgr -o -c /etc/pcmcia/scsi", | |
193 | ctr[TR_LOADING_PCMCIA]); | |
194 | if (try_scsi("scd0")) | |
195 | pcmcia_cdrom = 1; | |
196 | } | |
197 | ||
198 | /* try loading all SCSI modules with default options */ | |
199 | /* Should expand this to allow options later though */ | |
200 | if (!pcmcia_cdrom) | |
201 | runcommandwithstatus("/bin/probescsi.sh", | |
202 | ctr[TR_PROBING_SCSI]); | |
203 | ||
204 | /* If it fails, give up. */ | |
205 | if (!(try_scsi("scd0"))) { | |
206 | errorbox(ctr[TR_NO_CDROM]); | |
207 | goto EXIT; | |
208 | } | |
d6aaa55d | 209 | } |
d6aaa55d | 210 | |
d6aaa55d MT |
211 | sprintf(cdromdrive, "scd0"); |
212 | scsi_cdrom = 1; | |
10bc6f06 MT |
213 | } else { |
214 | sprintf(cdromdrive, "hd%c", cdletter); | |
215 | ide_cdrom = 1; | |
d6aaa55d MT |
216 | } |
217 | ||
10bc6f06 MT |
218 | snprintf(cdromparams.devnode, STRING_SIZE, "/dev/%s", cdromdrive); |
219 | cdromparams.module = 0; | |
220 | ||
221 | sprintf(insertmessage, ctr[TR_INSERT_CDROM], NAME); | |
222 | strcpy (insertdevnode, cdromparams.devnode); | |
d6aaa55d | 223 | } |
10bc6f06 | 224 | else |
d6aaa55d MT |
225 | { |
226 | /* If we've done a PXE boot, we can skip the Drivers floppy, | |
227 | * as we've already got the modules in our instroot.gz */ | |
228 | if (!(handle = fopen("/CDROMBOOT", "r"))) { | |
10bc6f06 | 229 | sprintf(insertmessage, ctr[TR_INSERT_FLOPPY], NAME); |
d6aaa55d MT |
230 | strcpy (insertdevnode , "/dev/floppy"); |
231 | } else { | |
232 | fclose(handle); | |
233 | cdmounted = 1; | |
234 | unmount_before = 1; | |
235 | } | |
236 | } | |
237 | ||
10bc6f06 MT |
238 | if (scsi_cdrom || ide_cdrom) { |
239 | /* Try to mount /cdrom in a loop. */ | |
d6aaa55d | 240 | snprintf(commandstring, STRING_SIZE, "/bin/mount -o ro %s /cdrom", insertdevnode); |
d6aaa55d MT |
241 | while (!cdmounted) |
242 | { | |
10bc6f06 MT |
243 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], insertmessage); |
244 | if (rc != 1) | |
245 | { | |
d6aaa55d MT |
246 | errorbox(ctr[TR_INSTALLATION_CANCELED]); |
247 | goto EXIT; | |
d6aaa55d | 248 | } |
10bc6f06 MT |
249 | if (!(mysystem(commandstring))) { |
250 | handle = fopen ("/cdrom/" SNAME "-" VERSION ".tgz", "r"); | |
251 | if (handle != NULL) { | |
252 | fclose (handle); | |
253 | cdmounted = 1; | |
254 | /* If we've booted from CDROM, then | |
255 | * we've already got the drivers, | |
256 | * so we can skip this unpack. */ | |
257 | if (!(handle = fopen("/CDROMBOOT", "r"))) { | |
258 | sprintf(string, "/bin/tar -C / -xvzf /cdrom/images/drivers-%s.img", VERSION); | |
259 | if (runcommandwithprogress(60, 4, title, | |
260 | string, | |
261 | 175, ctr[TR_EXTRACTING_MODULES])) | |
262 | { | |
263 | errorbox(ctr[TR_UNABLE_TO_EXTRACT_MODULES]); | |
264 | ||
265 | goto EXIT; | |
266 | } | |
267 | } else | |
268 | fclose(handle); | |
269 | } else { | |
270 | mysystem ("/bin/umount /cdrom"); | |
271 | } | |
d6aaa55d MT |
272 | } |
273 | } | |
10bc6f06 MT |
274 | } else { |
275 | snprintf(commandstring, STRING_SIZE, "/bin/tar -C / -xvzf /dev/floppy"); | |
d6aaa55d MT |
276 | while (!cdmounted) |
277 | { | |
278 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], insertmessage); | |
279 | if (rc != 1) | |
280 | { | |
281 | errorbox(ctr[TR_INSTALLATION_CANCELED]); | |
282 | goto EXIT; | |
283 | } | |
284 | if (runcommandwithprogress(60, 4, title, | |
285 | commandstring, | |
286 | 175, ctr[TR_EXTRACTING_MODULES])) | |
287 | { | |
288 | #if 0 /* disable this, so we allow for people putting in the wrong disk */ | |
289 | errorbox(ctr[TR_UNABLE_TO_EXTRACT_MODULES]); | |
290 | goto EXIT; | |
291 | #endif | |
292 | } | |
293 | else | |
294 | { | |
295 | handle = fopen ("/bin/mke2fs", "r"); | |
296 | if (handle != NULL) { | |
297 | fclose (handle); | |
298 | cdmounted = 1; | |
299 | } | |
300 | } | |
301 | } | |
302 | } | |
303 | ||
304 | /* PCMCIA controller is already detected | |
305 | * On Boot floppy, we didn't have the PCMCIA drivers | |
306 | * so load them now because they are installed from Drivers. */ | |
307 | if (!(handle = fopen("/CDROMBOOT", "r"))) { | |
308 | if (strstr (line, "nopcmcia") == NULL) { | |
309 | fprintf(flog,"Floppy boot detected, loading PCMCIA drivers.\n"); | |
310 | if (pcmcia) { | |
311 | fprintf (flog, "Detected PCMCIA Controller: %s.\n", pcmcia); | |
312 | sprintf(commandstring, "/sbin/modprobe %s", pcmcia); | |
313 | mysystem("/sbin/modprobe pcmcia_core"); | |
314 | mysystem(commandstring); | |
315 | mysystem("/sbin/modprobe ds"); | |
316 | } else { | |
317 | fprintf (flog, "Detected No PCMCIA Controller.\n"); | |
318 | } | |
319 | } else { | |
320 | fprintf(flog, "Skipping PCMCIA detection.\n"); | |
321 | } | |
322 | if (strstr (line, "nousb") == NULL) { | |
323 | fprintf(flog, "Initializing USB controllers.\n"); | |
324 | initialize_usb(); | |
325 | } else { | |
326 | fprintf(flog, "Skipping USB detection.\n"); | |
327 | } | |
328 | } else | |
329 | fclose(handle); | |
330 | ||
331 | /* Configure the network now! */ | |
332 | if (installtype == URL_INSTALL) | |
333 | { | |
334 | /* Network driver and params. */ | |
335 | if (!(networkmenu(ethernetkv))) | |
336 | { | |
337 | errorbox(ctr[TR_NETWORK_SETUP_FAILED]); | |
338 | goto EXIT; | |
339 | } | |
340 | ||
e57bc1fd | 341 | /* Check for ipfire-<VERSION>.tgz */ |
d6aaa55d MT |
342 | if (!(checktarball(SNAME "-" VERSION ".tgz"))) |
343 | { | |
344 | errorbox(ctr[TR_NO_IPCOP_TARBALL_FOUND]); | |
345 | goto EXIT; | |
346 | } | |
347 | } | |
348 | ||
349 | /* Get device for the HD. This has to succeed. */ | |
10bc6f06 | 350 | if (!(hdletter = findidetype(IDE_HD))) |
d6aaa55d | 351 | { |
10bc6f06 | 352 | if (installtype == URL_INSTALL) |
d6aaa55d | 353 | { |
10bc6f06 MT |
354 | /* If we've done a PXE boot, we can skip the SCSI |
355 | * floppy as we've already got the modules in our | |
356 | * instroot.gz */ | |
357 | if (!(handle = fopen("/CDROMBOOT", "r"))) | |
d6aaa55d | 358 | { |
10bc6f06 MT |
359 | /* search img where it is on a mounted loop iso */ |
360 | sprintf(string, "images/scsidrv-%s.img", VERSION); | |
361 | if (!(checktarball(string))) | |
d6aaa55d | 362 | { |
10bc6f06 MT |
363 | /* Couldn't find the SCSI drivers on the URL page, |
364 | * so after 3 failed attempts, ask the user for the | |
365 | * SCSI drivers floppy disk. */ | |
366 | errorbox(ctr[TR_NO_SCSI_IMAGE_FOUND]); | |
367 | sprintf(insertmessage, ctr[TR_INSERT_FLOPPY], NAME" SCSI"); | |
368 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], insertmessage); | |
369 | if (rc != 1) | |
370 | { | |
371 | errorbox(ctr[TR_INSTALLATION_CANCELED]); | |
372 | goto EXIT; | |
373 | } | |
374 | ||
375 | if (runcommandwithstatus("/bin/tar -C / -xvzf /dev/floppy", ctr[TR_EXTRACTING_MODULES])) | |
376 | { | |
377 | errorbox(ctr[TR_UNABLE_TO_EXTRACT_MODULES]); | |
378 | goto EXIT; | |
379 | } | |
380 | } else { | |
381 | /* unpack... */ | |
382 | snprintf(commandstring, STRING_SIZE, | |
383 | "/bin/wget -O - %s/%s | /bin/tar -C / -xvzf -", | |
384 | url, string); | |
385 | if (runcommandwithprogress(60, 4, title, commandstring, | |
386 | 4500, ctr[TR_INSTALLING_FILES])) | |
387 | { | |
388 | errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]); | |
389 | goto EXIT; | |
390 | } | |
d6aaa55d | 391 | } |
10bc6f06 MT |
392 | } else |
393 | fclose(handle); | |
394 | } else { | |
395 | if (ide_cdrom) { | |
396 | sprintf(string, "/bin/tar -C / -xvzf /cdrom/images/scsidrv-%s.img", VERSION); | |
397 | if (runcommandwithstatus(string, ctr[TR_EXTRACTING_MODULES])) | |
d6aaa55d MT |
398 | { |
399 | errorbox(ctr[TR_UNABLE_TO_EXTRACT_MODULES]); | |
400 | goto EXIT; | |
401 | } | |
d6aaa55d MT |
402 | } |
403 | } | |
d6aaa55d | 404 | |
10bc6f06 MT |
405 | if (!scsi_cdrom) { |
406 | ||
d6aaa55d | 407 | #if 0 /* not yet */ |
10bc6f06 MT |
408 | if (pcmcia) |
409 | { | |
410 | /* trying to support SCSI pcmcia :-) */ | |
411 | runcommandwithstatus("cardmgr -o -c /etc/pcmcia/scsi", | |
412 | ctr[TR_LOADING_PCMCIA]); | |
413 | if (try_scsi("sda")) | |
414 | pcmcia_disk = 1; | |
d6aaa55d | 415 | } |
10bc6f06 MT |
416 | #endif |
417 | ||
418 | /* try loading all SCSI modules with default options */ | |
419 | /* Should expand this to allow options later though */ | |
420 | if (!pcmcia_disk) | |
421 | runcommandwithstatus("/bin/probescsi.sh", | |
422 | ctr[TR_PROBING_SCSI]); | |
423 | } | |
424 | ||
425 | /* Need to clean this up at some point */ | |
426 | if (!try_scsi("sda")) { | |
427 | if (!try_scsi("ida/c0d0")) { | |
428 | if (!try_scsi("cciss/c0d0")) { | |
429 | if (!try_scsi("rd/c0d0")) { | |
430 | if (!try_scsi("ataraid/d0")) { | |
431 | errorbox(ctr[TR_NO_HARDDISK]); | |
432 | goto EXIT; | |
433 | } else { | |
434 | raid_disk = 1; | |
435 | sprintf(harddrive, "ataraid/d0"); | |
436 | } | |
437 | } else { | |
438 | raid_disk = 1; | |
439 | sprintf(harddrive, "rd/c0d0"); | |
440 | } | |
441 | } else { | |
442 | raid_disk = 1; | |
443 | sprintf(harddrive, "cciss/c0d0"); | |
444 | } | |
445 | } else { | |
446 | raid_disk = 1; | |
447 | sprintf(harddrive, "ida/c0d0"); | |
d6aaa55d | 448 | } |
10bc6f06 MT |
449 | } else { |
450 | sprintf(harddrive, "sda"); | |
d6aaa55d | 451 | } |
d6aaa55d | 452 | scsi_disk = 1; |
10bc6f06 MT |
453 | } else |
454 | sprintf(harddrive, "hd%c", hdletter); | |
455 | ||
456 | /* Make the hdparms struct and print the contents. */ | |
457 | snprintf(hdparams.devnode, STRING_SIZE, "/dev/%s", harddrive); | |
458 | hdparams.module = 0; | |
d6aaa55d MT |
459 | |
460 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], | |
10bc6f06 | 461 | ctr[TR_PREPARE_HARDDISK], hdparams.devnode); |
d6aaa55d MT |
462 | if (rc != 1) |
463 | goto EXIT; | |
464 | ||
465 | /* Calculate amount of memory in machine */ | |
466 | if ((handle = fopen("/proc/meminfo", "r"))) | |
467 | { | |
468 | while (fgets(line, STRING_SIZE-1, handle)) { | |
469 | if (sscanf (line, "MemTotal: %s kB", string)) { | |
470 | memory = atoi(string) / 1024 ; | |
471 | } | |
472 | } | |
473 | fclose(handle); | |
474 | } | |
475 | ||
476 | /* Partition, mkswp, mkfs. | |
477 | * before partitioning, first determine the sizes of each | |
478 | * partition. In order to do that we need to know the size of | |
479 | * the disk. | |
480 | */ | |
481 | /* Don't use mysystem here so we can redirect output */ | |
482 | sprintf(commandstring, "/bin/sfdisk -s /dev/%s > /disksize 2> /dev/null", harddrive); | |
483 | system(commandstring); | |
484 | ||
485 | /* Calculate amount of disk space */ | |
486 | if ((handle = fopen("/disksize", "r"))) | |
487 | { | |
488 | fgets(line, STRING_SIZE-1, handle); | |
489 | if (sscanf (line, "%s", string)) { | |
490 | maximum_free = atoi(string) / 1024; | |
491 | } | |
492 | fclose(handle); | |
493 | } | |
494 | ||
10bc6f06 MT |
495 | fprintf(flog, "maximum_free = %d, memory = %d", |
496 | maximum_free, memory); | |
d6aaa55d MT |
497 | |
498 | /* If you need more than this, you should really add physical memory */ | |
499 | /* Minimum: 192 = 64 real + 128 swap */ | |
500 | swap_file = memory < 64 ? 2 * memory : 192 - memory ; | |
501 | swap_file = swap_file < 32 ? 32 : swap_file ; | |
502 | ||
503 | if (maximum_free < 135 + swap_file ) | |
504 | { | |
505 | if (maximum_free < 135) { | |
506 | errorbox(ctr[TR_DISK_TOO_SMALL]); | |
507 | goto EXIT; | |
508 | } | |
509 | ||
510 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], ctr[TR_CONTINUE_NO_SWAP]); | |
511 | if (rc != 1) | |
512 | goto EXIT; | |
513 | swap_file = 0; | |
514 | } | |
515 | ||
9badc9e9 | 516 | boot_partition = 20; /* in MB */ |
d6aaa55d MT |
517 | current_free = maximum_free - boot_partition - swap_file; |
518 | ||
519 | /* Give more place for add-on, extend root to 25% of current_free, upper limit to 8 gigas */ | |
520 | root_partition = current_free / 4 ; | |
521 | root_partition = root_partition > 8192 ? 8192 : root_partition ; | |
522 | root_partition = current_free < 860 ? 235 : root_partition; | |
523 | root_partition = current_free < 380 ? 110 : root_partition; | |
524 | ||
525 | current_free = current_free - root_partition; | |
526 | root_partition = root_partition + swap_file; | |
527 | ||
528 | log_partition = current_free; | |
529 | ||
530 | fprintf(flog, "boot = %d, swap = %d, mylog = %d, root = %d\n", | |
531 | boot_partition, swap_file, log_partition, root_partition); | |
532 | ||
10bc6f06 | 533 | |
d6aaa55d MT |
534 | #ifdef __alpha__ |
535 | fdisk = 1; | |
536 | #endif | |
537 | ||
538 | if (fdisk) { | |
539 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], "NOW FDISK"); | |
540 | if (rc != 1) | |
541 | goto EXIT; | |
542 | } else { | |
543 | #ifdef __i386__ | |
544 | handle = fopen("/tmp/partitiontable", "w"); | |
545 | ||
546 | fprintf(handle, ",%d,83,*\n,%d,83,\n,0,0,\n,,83,\n", | |
547 | boot_partition, log_partition); | |
548 | ||
549 | fclose(handle); | |
550 | ||
10bc6f06 | 551 | snprintf(commandstring, STRING_SIZE, "/bin/sfdisk -uM %s < /tmp/partitiontable", hdparams.devnode); |
d6aaa55d MT |
552 | if (runcommandwithstatus(commandstring, ctr[TR_PARTITIONING_DISK])) |
553 | { | |
554 | errorbox(ctr[TR_UNABLE_TO_PARTITION]); | |
555 | goto EXIT; | |
556 | } | |
557 | #endif | |
558 | } | |
10bc6f06 MT |
559 | |
560 | if (raid_disk) | |
561 | snprintf(commandstring, STRING_SIZE, "/bin/mke2fs -m 0 -j %sp1", hdparams.devnode); | |
562 | else | |
563 | snprintf(commandstring, STRING_SIZE, "/bin/mke2fs -m 0 -j %s1", hdparams.devnode); | |
d6aaa55d MT |
564 | if (runcommandwithstatus(commandstring, ctr[TR_MAKING_BOOT_FILESYSTEM])) |
565 | { | |
566 | errorbox(ctr[TR_UNABLE_TO_MAKE_BOOT_FILESYSTEM]); | |
567 | goto EXIT; | |
568 | } | |
10bc6f06 MT |
569 | if (raid_disk) |
570 | snprintf(commandstring, STRING_SIZE, "/bin/mke2fs -j %sp2", hdparams.devnode); | |
571 | else | |
572 | snprintf(commandstring, STRING_SIZE, "/bin/mke2fs -j %s2", hdparams.devnode); | |
d6aaa55d MT |
573 | if (runcommandwithstatus(commandstring, ctr[TR_MAKING_LOG_FILESYSTEM])) |
574 | { | |
575 | errorbox(ctr[TR_UNABLE_TO_MAKE_LOG_FILESYSTEM]); | |
576 | goto EXIT; | |
577 | } | |
10bc6f06 MT |
578 | if (raid_disk) |
579 | snprintf(commandstring, STRING_SIZE, "/bin/mke2fs -m 1 -j %sp4", hdparams.devnode); | |
580 | else | |
581 | snprintf(commandstring, STRING_SIZE, "/bin/mke2fs -m 1 -j %s4", hdparams.devnode); | |
d6aaa55d | 582 | |
d6aaa55d MT |
583 | if (runcommandwithstatus(commandstring, ctr[TR_MAKING_ROOT_FILESYSTEM])) |
584 | { | |
585 | errorbox(ctr[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM]); | |
586 | goto EXIT; | |
587 | } | |
10bc6f06 MT |
588 | /* Mount harddisk. */ |
589 | if (raid_disk) | |
590 | snprintf(commandstring, STRING_SIZE, "/sbin/mount -t ext2 %sp4 /harddisk", hdparams.devnode); | |
591 | else | |
592 | snprintf(commandstring, STRING_SIZE, "/sbin/mount -t ext2 %s4 /harddisk", hdparams.devnode); | |
d6aaa55d MT |
593 | if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_ROOT_FILESYSTEM])) |
594 | { | |
595 | errorbox(ctr[TR_UNABLE_TO_MOUNT_ROOT_FILESYSTEM]); | |
596 | goto EXIT; | |
597 | } | |
10bc6f06 | 598 | /* Make swapfile */ |
d6aaa55d | 599 | if (swap_file) { |
10bc6f06 | 600 | snprintf(commandstring, STRING_SIZE, "/bin/dd if=/dev/zero of=/harddisk/swapfile bs=1024k count=%d", swap_file); |
d6aaa55d MT |
601 | if (runcommandwithstatus(commandstring, ctr[TR_MAKING_SWAPSPACE])) |
602 | { | |
603 | errorbox(ctr[TR_UNABLE_TO_MAKE_SWAPSPACE]); | |
604 | goto EXIT; | |
605 | } | |
10bc6f06 MT |
606 | snprintf(commandstring, STRING_SIZE, "/bin/mkswap /harddisk/swapfile"); |
607 | if (runcommandwithstatus(commandstring, ctr[TR_MAKING_SWAPSPACE])) | |
d6aaa55d MT |
608 | { |
609 | errorbox(ctr[TR_UNABLE_TO_MAKE_SWAPSPACE]); | |
610 | goto EXIT; | |
611 | } | |
d6aaa55d | 612 | } |
10bc6f06 MT |
613 | mkdir("/harddisk/boot", S_IRWXU|S_IRWXG|S_IRWXO); |
614 | mkdir("/harddisk/var", S_IRWXU|S_IRWXG|S_IRWXO); | |
615 | mkdir("/harddisk/var/log", S_IRWXU|S_IRWXG|S_IRWXO); | |
616 | ||
617 | if (raid_disk) | |
618 | snprintf(commandstring, STRING_SIZE, "/sbin/mount -t ext2 %sp1 /harddisk/boot", hdparams.devnode); | |
619 | else | |
620 | snprintf(commandstring, STRING_SIZE, "/sbin/mount -t ext2 %s1 /harddisk/boot", hdparams.devnode); | |
d6aaa55d | 621 | |
d6aaa55d MT |
622 | if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_BOOT_FILESYSTEM])) |
623 | { | |
624 | errorbox(ctr[TR_UNABLE_TO_MOUNT_BOOT_FILESYSTEM]); | |
625 | goto EXIT; | |
626 | } | |
10bc6f06 MT |
627 | if (swap_file) { |
628 | snprintf(commandstring, STRING_SIZE, "/bin/swapon /harddisk/swapfile"); | |
629 | if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_SWAP_PARTITION])) | |
630 | { | |
631 | errorbox(ctr[TR_UNABLE_TO_MOUNT_SWAP_PARTITION]); | |
632 | goto EXIT; | |
633 | } | |
634 | } | |
635 | if (raid_disk) | |
636 | snprintf(commandstring, STRING_SIZE, "/sbin/mount -t ext2 %sp2 /harddisk/var/log", hdparams.devnode); | |
637 | else | |
638 | snprintf(commandstring, STRING_SIZE, "/sbin/mount -t ext2 %s2 /harddisk/var/log", hdparams.devnode); | |
d6aaa55d MT |
639 | if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_LOG_FILESYSTEM])) |
640 | { | |
641 | errorbox(ctr[TR_UNABLE_TO_MOUNT_LOG_FILESYSTEM]); | |
642 | goto EXIT; | |
643 | } | |
644 | ||
645 | /* Either use tarball from cdrom or download. */ | |
646 | if (installtype == CDROM_INSTALL) | |
647 | snprintf(commandstring, STRING_SIZE, | |
648 | "/bin/tar -C /harddisk -xvzf /cdrom/" SNAME "-" VERSION ".tgz"); | |
649 | else | |
650 | snprintf(commandstring, STRING_SIZE, | |
651 | "/bin/wget -O - %s/" SNAME "-" VERSION ".tgz | /bin/tar -C /harddisk -xvzf -", url); | |
652 | ||
e57bc1fd MT |
653 | /* if (runcommandwithprogress(60, 4, title, commandstring, 4600, |
654 | * ctr[TR_INSTALLING_FILES])) | |
655 | * { | |
656 | * errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]); | |
657 | * goto EXIT; | |
658 | * } | |
659 | */ | |
660 | ||
661 | if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_FILES])) | |
d6aaa55d MT |
662 | { |
663 | errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]); | |
664 | goto EXIT; | |
665 | } | |
e57bc1fd | 666 | |
d6aaa55d MT |
667 | /* Save USB controller type to modules.conf */ |
668 | write_usb_modules_conf(); | |
669 | ||
670 | /* touch the modules.dep files */ | |
10bc6f06 MT |
671 | snprintf(commandstring, STRING_SIZE, |
672 | "/bin/chroot /harddisk /bin/touch /lib/modules/%s/modules.dep", | |
673 | KERNEL_VERSION); | |
674 | mysystem(commandstring); | |
d6aaa55d | 675 | #ifdef __i386__ |
10bc6f06 MT |
676 | snprintf(commandstring, STRING_SIZE, |
677 | "/bin/chroot /harddisk /bin/touch /lib/modules/%s-smp/modules.dep", | |
678 | KERNEL_VERSION); | |
679 | mysystem(commandstring); | |
d6aaa55d MT |
680 | #endif |
681 | ||
682 | /* Rename uname */ | |
683 | rename ("/harddisk/bin/uname.bak", "/harddisk/bin/uname"); | |
684 | ||
685 | /* Write PCMCIA Config */ | |
686 | if (pcmcia) { | |
687 | handle = fopen("/harddisk/etc/modules.conf", "a"); | |
688 | if (handle != NULL) { | |
689 | fprintf (handle, "# PCMCIA Settings\n"); | |
690 | fprintf (handle, "alias pcmcia-controller %s\n", pcmcia); | |
691 | fclose(handle); | |
692 | } | |
693 | } | |
694 | ||
695 | handle = fopen("/harddisk/etc/pcmcia.conf", "w"); | |
696 | if (handle != NULL) { | |
697 | if (pcmcia) { | |
698 | fprintf (handle, "PCMCIA=yes\n"); | |
699 | fprintf (handle, "PCIC=%s\n", pcmcia); | |
700 | } else { | |
701 | fprintf (handle, "PCMCIA=no\n"); | |
702 | fprintf (handle, "PCIC=\n"); | |
703 | } | |
704 | fprintf (handle, "CARDMGR_OPTS=\n"); | |
705 | fprintf (handle, "SCHEME=\n"); | |
706 | fclose(handle); | |
707 | } | |
708 | ||
709 | /* *always* write disk configuration */ | |
710 | if (!(write_disk_configs(&hdparams))){ | |
10bc6f06 MT |
711 | errorbox(ctr[TR_ERROR_WRITING_CONFIG]); |
712 | goto EXIT; | |
d6aaa55d MT |
713 | } |
714 | ||
715 | /* | |
716 | Allow the user to restore their configuration from a floppy. | |
717 | It uses tar. If the tar fails for any reason, show user an | |
718 | error and go back to the restore/skip question. This gives | |
719 | the user the chance to have another go. */ | |
10bc6f06 | 720 | |
a6753b55 | 721 | #ifdef OLD_RESTORECFG |
10bc6f06 MT |
722 | RESTORE: |
723 | /* set status variables to nonsense values */ | |
724 | allok_fastexit = 0; | |
725 | /* loop until floppy succeeds or user skips out */ | |
726 | while (1) | |
727 | { | |
728 | sprintf(message, ctr[TR_RESTORE_CONFIGURATION], NAME); | |
729 | if (newtWinChoice(title, ctr[TR_RESTORE], ctr[TR_SKIP], message) == 1) | |
730 | { | |
731 | /* Temporarily mount /proc under /harddisk/proc, | |
732 | * run updfstab to locate the floppy, and unmount /harddisk/proc | |
733 | * again. This should be run each time the user tries to restore | |
734 | * so it can properly detect removable devices */ | |
735 | if (mysystem("/bin/mount -n -t proc /proc /harddisk/proc")) { | |
736 | errorbox(ctr[TR_UNABLE_TO_MOUNT_PROC_FILESYSTEM]); | |
737 | goto EXIT; | |
738 | } | |
739 | if (mysystem("/bin/chroot /harddisk /usr/sbin/updfstab")) { | |
740 | errorbox(ctr[TR_UNABLE_TO_WRITE_ETC_FSTAB]); | |
741 | goto EXIT; | |
742 | } | |
743 | mysystem("/bin/umount /harddisk/proc"); | |
744 | ||
745 | mkdir("/harddisk/tmp/ipcop", S_IRWXU|S_IRWXG|S_IRWXO); | |
746 | ||
747 | /* Always extract to /tmp/ipcop for temporary extraction | |
748 | * just in case floppy fails */ | |
749 | ||
750 | /* try a compressed backup first because it's quicker to fail. | |
751 | * In exclude.system, files name must be without leading / or | |
752 | * on extraction, name will never match */ | |
753 | snprintf(commandstring, STRING_SIZE, | |
754 | "/bin/chroot /harddisk /bin/tar -X " CONFIG_ROOT "/backup/exclude.system -C /tmp/ipcop -xvzf /dev/floppy > %s 2> /dev/null", mylog); | |
d6aaa55d | 755 | |
10bc6f06 MT |
756 | statuswindow(45, 4, title, ctr[TR_INSTALLING_FILES]); |
757 | rc = system(commandstring); | |
758 | ||
759 | if (rc) { | |
760 | /* if it's not compressed, try uncompressed first before failing*/ | |
761 | snprintf(commandstring, STRING_SIZE, | |
762 | "/bin/chroot /harddisk /bin/tar -X " CONFIG_ROOT "/backup/exclude.system -C /tmp/ipcop -xvf /dev/floppy > %s 2> /dev/null", mylog); | |
763 | rc = system(commandstring); | |
764 | if (rc) { | |
765 | newtPopWindow(); | |
766 | /* command failed trying to read from floppy */ | |
767 | errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]); | |
768 | ||
769 | /* remove badly restored files */ | |
770 | mysystem("/bin/chroot /harddisk /bin/rm -rf /tmp/ipcop"); | |
771 | goto RESTORE; | |
772 | } else { | |
773 | /* Now copy to correct location */ | |
774 | mysystem("/bin/chroot /harddisk /bin/cp -af /tmp/ipcop/. /"); | |
775 | mysystem("/bin/chroot /harddisk /bin/rm -rf /tmp/ipcop"); | |
776 | newtPopWindow(); | |
777 | allok_fastexit=1; | |
778 | ||
779 | /* Upgrade necessary files from v1.2 to v1.3 to v1.4 */ | |
780 | upgrade_v12_v13(); | |
781 | upgrade_v130_v140(); | |
782 | break; /* out of loop at this point because floppy has | |
783 | successfully restored */ | |
784 | } | |
785 | } | |
786 | else { /* success */ | |
787 | /* Now copy to correct location */ | |
788 | mysystem("/bin/chroot /harddisk /bin/cp -af /tmp/ipcop/. /"); | |
789 | mysystem("/bin/chroot /harddisk /bin/rm -rf /tmp/ipcop"); | |
790 | newtPopWindow(); | |
791 | allok_fastexit=1; | |
792 | ||
793 | /* Upgrade necessary files from v1.2 to v1.3 to v1.4 */ | |
794 | upgrade_v12_v13(); | |
795 | upgrade_v130_v140(); | |
796 | break; /* out of loop at this point because floppy has | |
797 | successfully restored */ | |
798 | } | |
799 | } | |
800 | else{ /* user chose to skip install from floppy */ | |
801 | if (installtype == CDROM_INSTALL){ | |
802 | /* if we installed from CD ROM then we didn't set up the | |
803 | network interface yet. Therefore, set up Network | |
804 | driver and params just before we need them. */ | |
805 | ||
806 | if (!(networkmenu(ethernetkv))){ | |
807 | /* network setup failed, tell the world */ | |
808 | errorbox(ctr[TR_NETWORK_SETUP_FAILED]); | |
809 | goto EXIT; | |
810 | } | |
811 | } | |
812 | break; /* out of loop because we succeeded with ethernet | |
813 | set up and user is notrestarting from floppy*/ | |
814 | } | |
815 | } | |
a6753b55 HS |
816 | #else |
817 | if (installtype == CDROM_INSTALL){ | |
818 | /* if we installed from CD ROM then we didn't set up the | |
819 | network interface yet. Therefore, set up Network | |
820 | driver and params just before we need them. */ | |
821 | ||
822 | if (!(networkmenu(ethernetkv))){ | |
823 | /* network setup failed, tell the world */ | |
824 | errorbox(ctr[TR_NETWORK_SETUP_FAILED]); | |
825 | goto EXIT; | |
826 | } | |
827 | } | |
828 | #endif | |
10bc6f06 MT |
829 | |
830 | /* Check the SQUID acl file exists, if not use our 1.4 copy */ | |
831 | { | |
832 | FILE *aclreadfile; | |
833 | ||
834 | if (!(aclreadfile = fopen ("/harddisk" CONFIG_ROOT "/proxy/acl", "r"))) { | |
835 | rename ("/harddisk" CONFIG_ROOT "/proxy/acl-1.4", | |
836 | "/harddisk" CONFIG_ROOT "/proxy/acl"); | |
837 | } else { | |
838 | unlink ("/harddisk" CONFIG_ROOT "/proxy/acl-1.4"); | |
839 | fclose(aclreadfile); | |
d6aaa55d | 840 | } |
10bc6f06 | 841 | chown ("/harddisk" CONFIG_ROOT "/proxy/acl", 99, 99); |
d6aaa55d MT |
842 | } |
843 | ||
844 | /* Build cache lang file */ | |
845 | mysystem("/bin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT "/lang.pl'; &Lang::BuildCacheLang\""); | |
846 | ||
10bc6f06 MT |
847 | if (!allok_fastexit){ |
848 | /* write ethernet and lang configs only if they have not | |
849 | been restored from floppy already. */ | |
850 | if (!(write_ethernet_configs( ethernetkv))|| | |
851 | !(write_lang_configs(shortlangname))){ | |
852 | errorbox(ctr[TR_ERROR_WRITING_CONFIG]); | |
853 | goto EXIT; | |
854 | } | |
855 | } | |
856 | ||
857 | /* if we detected SCSI then fixup */ | |
858 | if ((handle = fopen("/scsidriver", "r"))) | |
859 | { | |
860 | char *driver; | |
861 | fgets(line, STRING_SIZE-1, handle); | |
862 | fclose(handle); | |
863 | line[strlen(line) - 1] = 0; | |
864 | driver = strtok(line, "."); | |
865 | fprintf(flog, "Detected SCSI driver %s\n",driver); | |
866 | if (strlen(driver) > 1) { | |
f8ae001e | 867 | fprintf(flog, "Fixing up ipfirerd.img\n"); |
10bc6f06 MT |
868 | mysystem("/bin/chroot /harddisk /sbin/modprobe loop"); |
869 | mkdir("/harddisk/initrd", S_IRWXU|S_IRWXG|S_IRWXO); | |
f8ae001e | 870 | snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod --with=%s --with=sd_mod --with=sr_mod --with=libata --with=ataraid /boot/ipfirerd.img %s", driver, KERNEL_VERSION); |
10bc6f06 MT |
871 | runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]); |
872 | #ifdef __i386__ | |
f8ae001e | 873 | snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod --with=%s --with=sd_mod --with=sr_mod --with=libata --with=ataraid /boot/ipfirerd-smp.img %s-smp", driver, KERNEL_VERSION); |
10bc6f06 MT |
874 | runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]); |
875 | mysystem("/bin/chroot /harddisk /bin/mv /boot/grub/scsigrub.conf /boot/grub/grub.conf"); | |
876 | #endif | |
877 | #ifdef __alpha__ | |
878 | snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /bin/mv /boot/etc/scsiaboot.conf /boot/etc/aboot.conf"); | |
879 | runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]); | |
880 | #endif | |
d6aaa55d MT |
881 | } |
882 | } | |
883 | ||
d6aaa55d MT |
884 | #if 0 /* not yet */ |
885 | if (pcmcia_disk) | |
886 | { | |
887 | fprintf(flog, "Detected SCSI driver PCMCIA\n"); | |
f8ae001e | 888 | fprintf(flog, "Fixing up ipfirerd.img\n"); |
d6aaa55d MT |
889 | mysystem("/bin/chroot /harddisk /sbin/modprobe loop"); |
890 | mkdir("/harddisk/initrd", S_IRWXU|S_IRWXG|S_IRWXO); | |
f8ae001e | 891 | snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /sbin/pcinitrd -r %s /boot/ipfirerd.img", KERNEL_VERSION); |
10bc6f06 | 892 | mysystem(commandstring); |
d6aaa55d MT |
893 | #ifdef __i386__ |
894 | mysystem("/bin/chroot /harddisk /bin/mv /boot/grub/scsigrub.conf /boot/grub/grub.conf"); | |
895 | #endif | |
896 | #ifdef __alpha__ | |
897 | mysystem("/bin/chroot /harddisk /bin/mv /boot/etc/scsiaboot.conf /boot/etc/aboot.conf"); | |
898 | #endif | |
899 | } | |
900 | #endif | |
901 | ||
902 | #ifdef __i386__ | |
10bc6f06 | 903 | replace( "/harddisk/boot/grub/grubbatch", "DEVICE", hdparams.devnode); |
d6aaa55d MT |
904 | /* restore permissions */ |
905 | chmod("/harddisk/boot/grub/grubbatch", S_IXUSR | S_IRUSR | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH); | |
906 | ||
10bc6f06 MT |
907 | if (raid_disk) |
908 | sprintf(string, "root=%sp4", hdparams.devnode); | |
909 | else | |
910 | sprintf(string, "root=%s4", hdparams.devnode); | |
d6aaa55d MT |
911 | replace( "/harddisk/boot/grub/grub.conf", "root=ROOT", string); |
912 | ||
913 | mysystem("/bin/chroot /harddisk /bin/mount -n -t proc none /proc"); | |
914 | ||
10bc6f06 MT |
915 | snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /boot/grub/grubbatch"); |
916 | ||
917 | if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_GRUB])) | |
d6aaa55d MT |
918 | { |
919 | errorbox(ctr[TR_UNABLE_TO_INSTALL_GRUB]); | |
920 | goto EXIT; | |
921 | } | |
f8ae001e | 922 | /* Set Bootsplash */ |
5433e2c9 | 923 | mysystem("/bin/installbootsplash.sh"); |
d6aaa55d MT |
924 | mysystem("/bin/chroot /harddisk /bin/umount -n /proc"); |
925 | #endif | |
926 | #ifdef __alpha__ | |
10bc6f06 | 927 | snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /sbin/swriteboot -f3 %s /boot/bootlx", hdparams.devnode); |
d6aaa55d | 928 | mysystem(commandstring); |
10bc6f06 | 929 | snprintf(commandstring, STRING_SIZE, "/bin/chroot /harddisk /sbin/abootconf %s 1", hdparams.devnode); |
d6aaa55d | 930 | mysystem(commandstring); |
10bc6f06 MT |
931 | if (raid_disk) |
932 | sprintf(string, "root=%sp4", hdparams.devnode); | |
933 | else | |
934 | sprintf(string, "root=%s4", hdparams.devnode); | |
d6aaa55d MT |
935 | replace( "/harddisk/boot/etc/aboot.conf", "root=ROOT", string); |
936 | #endif | |
937 | ||
938 | /* unmounting happens everywhere because there are places | |
939 | which require device is to be unmounted under certain | |
940 | circumstances. This is the last place we can unmount | |
10bc6f06 | 941 | anything and still succeed. */ |
d6aaa55d | 942 | |
10bc6f06 MT |
943 | if (!unmount_before && installtype == CDROM_INSTALL){ |
944 | if (mysystem("/sbin/umount /cdrom")) | |
945 | { | |
946 | errorbox(ctr[TR_UNABLE_TO_UNMOUNT_CDROM]); | |
947 | goto EXIT; | |
948 | } | |
d6aaa55d MT |
949 | } |
950 | ||
10bc6f06 | 951 | if (installtype == CDROM_INSTALL) |
d6aaa55d | 952 | { |
10bc6f06 MT |
953 | |
954 | if (!(ejectcdrom(cdromparams.devnode))) | |
d6aaa55d MT |
955 | { |
956 | errorbox(ctr[TR_UNABLE_TO_EJECT_CDROM]); | |
957 | // goto EXIT; | |
958 | } | |
959 | } | |
10bc6f06 MT |
960 | |
961 | ||
962 | sprintf(message, ctr[TR_CONGRATULATIONS_LONG], | |
d6aaa55d MT |
963 | NAME, SNAME, SNAME, NAME, NAME, NAME); |
964 | newtWinMessage(ctr[TR_CONGRATULATIONS], ctr[TR_OK], message); | |
10bc6f06 | 965 | |
d6aaa55d | 966 | allok = 1; |
10bc6f06 | 967 | |
d6aaa55d | 968 | EXIT: |
10bc6f06 | 969 | fprintf(flog, "Install program ended.\n"); |
d6aaa55d MT |
970 | fflush(flog); |
971 | fclose(flog); | |
972 | ||
10bc6f06 | 973 | if (!(allok)) |
d6aaa55d | 974 | newtWinMessage(title, ctr[TR_OK], ctr[TR_PRESS_OK_TO_REBOOT]); |
10bc6f06 | 975 | |
d6aaa55d | 976 | newtFinished(); |
10bc6f06 | 977 | |
d6aaa55d | 978 | freekeyvalues(ethernetkv); |
d6aaa55d | 979 | |
10bc6f06 | 980 | if (allok && !allok_fastexit) |
d6aaa55d MT |
981 | { |
982 | /* /proc is needed by the module checker. We have to mount it | |
983 | * so it can be seen by setup, which is run chrooted. */ | |
984 | if (system("/sbin/mount proc -t proc /harddisk/proc")) | |
985 | printf("Unable to mount proc in /harddisk."); | |
986 | else | |
987 | { | |
988 | if (system("/bin/chroot /harddisk /usr/local/sbin/setup /dev/tty2 INSTALL")) | |
989 | printf("Unable to run setup.\n"); | |
990 | if (system("/sbin/umount /harddisk/proc")) | |
991 | printf("Unable to umount /harddisk/proc.\n"); | |
992 | } | |
993 | } | |
994 | ||
995 | fcloseall(); | |
996 | ||
997 | system("/bin/swapoff /harddisk/swapfile"); | |
998 | system("/sbin/umount /harddisk/var/log"); | |
999 | system("/sbin/umount /harddisk/boot"); | |
1000 | system("/sbin/umount /harddisk"); | |
10bc6f06 | 1001 | |
d6aaa55d MT |
1002 | system("/etc/halt"); |
1003 | ||
1004 | return 0; | |
1005 | } |