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