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