]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/install+setup/install/main.c
5dc53bbc20ebeeff0f5b48f3db8c45d8b395f9fe
[people/pmueller/ipfire-2.x.git] / src / install+setup / install / main.c
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 *
9 */
10
11 #include "install.h"
12 #define _GNU_SOURCE
13
14 #define CDROM_INSTALL 0
15 #define URL_INSTALL 1
16 #define DISK_INSTALL 2
17 #define INST_FILECOUNT 7000
18 #define UNATTENDED_CONF "/cdrom/boot/unattended.conf"
19
20 int raid_disk = 0;
21 FILE *flog = NULL;
22 char *mylog;
23
24 char **ctr;
25
26 extern char url[STRING_SIZE];
27
28 struct nic nics[20] = { { "" , "" } }; // only defined for compile
29 struct knic knics[20] = { { "" , "" , "" } }; // only defined for compile
30
31 extern char *en_tr[];
32 extern char *de_tr[];
33
34 int detect_smp() {
35 FILE *fd = NULL;
36 char line[STRING_SIZE];
37 int cpu_count = 0;
38
39 if ((fd = fopen("/proc/cpuinfo", "r")) == NULL) {
40 return 0;
41 }
42 while (fgets(line, STRING_SIZE, fd) != NULL) {
43 if (strstr(line, "processor") == line) {
44 cpu_count++;
45 }
46 }
47 (void)fclose(fd);
48 return (cpu_count > 1);
49 }
50
51 long calc_swapsize(long memory, long disk) {
52 if (memory < 128) {
53 return 256;
54 }
55 if (memory > 1024) {
56 return 512;
57 }
58
59 return memory*2;
60 }
61
62 int main(int argc, char *argv[])
63 {
64 char *langnames[] = { "Deutsch", "English", NULL };
65 char *shortlangnames[] = { "de", "en", NULL };
66 char **langtrs[] = { de_tr, en_tr, NULL };
67 char hdletter;
68 char harddrive[5], sourcedrive[5]; /* Device holder. */
69 struct devparams hdparams, cdromparams; /* Params for CDROM and HD */
70 int cdmounted = 0; /* Loop flag for inserting a cd. */
71 int rc = 0;
72 char commandstring[STRING_SIZE];
73 char *installtypes[] = { "CDROM/USB", "HTTP/FTP", NULL };
74 int installtype = CDROM_INSTALL;
75 int choice;
76 char shortlangname[10];
77 char message[1000];
78 char title[STRING_SIZE];
79 int allok = 0;
80 int allok_fastexit=0;
81 struct keyvalue *ethernetkv = initkeyvalues();
82 FILE *handle, *cmdfile;
83 char line[STRING_SIZE];
84 char string[STRING_SIZE];
85 long maximum_free = 0, current_free;
86 long memory = 0;
87 long system_partition, boot_partition, root_partition, swap_file;
88 int scsi_disk = 0;
89 char *yesnoharddisk[3]; // char *yesnoharddisk = { "NO", "YES", NULL };
90
91 int unattended = 0;
92 struct keyvalue *unattendedkv = initkeyvalues();
93 int hardyn = 0;
94
95 setlocale (LC_ALL, "");
96 sethostname( SNAME , 10);
97
98 memset(&hdparams, 0, sizeof(struct devparams));
99 memset(&cdromparams, 0, sizeof(struct devparams));
100
101 /* Log file/terminal stuff. */
102 if (argc >= 2)
103 {
104 if (!(flog = fopen(argv[1], "w+")))
105 return 0;
106 }
107 else
108 return 0;
109
110 mylog = argv[1];
111
112 fprintf(flog, "Install program started.\n");
113
114 newtInit();
115 newtCls();
116
117 /* Do usb detection first for usb keyboard */
118 if (! (cmdfile = fopen("/proc/cmdline", "r")))
119 {
120 fprintf(flog, "Couldn't open commandline: /proc/cmdline\n");
121 } else {
122 fgets(line, STRING_SIZE, cmdfile);
123 if (strstr (line, "nousb") == NULL) {
124 fprintf(flog, "Initializing USB controllers.\n");
125 initialize_usb();
126 } else {
127 fprintf(flog, "Skipping USB detection.\n");
128 }
129 // check if we have to make an unattended install
130 if (strstr (line, "unattended") != NULL) {
131 unattended = 1;
132 }
133 }
134
135 if (unattended) {
136 runcommandwithstatus("/bin/sleep 10", "WARNING: Unattended installation will start in 10 seconds...");
137 }
138
139 /* German is the default */
140 for (choice = 0; langnames[choice]; choice++)
141 {
142 if (strcmp(langnames[choice], "Deutsch") == 0)
143 break;
144 }
145 if (!langnames[choice])
146 goto EXIT;
147
148 if (!unattended) {
149 rc = newtWinMenu("Language selection",
150 "Select the language you wish to use for the " NAME ".", 50, 5, 5, 8,
151 langnames, &choice, "Ok", NULL);
152 }
153
154 ctr = langtrs[choice];
155 strcpy(shortlangname, shortlangnames[choice]);
156 fprintf(flog, "Selected language: %s\n", shortlangname);
157
158 mysystem("/bin/setfont lat0-16");
159
160 newtDrawRootText(14, 0, NAME " " VERSION " - " SLOGAN );
161 newtPushHelpLine(ctr[TR_HELPLINE]);
162 sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
163
164 if (!unattended) {
165 sprintf(message, ctr[TR_WELCOME], NAME);
166 newtWinMessage(title, ctr[TR_OK], message);
167
168 sprintf(message, ctr[TR_SELECT_INSTALLATION_MEDIA_LONG], NAME);
169 rc = newtWinMenu(ctr[TR_SELECT_INSTALLATION_MEDIA], message,
170 50, 5, 5, 6, installtypes, &installtype, ctr[TR_OK],
171 ctr[TR_CANCEL], NULL);
172 } else {
173 rc = 1;
174 installtype = CDROM_INSTALL;
175 }
176
177 if (rc == 2)
178 goto EXIT;
179
180 // Starting hardware detection
181 runcommandwithstatus("/bin/probehw.sh", ctr[TR_PROBING_HARDWARE]);
182 runcommandwithstatus("/bin/probenic.sh install", ctr[TR_PROBING_HARDWARE]);
183
184 /* CDROM INSTALL */
185 if (installtype == CDROM_INSTALL) {
186 switch (mysystem("/bin/mountsource.sh")) {
187 case 0:
188 installtype = CDROM_INSTALL;
189 cdmounted = 1;
190 break;
191 case 1:
192 installtype = DISK_INSTALL;
193 break;
194 case 10:
195 errorbox(ctr[TR_NO_CDROM]);
196 goto EXIT;
197 }
198
199 /* read source drive letter */
200 if ((handle = fopen("/tmp/source_device", "r")) == NULL) {
201 errorbox(ctr[TR_ERROR_PROBING_CDROM]);
202 goto EXIT;
203 }
204 fgets(sourcedrive, 5, handle);
205 fprintf(flog, "Source drive: %s\n", sourcedrive);
206 fclose(handle);
207
208 //snprintf(cdromparams.devnode_disk, STRING_SIZE, "/dev/%s", sourcedrive);
209 fprintf(flog, "Source device: %s\n", sourcedrive);
210 }
211
212 /* Configure the network now! */
213 if (installtype == URL_INSTALL) {
214 /* Network driver and params. */
215 if (!(networkmenu(ethernetkv))) {
216 errorbox(ctr[TR_NETWORK_SETUP_FAILED]);
217 goto EXIT;
218 }
219
220 /* Check for ipfire-<VERSION>.tbz2 */
221 if (checktarball(SNAME "-" VERSION ".tbz2", ctr[TR_ENTER_URL])) {
222 errorbox(ctr[TR_NO_IPCOP_TARBALL_FOUND]);
223 goto EXIT;
224 }
225 }
226
227 // Now try to find destination device...
228 if ((hdletter = findidetype(IDE_HD))) {
229 sprintf(harddrive, "hd%c", hdletter);
230 goto FOUND_DESTINATION;
231 }
232
233 /* Need to clean this up at some point
234 scsi disk is sdb/sdc when sda/sdb is used for usb-key
235 if scsi-disk is sdd or more, it is not discovered
236 Support only 2 usb keys, none could be unplugged */
237 if (checkusb("sdb") && try_scsi("sdc")) {
238 scsi_disk = 1;
239 sprintf(harddrive, "sdc");
240 goto FOUND_DESTINATION;
241 }
242 if (checkusb("sda") && try_scsi("sdb")) {
243 scsi_disk = 1;
244 sprintf(harddrive, "sdb");
245 goto FOUND_DESTINATION;
246 }
247 if (try_scsi("sda")) {
248 scsi_disk = 1;
249 sprintf(harddrive, "sda");
250 goto FOUND_DESTINATION;
251 }
252 if (try_scsi("ida/c0d0")) {
253 raid_disk = 1;
254 sprintf(harddrive, "ida/c0d0");
255 goto FOUND_DESTINATION;
256 }
257 if (try_scsi("cciss/c0d0")) {
258 raid_disk = 1;
259 sprintf(harddrive, "cciss/c0d0");
260 goto FOUND_DESTINATION;
261 }
262 if (try_scsi("rd/c0d0")) {
263 raid_disk = 1;
264 sprintf(harddrive, "rd/c0d0");
265 goto FOUND_DESTINATION;
266 }
267 if (try_scsi("ataraid/d0")) {
268 raid_disk = 1;
269 sprintf(harddrive, "ataraid/d0");
270 goto FOUND_DESTINATION;
271 }
272 /* nothing worked, give up */
273 errorbox(ctr[TR_NO_HARDDISK]);
274 goto EXIT;
275
276 FOUND_DESTINATION:
277 /* load unattended configuration */
278 if (unattended) {
279 fprintf(flog, "unattended: Reading unattended.conf\n");
280
281 (void) readkeyvalues(unattendedkv, UNATTENDED_CONF);
282 }
283
284 /* Make the hdparms struct and print the contents.
285 With USB-KEY install and SCSI disk, while installing, the disk
286 is named 'sdb,sdc,...' (following keys)
287 On reboot, it will become 'sda'
288 To avoid many test, all names are built in the struct.
289 */
290 sprintf(hdparams.devnode_disk, "/dev/%s", harddrive);
291 /* Address the partition or raid partition (eg dev/sda or /dev/sdap1 */
292 sprintf(hdparams.devnode_part, "/dev/%s%s", harddrive,raid_disk ? "p" : "");
293 /* Now the names after the machine is booted. Only scsi is affected
294 and we only install on the first scsi disk. */
295 { char tmp[30];
296 strcpy(tmp, scsi_disk ? "sda" : harddrive);
297 sprintf(hdparams.devnode_disk_run, "/dev/%s", tmp);
298 sprintf(hdparams.devnode_part_run, "/dev/%s%s", tmp, raid_disk ? "p" : "");
299 }
300
301 fprintf(flog, "Destination drive: %s\n", hdparams.devnode_disk);
302
303 sprintf(message, ctr[TR_PREPARE_HARDDISK], hdparams.devnode_disk);
304 if (unattended) {
305 hardyn = 1;
306 }
307
308 yesnoharddisk[0] = ctr[TR_NO];
309 yesnoharddisk[1] = ctr[TR_YES];
310 yesnoharddisk[2] = NULL;
311
312 while (! hardyn) {
313 rc = newtWinMenu(title, message,
314 50, 5, 5, 6, yesnoharddisk,
315 &hardyn, ctr[TR_OK],
316 ctr[TR_CANCEL], NULL);
317 if (rc == 2)
318 goto EXIT;
319 }
320 if (rc == 2)
321 goto EXIT;
322
323 /* Calculate amount of memory in machine */
324 if ((handle = fopen("/proc/meminfo", "r")))
325 {
326 while (fgets(line, STRING_SIZE-1, handle)) {
327 if (sscanf (line, "MemTotal: %s kB", string)) {
328 memory = atoi(string) / 1024 ;
329 }
330 }
331 fclose(handle);
332 }
333
334 /* Partition, mkswp, mkfs.
335 * before partitioning, first determine the sizes of each
336 * partition. In order to do that we need to know the size of
337 * the disk.
338 */
339 /* Don't use mysystem here so we can redirect output */
340 sprintf(commandstring, "/bin/sfdisk -s /dev/%s > /tmp/disksize 2> /dev/null", harddrive);
341 system(commandstring);
342
343 /* Calculate amount of disk space */
344 if ((handle = fopen("/tmp/disksize", "r")))
345 {
346 fgets(line, STRING_SIZE-1, handle);
347 if (sscanf (line, "%s", string)) {
348 maximum_free = atoi(string) / 1024;
349 }
350 fclose(handle);
351 }
352
353 fprintf(flog, "maximum_free = %ld, memory = %ld",
354 maximum_free, memory);
355
356 swap_file = calc_swapsize(memory, maximum_free);
357
358 if (maximum_free < 512 + swap_file ) {
359 if (maximum_free < 512) {
360 errorbox(ctr[TR_DISK_TOO_SMALL]);
361 goto EXIT;
362 }
363
364 if (!unattended) {
365 rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], ctr[TR_CONTINUE_NO_SWAP]);
366 }
367 else {
368 rc = 1;
369 }
370
371 if (rc != 1)
372 goto EXIT;
373 swap_file = 0;
374 }
375
376 boot_partition = 20; /* in MB */
377 current_free = maximum_free - boot_partition - swap_file;
378
379 root_partition = 2048 ;
380 if (current_free < 512) {
381 errorbox(ctr[TR_DISK_TOO_SMALL]);
382 goto EXIT;
383 }
384
385 current_free = current_free - root_partition;
386 if (!swap_file) {
387 root_partition = root_partition + swap_file;
388 }
389
390 system_partition = current_free;
391
392 fprintf(flog, "boot = %ld, swap = %ld, mylog = %ld, root = %ld\n",
393 boot_partition, swap_file, system_partition, root_partition);
394
395 handle = fopen("/tmp/partitiontable", "w");
396
397 /* Make swapfile */
398 if (swap_file) {
399 fprintf(handle, ",%ld,L,*\n,%ld,S,\n,%ld,L,\n,,L,\n",
400 boot_partition, swap_file, root_partition);
401 } else {
402 fprintf(handle, ",%ld,L,*\n,0,0,\n,%ld,L,\n,,L,\n",
403 boot_partition, root_partition);
404 }
405
406 fclose(handle);
407
408 snprintf(commandstring, STRING_SIZE, "/bin/sfdisk -L -uM %s < /tmp/partitiontable", hdparams.devnode_disk);
409 if (runcommandwithstatus(commandstring, ctr[TR_PARTITIONING_DISK]))
410 {
411 errorbox(ctr[TR_UNABLE_TO_PARTITION]);
412 goto EXIT;
413 }
414
415 mysystem("/sbin/udevstart");
416
417 snprintf(commandstring, STRING_SIZE, "/bin/mke2fs -T ext2 -c %s1", hdparams.devnode_part);
418 if (runcommandwithstatus(commandstring, ctr[TR_MAKING_BOOT_FILESYSTEM]))
419 {
420 errorbox(ctr[TR_UNABLE_TO_MAKE_BOOT_FILESYSTEM]);
421 goto EXIT;
422 }
423
424 if (swap_file) {
425 snprintf(commandstring, STRING_SIZE, "/sbin/mkswap %s2", hdparams.devnode_part);
426 if (runcommandwithstatus(commandstring, ctr[TR_MAKING_SWAPSPACE]))
427 {
428 errorbox(ctr[TR_UNABLE_TO_MAKE_SWAPSPACE]);
429 goto EXIT;
430 }
431 }
432
433 snprintf(commandstring, STRING_SIZE, "/sbin/mkreiserfs -f %s3", hdparams.devnode_part);
434 if (runcommandwithstatus(commandstring, ctr[TR_MAKING_ROOT_FILESYSTEM]))
435 {
436 errorbox(ctr[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM]);
437 goto EXIT;
438 }
439
440 snprintf(commandstring, STRING_SIZE, "/sbin/mkreiserfs -f %s4", hdparams.devnode_part);
441 if (runcommandwithstatus(commandstring, ctr[TR_MAKING_LOG_FILESYSTEM]))
442 {
443 errorbox(ctr[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM]);
444 goto EXIT;
445 }
446
447 /* Mount harddisk. */
448
449 snprintf(commandstring, STRING_SIZE, "/bin/mount %s3 /harddisk", hdparams.devnode_part);
450 if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_ROOT_FILESYSTEM]))
451 {
452 errorbox(ctr[TR_UNABLE_TO_MOUNT_ROOT_FILESYSTEM]);
453 goto EXIT;
454 }
455
456 mkdir("/harddisk/boot", S_IRWXU|S_IRWXG|S_IRWXO);
457 mkdir("/harddisk/var", S_IRWXU|S_IRWXG|S_IRWXO);
458 mkdir("/harddisk/var/log", S_IRWXU|S_IRWXG|S_IRWXO);
459
460 snprintf(commandstring, STRING_SIZE, "/bin/mount %s1 /harddisk/boot", hdparams.devnode_part);
461 if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_BOOT_FILESYSTEM]))
462 {
463 errorbox(ctr[TR_UNABLE_TO_MOUNT_BOOT_FILESYSTEM]);
464 goto EXIT;
465 }
466 if (swap_file) {
467 snprintf(commandstring, STRING_SIZE, "/sbin/swapon %s2", hdparams.devnode_part);
468 if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_SWAP_PARTITION]))
469 {
470 errorbox(ctr[TR_UNABLE_TO_MOUNT_SWAP_PARTITION]);
471 goto EXIT;
472 }
473 }
474 snprintf(commandstring, STRING_SIZE, "/bin/mount %s4 /harddisk/var", hdparams.devnode_part);
475 if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_LOG_FILESYSTEM]))
476 {
477 errorbox(ctr[TR_UNABLE_TO_MOUNT_LOG_FILESYSTEM]);
478 goto EXIT;
479 }
480
481 if (installtype == URL_INSTALL) {
482 snprintf(commandstring, STRING_SIZE,
483 "/bin/wget -q -O - %s/" SNAME "-" VERSION ".tbz2 | /bin/tar -C /harddisk -xvjf -", url);
484 }
485
486 if (installtype == CDROM_INSTALL) {
487 snprintf(commandstring, STRING_SIZE,
488 "/bin/tar -C /harddisk -xvjf /cdrom/" SNAME "-" VERSION ".tbz2");
489 }
490
491 if (runcommandwithprogress(60, 4, title, commandstring, INST_FILECOUNT,
492 ctr[TR_INSTALLING_FILES]))
493 {
494 errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);
495 goto EXIT;
496 }
497
498 /* Save USB controller type to modules.conf */
499 write_usb_modules_conf();
500
501 /* Save language und local settings */
502 write_lang_configs(shortlangname);
503
504 /* touch the modules.dep files */
505 snprintf(commandstring, STRING_SIZE,
506 "/bin/touch /harddisk/lib/modules/%s-ipfire/modules.dep",
507 KERNEL_VERSION);
508 mysystem(commandstring);
509 snprintf(commandstring, STRING_SIZE,
510 "/bin/touch /harddisk/lib/modules/%s-ipfire-smp/modules.dep",
511 KERNEL_VERSION);
512 mysystem(commandstring);
513
514 /* Rename uname */
515 rename ("/harddisk/bin/uname.bak", "/harddisk/bin/uname");
516
517 /* mount proc filesystem */
518 mysystem("mkdir /harddisk/proc");
519 mysystem("/bin/mount -t proc none /harddisk/proc");
520 mysystem("/bin/mount --bind /dev /harddisk/dev");
521
522 /* Build cache lang file */
523 snprintf(commandstring, STRING_SIZE, "/sbin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT "/lang.pl'; &Lang::BuildCacheLang\"");
524 if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_LANG_CACHE]))
525 {
526 errorbox(ctr[TR_UNABLE_TO_INSTALL_LANG_CACHE]);
527 goto EXIT;
528 }
529
530 /* Update /etc/fstab */
531 replace("/harddisk/etc/fstab", "DEVICE", hdparams.devnode_part_run);
532
533 /* if we detected SCSI/USB then fixup */
534 /* mysystem("/bin/probecntrl.sh");
535 if ((handle = fopen("/tmp/cntrldriver", "r")))
536 {
537 char *driver;
538 fgets(line, STRING_SIZE-1, handle);
539 fclose(handle);
540 line[strlen(line) - 1] = 0;
541 driver = strtok(line, ".");
542 if (strlen(driver) > 1) {
543 fprintf(flog, "Fixing up ipfirerd.img\n");
544 mkdir("/harddisk/initrd", S_IRWXU|S_IRWXG|S_IRWXO);
545 snprintf(commandstring, STRING_SIZE, "/sbin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod %s --with=sd_mod --with=sr_mod /boot/ipfirerd.img %s-ipfire", driver, KERNEL_VERSION);
546 runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]);
547 snprintf(commandstring, STRING_SIZE, "/sbin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod %s --with=sd_mod --with=sr_mod /boot/ipfirerd-smp.img %s-ipfire-smp", driver, KERNEL_VERSION);
548 runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]);
549 mysystem("/sbin/chroot /harddisk /bin/mv /boot/grub/scsigrub.conf /boot/grub/grub.conf");
550 }
551 } */
552
553 sprintf(string, "root=%s3", hdparams.devnode_part_run);
554 replace( "/harddisk/boot/grub/grub.conf", "root=ROOT", string);
555 replace( "/harddisk/boot/grub/grubbatch", "DEVICE", hdparams.devnode_disk);
556
557 /* restore permissions */
558 chmod("/harddisk/boot/grub/grubbatch", S_IXUSR | S_IRUSR | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH);
559
560 snprintf(commandstring, STRING_SIZE,
561 "/sbin/chroot /harddisk /boot/grub/grubbatch");
562 if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_GRUB])) {
563 errorbox(ctr[TR_UNABLE_TO_INSTALL_GRUB]);
564 goto EXIT;
565 }
566
567 /* Install bootsplash */
568 mysystem("/bin/installbootsplash.sh");
569
570 mysystem("ln -s grub.conf /harddisk/boot/grub/menu.lst");
571 // mysystem("umount /harddisk/proc");
572 // mysystem("umount /harddisk/dev");
573
574 if (!unattended) {
575 sprintf(message, ctr[TR_CONGRATULATIONS_LONG],
576 NAME, SNAME, SNAME, NAME, NAME, NAME);
577 newtWinMessage(ctr[TR_CONGRATULATIONS], ctr[TR_OK], message);
578 }
579
580 allok = 1;
581
582 EXIT:
583 fprintf(flog, "Install program ended.\n");
584
585
586
587 if (!(allok))
588 newtWinMessage(title, ctr[TR_OK], ctr[TR_PRESS_OK_TO_REBOOT]);
589
590 freekeyvalues(ethernetkv);
591
592 if (allok && !allok_fastexit)
593 {
594 /* /proc is needed by the module checker. We have to mount it
595 * so it can be seen by setup, which is run chrooted. */
596 // if (system("/bin/mount proc -t proc /harddisk/proc"))
597 // printf("Unable to mount proc in /harddisk.");
598 // else
599 // {
600 if (unattended) {
601 fprintf(flog, "Entering unattended setup\n");
602 if (unattended_setup(unattendedkv)) {
603 snprintf(commandstring, STRING_SIZE, "/bin/sleep 10");
604 runcommandwithstatus(commandstring, "Unattended installation finished, system will reboot");
605 } else {
606 errorbox("Unattended setup failed.");
607 goto EXIT;
608 }
609 }
610
611 fflush(flog);
612 fclose(flog);
613 newtFinished();
614
615 if (!unattended) {
616 // Copy our scanned nics to the disk and lock because scan doesn't work in chroot
617 system("touch /harddisk/var/ipfire/ethernet/scan_lock");
618 system("cp -f /tmp/scanned_nics /harddisk/var/ipfire/ethernet/scanned_nics");
619 if (system("/sbin/chroot /harddisk /usr/local/sbin/setup /dev/tty2 INSTALL"))
620 printf("Unable to run setup.\n");
621 system("rm -f /harddisk/var/ipfire/ethernet/scan_lock");
622 }
623
624 if (system("/bin/umount /harddisk/proc"))
625 printf("Unable to umount /harddisk/proc.\n");
626 // }
627 } else {
628 fflush(flog);
629 fclose(flog);
630 newtFinished();
631 }
632
633 fcloseall();
634
635 if (swap_file) {
636 snprintf(commandstring, STRING_SIZE, "/bin/swapoff %s2", hdparams.devnode_part);
637 }
638
639 newtFinished();
640
641 system("/bin/umount /harddisk/proc");
642 system("/bin/umount /harddisk/dev");
643
644 system("/bin/umount /harddisk/var");
645 system("/bin/umount /harddisk/boot");
646 system("/bin/umount /harddisk");
647
648 system("/etc/halt");
649
650 return 0;
651 }