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