]> git.ipfire.org Git - ipfire-2.x.git/blob - src/install+setup/install/main.c
Ramdisk-Arbeit nahezu beendet.
[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.
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 7000
18 #define UNATTENDED_CONF "/cdrom/boot/unattended.conf"
19
20 int raid_disk = 0;
21 FILE *flog = NULL;
22 char *mylog;
23
24 char **ctr;
25
26 extern char url[STRING_SIZE];
27
28 extern char *en_tr[];
29 extern char *de_tr[];
30
31 int detect_smp() {
32 FILE *fd = NULL;
33 char line[STRING_SIZE];
34 int cpu_count = 0;
35
36 if ((fd = fopen("/proc/cpuinfo", "r")) == NULL) {
37 return 0;
38 }
39 while (fgets(line, STRING_SIZE, fd) != NULL) {
40 if (strstr(line, "processor") == line) {
41 cpu_count++;
42 }
43 }
44 (void)fclose(fd);
45 return (cpu_count > 1);
46 }
47
48 long calc_swapsize(long memory, long disk) {
49 if (memory < 128) {
50 return 256;
51 }
52 if (memory > 1024) {
53 return 512;
54 }
55
56 return memory*2;
57 }
58
59 int main(int argc, char *argv[])
60 {
61 char *langnames[] = { "Deutsch", "English", NULL };
62 char *shortlangnames[] = { "de", "en", NULL };
63 char **langtrs[] = { de_tr, en_tr, NULL };
64 char hdletter;
65 char harddrive[5], sourcedrive[5]; /* Device holder. */
66 struct devparams hdparams, cdromparams; /* Params for CDROM and HD */
67 int cdmounted = 0; /* Loop flag for inserting a cd. */
68 int rc = 0;
69 char commandstring[STRING_SIZE];
70 char *installtypes[] = { "CDROM/USB", "HTTP/FTP", NULL };
71 int installtype = CDROM_INSTALL;
72 int choice;
73 char shortlangname[10];
74 char message[1000];
75 char title[STRING_SIZE];
76 int allok = 0;
77 int allok_fastexit=0;
78 struct keyvalue *ethernetkv = initkeyvalues();
79 FILE *handle, *cmdfile;
80 char line[STRING_SIZE];
81 char string[STRING_SIZE];
82 long maximum_free = 0, current_free;
83 long memory = 0;
84 long system_partition, boot_partition, root_partition, swap_file;
85 int scsi_disk = 0;
86 char *yesnoharddisk[] = { "NO", "YES", NULL };
87 int unattended = 0;
88 struct keyvalue *unattendedkv = initkeyvalues();
89 int hardyn = 0;
90
91 setlocale (LC_ALL, "");
92 sethostname( SNAME , 10);
93
94 memset(&hdparams, 0, sizeof(struct devparams));
95 memset(&cdromparams, 0, sizeof(struct devparams));
96
97 /* Log file/terminal stuff. */
98 if (argc >= 2)
99 {
100 if (!(flog = fopen(argv[1], "w+")))
101 return 0;
102 }
103 else
104 return 0;
105
106 mylog = argv[1];
107
108 fprintf(flog, "Install program started.\n");
109
110 newtInit();
111 newtCls();
112
113 /* Do usb detection first for usb keyboard */
114 if (! (cmdfile = fopen("/proc/cmdline", "r")))
115 {
116 fprintf(flog, "Couldn't open commandline: /proc/cmdline\n");
117 } else {
118 fgets(line, STRING_SIZE, cmdfile);
119 if (strstr (line, "nousb") == NULL) {
120 fprintf(flog, "Initializing USB controllers.\n");
121 initialize_usb();
122 } else {
123 fprintf(flog, "Skipping USB detection.\n");
124 }
125 // check if we have to make an unattended install
126 if (strstr (line, "unattended") != NULL) {
127 unattended = 1;
128 }
129 }
130
131 if (unattended) {
132 runcommandwithstatus("/bin/sleep 10", "WARNING: Unattended installation will start in 10 seconds...");
133 }
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",
146 "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 mysystem("/bin/setfont lat0-16");
154
155 newtDrawRootText(14, 0, NAME " " VERSION " - " SLOGAN );
156 newtPushHelpLine(ctr[TR_HELPLINE]);
157 sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
158
159 if (!unattended) {
160 sprintf(message, ctr[TR_WELCOME], NAME);
161 newtWinMessage(title, ctr[TR_OK], message);
162
163 sprintf(message, ctr[TR_SELECT_INSTALLATION_MEDIA_LONG], NAME);
164 rc = newtWinMenu(ctr[TR_SELECT_INSTALLATION_MEDIA], message,
165 50, 5, 5, 6, installtypes, &installtype, ctr[TR_OK],
166 ctr[TR_CANCEL], NULL);
167 } else {
168 rc = 1;
169 installtype = CDROM_INSTALL;
170 }
171
172 if (rc == 2)
173 goto EXIT;
174
175 // Starting hardware detection
176 runcommandwithstatus("/bin/probehw.sh", ctr[TR_PROBING_HARDWARE]);
177
178 /* CDROM INSTALL */
179 if (installtype == CDROM_INSTALL) {
180 switch (mysystem("/bin/mountsource.sh")) {
181 case 0:
182 installtype = CDROM_INSTALL;
183 cdmounted = 1;
184 break;
185 case 1:
186 installtype = DISK_INSTALL;
187 break;
188 case 10:
189 errorbox(ctr[TR_NO_CDROM]);
190 goto EXIT;
191 }
192
193 /* read source drive letter */
194 if ((handle = fopen("/tmp/source_device", "r")) == NULL) {
195 errorbox(ctr[TR_ERROR_PROBING_CDROM]);
196 goto EXIT;
197 }
198 fgets(sourcedrive, 5, handle);
199 fprintf(flog, "Source drive: %s\n", sourcedrive);
200 fclose(handle);
201
202 snprintf(cdromparams.devnode, STRING_SIZE, "/dev/%s", sourcedrive);
203 cdromparams.module = 0;
204 fprintf(flog, "Source device: %s\n", cdromparams.devnode);
205 }
206
207 /* Configure the network now! */
208 if (installtype == URL_INSTALL) {
209 /* Network driver and params. */
210 if (!(networkmenu(ethernetkv))) {
211 errorbox(ctr[TR_NETWORK_SETUP_FAILED]);
212 goto EXIT;
213 }
214
215 /* Check for ipfire-<VERSION>.tbz2 */
216 if (checktarball(SNAME "-" VERSION ".tbz2", ctr[TR_ENTER_URL])) {
217 errorbox(ctr[TR_NO_IPCOP_TARBALL_FOUND]);
218 goto EXIT;
219 }
220 }
221
222 /* Get device for the HD. This has to succeed. */
223 if (!(hdletter = findidetype(IDE_HD)))
224 {
225 /* Need to clean this up at some point */
226 if (!try_scsi("sda") || strstr(sourcedrive, "sda") != NULL) {
227 if (!try_scsi("ida/c0d0")) {
228 if (!try_scsi("cciss/c0d0")) {
229 if (!try_scsi("rd/c0d0")) {
230 if (!try_scsi("ataraid/d0")) {
231 errorbox(ctr[TR_NO_HARDDISK]);
232 goto EXIT;
233 } else {
234 raid_disk = 1;
235 sprintf(harddrive, "ataraid/d0");
236 }
237 } else {
238 raid_disk = 1;
239 sprintf(harddrive, "rd/c0d0");
240 }
241 } else {
242 raid_disk = 1;
243 sprintf(harddrive, "cciss/c0d0");
244 }
245 } else {
246 raid_disk = 1;
247 sprintf(harddrive, "ida/c0d0");
248 }
249 } else {
250 if (strstr(sourcedrive, "sda") != NULL) {
251 // probably installing from usb stick, try sdb
252 if (try_scsi("sdb")) {
253 sprintf(harddrive, "sdb");
254 }
255 else {
256 errorbox(ctr[TR_NO_HARDDISK]);
257 goto EXIT;
258 }
259 }
260 else {
261 sprintf(harddrive, "sda");
262 }
263 }
264 scsi_disk = 1;
265 } else
266 sprintf(harddrive, "hd%c", hdletter);
267
268 fprintf(flog, "Destination drive: %s\n", harddrive);
269
270 /* load unattended configuration */
271 if (unattended) {
272 fprintf(flog, "unattended: Reading unattended.conf\n");
273
274 (void) readkeyvalues(unattendedkv, UNATTENDED_CONF);
275 }
276
277 /* Make the hdparms struct and print the contents. */
278 snprintf(hdparams.devnode, STRING_SIZE, "/dev/%s", harddrive);
279 hdparams.module = 0;
280
281 sprintf(message, ctr[TR_PREPARE_HARDDISK], hdparams.devnode);
282
283 if (unattended) {
284 hardyn = 1;
285 }
286
287 while (! hardyn) {
288 rc = newtWinMenu(title, message,
289 50, 5, 5, 6, yesnoharddisk,
290 &hardyn, ctr[TR_OK],
291 ctr[TR_CANCEL], NULL);
292 if (rc == 2)
293 goto EXIT;
294 }
295
296 if (rc == 2)
297 goto EXIT;
298
299 /* Calculate amount of memory in machine */
300 if ((handle = fopen("/proc/meminfo", "r")))
301 {
302 while (fgets(line, STRING_SIZE-1, handle)) {
303 if (sscanf (line, "MemTotal: %s kB", string)) {
304 memory = atoi(string) / 1024 ;
305 }
306 }
307 fclose(handle);
308 }
309
310 /* Partition, mkswp, mkfs.
311 * before partitioning, first determine the sizes of each
312 * partition. In order to do that we need to know the size of
313 * the disk.
314 */
315 /* Don't use mysystem here so we can redirect output */
316 sprintf(commandstring, "/bin/sfdisk -s /dev/%s > /tmp/disksize 2> /dev/null", harddrive);
317 system(commandstring);
318
319 /* Calculate amount of disk space */
320 if ((handle = fopen("/tmp/disksize", "r")))
321 {
322 fgets(line, STRING_SIZE-1, handle);
323 if (sscanf (line, "%s", string)) {
324 maximum_free = atoi(string) / 1024;
325 }
326 fclose(handle);
327 }
328
329 fprintf(flog, "maximum_free = %ld, memory = %ld",
330 maximum_free, memory);
331
332 swap_file = calc_swapsize(memory, maximum_free);
333
334 if (maximum_free < 512 + swap_file ) {
335 if (maximum_free < 512) {
336 errorbox(ctr[TR_DISK_TOO_SMALL]);
337 goto EXIT;
338 }
339
340 if (!unattended) {
341 rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], ctr[TR_CONTINUE_NO_SWAP]);
342 }
343 else {
344 rc = 1;
345 }
346
347 if (rc != 1)
348 goto EXIT;
349 swap_file = 0;
350 }
351
352 boot_partition = 20; /* in MB */
353 current_free = maximum_free - boot_partition - swap_file;
354
355 root_partition = 2048 ;
356 if (current_free < 512) {
357 errorbox(ctr[TR_DISK_TOO_SMALL]);
358 goto EXIT;
359 }
360
361 current_free = current_free - root_partition;
362 if (!swap_file) {
363 root_partition = root_partition + swap_file;
364 }
365
366 system_partition = current_free;
367
368 fprintf(flog, "boot = %ld, swap = %ld, mylog = %ld, root = %ld\n",
369 boot_partition, swap_file, system_partition, root_partition);
370
371 handle = fopen("/tmp/partitiontable", "w");
372
373 /* Make swapfile */
374 if (swap_file) {
375 fprintf(handle, ",%ld,L,*\n,%ld,S,\n,%ld,L,\n,,L,\n",
376 boot_partition, swap_file, root_partition);
377 } else {
378 fprintf(handle, ",%ld,L,*\n,0,0,\n,%ld,L,\n,,L,\n",
379 boot_partition, root_partition);
380 }
381
382 fclose(handle);
383
384 snprintf(commandstring, STRING_SIZE, "/bin/sfdisk -L -uM %s < /tmp/partitiontable", hdparams.devnode);
385 if (runcommandwithstatus(commandstring, ctr[TR_PARTITIONING_DISK]))
386 {
387 errorbox(ctr[TR_UNABLE_TO_PARTITION]);
388 goto EXIT;
389 }
390
391 mysystem("/sbin/udevstart");
392
393 if (raid_disk)
394 snprintf(commandstring, STRING_SIZE, "/bin/mke2fs -T ext2 -c %sp1", hdparams.devnode);
395 else
396 snprintf(commandstring, STRING_SIZE, "/bin/mke2fs -T ext2 -c %s1", hdparams.devnode);
397 if (runcommandwithstatus(commandstring, ctr[TR_MAKING_BOOT_FILESYSTEM]))
398 {
399 errorbox(ctr[TR_UNABLE_TO_MAKE_BOOT_FILESYSTEM]);
400 goto EXIT;
401 }
402
403 if (swap_file) {
404 if (raid_disk)
405 snprintf(commandstring, STRING_SIZE, "/sbin/mkswap %sp2", hdparams.devnode);
406 else
407 snprintf(commandstring, STRING_SIZE, "/sbin/mkswap %s2", hdparams.devnode);
408 if (runcommandwithstatus(commandstring, ctr[TR_MAKING_SWAPSPACE]))
409 {
410 errorbox(ctr[TR_UNABLE_TO_MAKE_SWAPSPACE]);
411 goto EXIT;
412 }
413 }
414
415 if (raid_disk)
416 snprintf(commandstring, STRING_SIZE, "/sbin/mkreiserfs -f %sp3", hdparams.devnode);
417 else
418 snprintf(commandstring, STRING_SIZE, "/sbin/mkreiserfs -f %s3", hdparams.devnode);
419
420 if (runcommandwithstatus(commandstring, ctr[TR_MAKING_ROOT_FILESYSTEM]))
421 {
422 errorbox(ctr[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM]);
423 goto EXIT;
424 }
425
426 if (raid_disk)
427 snprintf(commandstring, STRING_SIZE, "/sbin/mkreiserfs -f %sp4", hdparams.devnode);
428 else
429 snprintf(commandstring, STRING_SIZE, "/sbin/mkreiserfs -f %s4", hdparams.devnode);
430
431 if (runcommandwithstatus(commandstring, ctr[TR_MAKING_LOG_FILESYSTEM]))
432 {
433 errorbox(ctr[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM]);
434 goto EXIT;
435 }
436
437 /* Mount harddisk. */
438 if (raid_disk)
439 snprintf(commandstring, STRING_SIZE, "/bin/mount %sp3 /harddisk", hdparams.devnode);
440 else
441 snprintf(commandstring, STRING_SIZE, "/bin/mount %s3 /harddisk", hdparams.devnode);
442 if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_ROOT_FILESYSTEM]))
443 {
444 errorbox(ctr[TR_UNABLE_TO_MOUNT_ROOT_FILESYSTEM]);
445 goto EXIT;
446 }
447
448 mkdir("/harddisk/boot", S_IRWXU|S_IRWXG|S_IRWXO);
449 mkdir("/harddisk/var", S_IRWXU|S_IRWXG|S_IRWXO);
450 mkdir("/harddisk/var/log", S_IRWXU|S_IRWXG|S_IRWXO);
451
452 if (raid_disk)
453 snprintf(commandstring, STRING_SIZE, "/bin/mount %sp1 /harddisk/boot", hdparams.devnode);
454 else
455 snprintf(commandstring, STRING_SIZE, "/bin/mount %s1 /harddisk/boot", hdparams.devnode);
456
457 if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_BOOT_FILESYSTEM]))
458 {
459 errorbox(ctr[TR_UNABLE_TO_MOUNT_BOOT_FILESYSTEM]);
460 goto EXIT;
461 }
462 if (swap_file) {
463 if (raid_disk)
464 snprintf(commandstring, STRING_SIZE, "/sbin/swapon %sp2", hdparams.devnode);
465 else
466 snprintf(commandstring, STRING_SIZE, "/sbin/swapon %s2", hdparams.devnode);
467 if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_SWAP_PARTITION]))
468 {
469 errorbox(ctr[TR_UNABLE_TO_MOUNT_SWAP_PARTITION]);
470 goto EXIT;
471 }
472 }
473 if (raid_disk)
474 snprintf(commandstring, STRING_SIZE, "/bin/mount %sp4 /harddisk/var", hdparams.devnode);
475 else
476 snprintf(commandstring, STRING_SIZE, "/bin/mount %s4 /harddisk/var", hdparams.devnode);
477 if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_LOG_FILESYSTEM]))
478 {
479 errorbox(ctr[TR_UNABLE_TO_MOUNT_LOG_FILESYSTEM]);
480 goto EXIT;
481 }
482
483 if (installtype == URL_INSTALL) {
484 snprintf(commandstring, STRING_SIZE,
485 "/bin/wget -q -O - %s/" SNAME "-" VERSION ".tbz2 | /bin/tar -C /harddisk -xvjf -", url);
486 }
487
488 if (installtype == CDROM_INSTALL) {
489 snprintf(commandstring, STRING_SIZE,
490 "/bin/tar -C /harddisk -xvjf /cdrom/" SNAME "-" VERSION ".tbz2");
491 }
492
493 if (runcommandwithprogress(60, 4, title, commandstring, INST_FILECOUNT,
494 ctr[TR_INSTALLING_FILES]))
495 {
496 errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);
497 goto EXIT;
498 }
499
500 /* Save USB controller type to modules.conf */
501 write_usb_modules_conf();
502
503 /* touch the modules.dep files */
504 snprintf(commandstring, STRING_SIZE,
505 "/bin/touch /harddisk/lib/modules/%s-ipfire/modules.dep",
506 KERNEL_VERSION);
507 mysystem(commandstring);
508 snprintf(commandstring, STRING_SIZE,
509 "/bin/touch /harddisk/lib/modules/%s-ipfire-smp/modules.dep",
510 KERNEL_VERSION);
511 mysystem(commandstring);
512
513 /* Rename uname */
514 rename ("/harddisk/bin/uname.bak", "/harddisk/bin/uname");
515
516 /* *always* write disk configuration */
517 if (!(write_disk_configs(&hdparams))){
518 errorbox(ctr[TR_ERROR_WRITING_CONFIG]);
519 goto EXIT;
520 }
521
522 /* mount proc filesystem */
523 mysystem("mkdir /harddisk/proc");
524 mysystem("/bin/mount -t proc none /harddisk/proc");
525 mysystem("/bin/mount --bind /dev /harddisk/dev");
526
527 /* Build cache lang file */
528 snprintf(commandstring, STRING_SIZE, "/sbin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT "/lang.pl'; &Lang::BuildCacheLang\"");
529 if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_LANG_CACHE]))
530 {
531 errorbox(ctr[TR_UNABLE_TO_INSTALL_LANG_CACHE]);
532 goto EXIT;
533 }
534
535 /* Update /etc/fstab */
536 replace("/harddisk/etc/fstab", "DEVICE", hdparams.devnode);
537
538 /* if we detected SCSI/USB then fixup */
539 mysystem("/bin/probecntrl.sh");
540 if ((handle = fopen("/tmp/cntrldriver", "r")))
541 {
542 char *driver;
543 fgets(line, STRING_SIZE-1, handle);
544 fclose(handle);
545 line[strlen(line) - 1] = 0;
546 driver = strtok(line, ".");
547 if (strlen(driver) > 1) {
548 fprintf(flog, "Fixing up ipfirerd.img\n");
549 mkdir("/harddisk/initrd", S_IRWXU|S_IRWXG|S_IRWXO);
550 snprintf(commandstring, STRING_SIZE, "/sbin/chroot /harddisk /sbin/mkinitrd -v --with=scsi_mod %s --with=sd_mod --with=sr_mod /boot/ipfirerd.img %s-ipfire", driver, KERNEL_VERSION);
551 runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]);
552 snprintf(commandstring, STRING_SIZE, "/sbin/chroot /harddisk /sbin/mkinitrd -v --with=scsi_mod %s --with=sd_mod --with=sr_mod /boot/ipfirerd-smp.img %s-ipfire-smp", driver, KERNEL_VERSION);
553 runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]);
554 mysystem("/sbin/chroot /harddisk /bin/mv /boot/grub/scsigrub.conf /boot/grub/grub.conf");
555 }
556 }
557
558 if (raid_disk)
559 sprintf(string, "root=%sp3", hdparams.devnode);
560 else
561 sprintf(string, "root=%s3", hdparams.devnode);
562 replace( "/harddisk/boot/grub/grub.conf", "root=ROOT", string);
563 replace( "/harddisk/boot/grub/grubbatch", "DEVICE", hdparams.devnode);
564
565 /* restore permissions */
566 chmod("/harddisk/boot/grub/grubbatch", S_IXUSR | S_IRUSR | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH);
567
568 snprintf(commandstring, STRING_SIZE,
569 "/sbin/chroot /harddisk /boot/grub/grubbatch");
570 if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_GRUB])) {
571 errorbox(ctr[TR_UNABLE_TO_INSTALL_GRUB]);
572 goto EXIT;
573 }
574
575 /* Install bootsplash */
576 mysystem("/bin/installbootsplash.sh");
577
578 mysystem("ln -s grub.conf /harddisk/boot/grub/menu.lst");
579 mysystem("umount /harddisk/proc");
580 mysystem("umount /harddisk/dev");
581
582 if (!unattended) {
583 sprintf(message, ctr[TR_CONGRATULATIONS_LONG],
584 NAME, SNAME, SNAME, NAME, NAME, NAME);
585 newtWinMessage(ctr[TR_CONGRATULATIONS], ctr[TR_OK], message);
586 }
587
588 allok = 1;
589
590 EXIT:
591 fprintf(flog, "Install program ended.\n");
592
593 if (!(allok))
594 newtWinMessage(title, ctr[TR_OK], ctr[TR_PRESS_OK_TO_REBOOT]);
595
596 freekeyvalues(ethernetkv);
597
598 if (allok && !allok_fastexit)
599 {
600 /* /proc is needed by the module checker. We have to mount it
601 * so it can be seen by setup, which is run chrooted. */
602 if (system("/bin/mount proc -t proc /harddisk/proc"))
603 printf("Unable to mount proc in /harddisk.");
604 else
605 {
606 if (unattended) {
607 fprintf(flog, "Entering unattended setup\n");
608 if (unattended_setup(unattendedkv)) {
609 snprintf(commandstring, STRING_SIZE, "/bin/sleep 10");
610 runcommandwithstatus(commandstring, "Unattended installation finished, system will reboot");
611 } else {
612 errorbox("Unattended setup failed.");
613 goto EXIT;
614 }
615 }
616
617 newtFinished();
618 fflush(flog);
619 fclose(flog);
620
621 if (!unattended) {
622 if (system("/sbin/chroot /harddisk /usr/local/sbin/setup /dev/tty2 INSTALL"))
623 printf("Unable to run setup.\n");
624 }
625
626 if (system("/bin/umount /harddisk/proc"))
627 printf("Unable to umount /harddisk/proc.\n");
628 }
629 }
630 fcloseall();
631
632 if (swap_file) {
633 if (raid_disk)
634 snprintf(commandstring, STRING_SIZE, "/bin/swapoff %sp2", hdparams.devnode);
635 else
636 snprintf(commandstring, STRING_SIZE, "/bin/swapoff %s2", hdparams.devnode);
637 }
638
639 newtFinished();
640
641 system("/bin/umount /harddisk/var");
642 system("/bin/umount /harddisk/boot");
643 system("/bin/umount /harddisk");
644
645 system("/etc/halt");
646
647 return 0;
648 }