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