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