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