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