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