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