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