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