1 /* SmoothWall install program.
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
6 * (c) Lawrence Manning, 2001
7 * Contains main entry point, and misc functions.
14 #define CDROM_INSTALL 0
16 #define DISK_INSTALL 2
17 #define INST_FILECOUNT 6600
18 #define UNATTENDED_CONF "/cdrom/data/unattended.conf"
27 extern char url
[STRING_SIZE
];
34 char line
[STRING_SIZE
];
37 if ((fd
= fopen("/proc/cpuinfo", "r")) == NULL
) {
40 while (fgets(line
, STRING_SIZE
, fd
) != NULL
) {
41 if (strstr(line
, "processor") == line
) {
46 return (cpu_count
> 1);
49 int generate_packages_list(char *packages
, const char *rpmdir
, const char *source
) {
52 char buffer
[STRING_SIZE
];
53 bzero(buffer
, sizeof(buffer
));
55 if ((fd
= fopen(source
, "r")) == NULL
) {
56 (void) fprintf(flog
, "Packages file %s not found\n", source
);
59 while (fgets(buffer
, sizeof(buffer
), fd
) != NULL
) {
61 length
= strlen(buffer
)-1;
65 if (buffer
[length
] == '\n') {
68 length
= snprintf(packages
, STRING_SIZE
, "%s %s/%s", strdup(packages
), rpmdir
, buffer
);
69 if ((length
<0) || (length
>STRING_SIZE
)) {
70 (void) fprintf(flog
, "rpm command line too long: %d\n%s", length
, packages
);
75 (void) fprintf(flog
, "Error reading file\n");
83 long calc_swapsize(long memory
, long disk
) {
94 int unattended_setup(struct keyvalue
*unattendedkv
) {
95 struct keyvalue
*mainsettings
= initkeyvalues();
96 struct keyvalue
*ethernetkv
= initkeyvalues();
98 char commandstring
[STRING_SIZE
];
100 char domainname
[STRING_SIZE
];
101 char hostname
[STRING_SIZE
];
102 char keymap
[STRING_SIZE
];
103 char language
[STRING_SIZE
];
104 char timezone
[STRING_SIZE
];
105 char green_address
[STRING_SIZE
];
106 char green_netmask
[STRING_SIZE
];
107 char green_netaddress
[STRING_SIZE
];
108 char green_broadcast
[STRING_SIZE
];
109 char root_password
[STRING_SIZE
];
110 char admin_password
[STRING_SIZE
];
111 char serial_console
[STRING_SIZE
];
112 char reversesort
[STRING_SIZE
];
114 findkey(unattendedkv
, "DOMAINNAME", domainname
);
115 findkey(unattendedkv
, "HOSTNAME", hostname
);
116 findkey(unattendedkv
, "KEYMAP", keymap
);
117 findkey(unattendedkv
, "LANGUAGE", language
);
118 findkey(unattendedkv
, "TIMEZONE", timezone
);
119 findkey(unattendedkv
, "GREEN_ADDRESS", green_address
);
120 findkey(unattendedkv
, "GREEN_NETMASK", green_netmask
);
121 findkey(unattendedkv
, "GREEN_NETADDRESS", green_netaddress
);
122 findkey(unattendedkv
, "GREEN_BROADCAST", green_broadcast
);
123 findkey(unattendedkv
, "ROOT_PASSWORD", root_password
);
124 findkey(unattendedkv
, "ADMIN_PASSWORD", admin_password
);
125 findkey(unattendedkv
, "SERIAL_CONSOLE", serial_console
);
126 findkey(unattendedkv
, "REVERSE_NICS", reversesort
);
128 /* write main/settings. */
129 replacekeyvalue(mainsettings
, "DOMAINNAME", domainname
);
130 replacekeyvalue(mainsettings
, "HOSTNAME", hostname
);
131 replacekeyvalue(mainsettings
, "KEYMAP", keymap
);
132 replacekeyvalue(mainsettings
, "LANGUAGE", language
);
133 replacekeyvalue(mainsettings
, "TIMEZONE", timezone
);
134 writekeyvalues(mainsettings
, "/harddisk" CONFIG_ROOT
"/main/settings");
135 freekeyvalues(mainsettings
);
138 fprintf(flog
, "unattended: Starting setup\n");
142 fprintf(flog
, "unattended: setting up network configuration\n");
144 (void) readkeyvalues(ethernetkv
, "/harddisk" CONFIG_ROOT
"/ethernet/settings");
145 replacekeyvalue(ethernetkv
, "GREEN_ADDRESS", green_address
);
146 replacekeyvalue(ethernetkv
, "GREEN_NETMASK", green_netmask
);
147 replacekeyvalue(ethernetkv
, "GREEN_NETADDRESS", green_netaddress
);
148 replacekeyvalue(ethernetkv
, "GREEN_BROADCAST", green_broadcast
);
149 replacekeyvalue(ethernetkv
, "CONFIG_TYPE", "0");
150 replacekeyvalue(ethernetkv
, "GREEN_DEV", "br0");
151 write_ethernet_configs(ethernetkv
);
152 freekeyvalues(ethernetkv
);
155 unlink("/harddisk/etc/localtime");
156 snprintf(commandstring
, STRING_SIZE
, "/harddisk/%s", timezone
);
157 link(commandstring
, "/harddisk/etc/localtime");
160 fprintf(flog
, "unattended: writing hostname.conf\n");
161 if (!(file
= fopen("/harddisk" CONFIG_ROOT
"/main/hostname.conf", "w")))
163 errorbox("unattended: ERROR writing hostname.conf");
166 fprintf(file
, "ServerName %s\n", hostname
);
169 fprintf(flog
, "unattended: writing hosts\n");
170 if (!(hosts
= fopen("/harddisk/etc/hosts", "w")))
172 errorbox("unattended: ERROR writing hosts");
175 fprintf(hosts
, "127.0.0.1\tlocalhost\n");
176 fprintf(hosts
, "%s\t%s.%s\t%s\n", green_address
, hostname
, domainname
, hostname
);
179 fprintf(flog
, "unattended: writing hosts.allow\n");
180 if (!(file
= fopen("/harddisk/etc/hosts.allow", "w")))
182 errorbox("unattended: ERROR writing hosts.allow");
185 fprintf(file
, "sshd : ALL\n");
186 fprintf(file
, "ALL : localhost\n");
187 fprintf(file
, "ALL : %s/%s\n", green_netaddress
, green_netmask
);
190 fprintf(flog
, "unattended: writing hosts.deny\n");
191 if (!(file
= fopen("/harddisk/etc/hosts.deny", "w")))
193 errorbox("unattended: ERROR writing hosts.deny");
196 fprintf(file
, "ALL : ALL\n");
199 if (strcmp(serial_console
, "yes") != 0) {
200 snprintf(commandstring
, STRING_SIZE
,
201 "/bin/chroot /harddisk /bin/sed -i -e \"s/^s0/#s0/\" /etc/inittab");
202 if (mysystem(commandstring
)) {
203 errorbox("unattended: ERROR modifying inittab");
207 snprintf(commandstring
, STRING_SIZE
,
208 "/bin/chroot /harddisk /bin/sed -i -e \"s/^serial/#serial/; s/^terminal/#terminal/\" /boot/grub/grub.conf");
209 if (mysystem(commandstring
)) {
210 errorbox("unattended: ERROR modifying inittab");
215 /* set reverse sorting of interfaces */
216 if (strcmp(reversesort
, "yes") == 0) {
217 mysystem("/bin/touch /harddisk/var/ipfire/ethernet/reverse_nics");
220 /* set root password */
221 fprintf(flog
, "unattended: setting root password\n");
223 snprintf(commandstring
, STRING_SIZE
,
224 "/bin/chroot /harddisk /bin/sh -c \"echo 'root:%s' | /usr/sbin/chpasswd\"", root_password
);
225 if (mysystem(commandstring
)) {
226 errorbox("unattended: ERROR setting root password");
230 /* set admin password */
231 fprintf(flog
, "unattended: setting admin password\n");
232 snprintf(commandstring
, STRING_SIZE
,
233 "/bin/chroot /harddisk /usr/bin/htpasswd -c -m -b " CONFIG_ROOT
"/auth/users admin '%s'", admin_password
);
234 if (mysystem(commandstring
)) {
235 errorbox("unattended: ERROR setting admin password");
242 int main(int argc
, char *argv
[])
244 char *langnames
[] = { "Deutsch", "English", NULL
};
245 char *shortlangnames
[] = { "de", "en", NULL
};
246 char **langtrs
[] = { de_tr
, en_tr
, NULL
};
247 char hdletter
, cdletter
;
248 char harddrive
[5], sourcedrive
[5]; /* Device holder. */
249 struct devparams hdparams
, cdromparams
; /* Params for CDROM and HD */
250 int cdmounted
= 0; /* Loop flag for inserting a cd. */
252 char commandstring
[STRING_SIZE
];
253 char *installtypes
[] = { "CDROM", "HTTP/FTP", NULL
};
254 int installtype
= CDROM_INSTALL
;
255 char insertmessage
[STRING_SIZE
];
256 char insertdevnode
[STRING_SIZE
];
258 char shortlangname
[10];
260 char title
[STRING_SIZE
];
262 int allok_fastexit
=0;
263 int unmount_before
=0;
264 struct keyvalue
*ethernetkv
= initkeyvalues();
265 FILE *handle
, *cmdfile
;
266 char line
[STRING_SIZE
];
267 char string
[STRING_SIZE
];
268 long maximum_free
= 0, current_free
;
270 long log_partition
, boot_partition
, root_partition
, swap_file
;
273 int pcmcia_cdrom
= 0;
278 char *yesnoharddisk
[] = { "NO", "YES", NULL
};
279 char *yesno
[] = { "NO", "YES", NULL
};
280 char green
[STRING_SIZE
];
282 struct keyvalue
*unattendedkv
= initkeyvalues();
283 char packages
[STRING_SIZE
];
284 int serial_console
= 0;
285 char megabridge
[STRING_SIZE
];
287 setlocale (LC_ALL
, "");
288 sethostname( SNAME
, 10);
290 memset(&hdparams
, 0, sizeof(struct devparams
));
291 memset(&cdromparams
, 0, sizeof(struct devparams
));
293 /* Log file/terminal stuff. */
296 if (!(flog
= fopen(argv
[1], "w+")))
304 fprintf(flog
, "Install program started.\n");
309 /* Do usb detection first for usb keyboard */
310 if (! (cmdfile
= fopen("/proc/cmdline", "r")))
312 fprintf(flog
, "Couldn't open commandline: /proc/cmdline\n");
314 fgets(line
, STRING_SIZE
, cmdfile
);
315 if (strstr (line
, "fdisk") != NULL
) {
316 fprintf(flog
, "Manual FDISK selected.\n");
319 if (strstr (line
, "nopcmcia") == NULL
) {
320 fprintf(flog
, "Initializing PCMCIA controllers.\n");
321 pcmcia
= initialize_pcmcia();
323 fprintf (flog
, "Detected PCMCIA Controller: %s.\n", pcmcia
);
324 sprintf(commandstring
, "/sbin/modprobe %s", pcmcia
);
325 mysystem("/sbin/modprobe pcmcia_core");
326 mysystem(commandstring
);
327 mysystem("/sbin/modprobe ds");
328 /* pcmcia netcard drivers are not available from Boot floppy,
329 * they will be loaded from Drivers floppy later */
331 fprintf (flog
, "Detected No PCMCIA Controller.\n");
334 fprintf(flog
, "Skipping PCMCIA detection.\n");
336 if (strstr (line
, "nousb") == NULL
) {
337 fprintf(flog
, "Initializing USB controllers.\n");
340 fprintf(flog
, "Skipping USB detection.\n");
342 // check if we have to make an unattended install
343 if (strstr (line
, "unattended") != NULL
) {
348 // make some beeps before wiping the system :)
350 runcommandwithstatus("/bin/beep -f 450 -r 10 -D 800 -n -f 900 -l 1000", "WARNING: Unattended installation will start in 10 seconds...");
353 /* German is the default */
354 for (choice
= 0; langnames
[choice
]; choice
++)
356 if (strcmp(langnames
[choice
], "Deutsch") == 0)
359 if (!langnames
[choice
])
363 rc
= newtWinMenu("Language selection",
364 "Select the language you wish to use for the " NAME
".", 50, 5, 5, 8,
365 langnames
, &choice
, "Ok", NULL
);
368 ctr
= langtrs
[choice
];
369 strcpy(shortlangname
, shortlangnames
[choice
]);
371 mysystem("/bin/setfont lat0-16");
373 newtDrawRootText(14, 0, NAME
" v" VERSION
" - " SLOGAN
);
374 newtPushHelpLine(ctr
[TR_HELPLINE
]);
377 sprintf(message
, ctr
[TR_WELCOME
], NAME
);
378 sprintf (title
, "%s %s - %s", NAME
, VERSION
, SLOGAN
);
379 newtWinMessage(title
, ctr
[TR_OK
], message
);
381 sprintf(message
, ctr
[TR_SELECT_INSTALLATION_MEDIA_LONG
], NAME
);
382 rc
= newtWinMenu(ctr
[TR_SELECT_INSTALLATION_MEDIA
], message
,
383 50, 5, 5, 6, installtypes
, &installtype
, ctr
[TR_OK
],
384 ctr
[TR_CANCEL
], NULL
);
388 installtype
= CDROM_INSTALL
;
394 // Starting hardware detection
395 runcommandwithstatus("/bin/probehw.sh", ctr
[TR_PROBING_HARDWARE
]);
397 switch (mysystem("/bin/mountsource.sh")) {
399 installtype
= CDROM_INSTALL
;
403 installtype
= DISK_INSTALL
;
406 errorbox(ctr
[TR_NO_CDROM
]);
410 /* read source drive letter */
411 if ((handle
= fopen("/source_device", "r")) == NULL
) {
412 errorbox("ERROR reading source_device");
414 fgets(sourcedrive
, 5, handle
);
415 fprintf(flog
, "Source drive: %s\n", sourcedrive
);
418 if (installtype
== CDROM_INSTALL
) {
419 snprintf(cdromparams
.devnode
, STRING_SIZE
, "/dev/%s", sourcedrive
);
420 cdromparams
.module
= 0;
421 fprintf(flog
, "Source device: %s\n", cdromparams
.devnode
);
424 /* Get device for the HD. This has to succeed. */
425 if (!(hdletter
= findidetype(IDE_HD
)))
427 /* Need to clean this up at some point */
428 if (!try_scsi("sda") || strstr(sourcedrive
, "sda") != NULL
) {
429 if (!try_scsi("ida/c0d0")) {
430 if (!try_scsi("cciss/c0d0")) {
431 if (!try_scsi("rd/c0d0")) {
432 if (!try_scsi("ataraid/d0")) {
433 errorbox(ctr
[TR_NO_HARDDISK
]);
437 sprintf(harddrive
, "ataraid/d0");
441 sprintf(harddrive
, "rd/c0d0");
445 sprintf(harddrive
, "cciss/c0d0");
449 sprintf(harddrive
, "ida/c0d0");
452 if (strstr(sourcedrive
, "sda") != NULL
) {
453 // probably installing from usb stick, try sdb
454 if (try_scsi("sdb")) {
455 sprintf(harddrive
, "sdb");
458 errorbox(ctr
[TR_NO_HARDDISK
]);
463 sprintf(harddrive
, "sda");
468 sprintf(harddrive
, "hd%c", hdletter
);
471 /* load unattended configuration */
473 fprintf(flog
, "unattended: Reading unattended.conf\n");
475 (void) readkeyvalues(unattendedkv
, UNATTENDED_CONF
);
478 /* Make the hdparms struct and print the contents. */
479 snprintf(hdparams
.devnode
, STRING_SIZE
, "/dev/%s", harddrive
);
482 sprintf(message
, ctr
[TR_PREPARE_HARDDISK
], hdparams
.devnode
);
489 rc
= newtWinMenu(title
, message
,
490 50, 5, 5, 6, yesnoharddisk
,
492 ctr
[TR_CANCEL
], NULL
);
500 /* Calculate amount of memory in machine */
501 if ((handle
= fopen("/proc/meminfo", "r")))
503 while (fgets(line
, STRING_SIZE
-1, handle
)) {
504 if (sscanf (line
, "MemTotal: %s kB", string
)) {
505 memory
= atoi(string
) / 1024 ;
511 /* Partition, mkswp, mkfs.
512 * before partitioning, first determine the sizes of each
513 * partition. In order to do that we need to know the size of
516 /* Don't use mysystem here so we can redirect output */
517 sprintf(commandstring
, "/bin/sfdisk -s /dev/%s > /disksize 2> /dev/null", harddrive
);
518 system(commandstring
);
520 /* Calculate amount of disk space */
521 if ((handle
= fopen("/disksize", "r")))
523 fgets(line
, STRING_SIZE
-1, handle
);
524 if (sscanf (line
, "%s", string
)) {
525 maximum_free
= atoi(string
) / 1024;
530 fprintf(flog
, "maximum_free = %ld, memory = %ld",
531 maximum_free
, memory
);
533 swap_file
= calc_swapsize(memory
, maximum_free
);
535 if (maximum_free
< 512 + swap_file
) {
536 if (maximum_free
< 512) {
537 errorbox(ctr
[TR_DISK_TOO_SMALL
]);
542 rc
= newtWinChoice(title
, ctr
[TR_OK
], ctr
[TR_CANCEL
], ctr
[TR_CONTINUE_NO_SWAP
]);
553 boot_partition
= 10; /* in MB */
554 current_free
= maximum_free
- boot_partition
- swap_file
;
556 root_partition
= current_free
/ 3 ;
557 if (current_free
< 400) {
558 errorbox(ctr
[TR_DISK_TOO_SMALL
]);
562 current_free
= current_free
- root_partition
;
564 root_partition
= root_partition
+ swap_file
;
567 log_partition
= current_free
;
569 fprintf(flog
, "boot = %ld, swap = %ld, mylog = %ld, root = %ld\n",
570 boot_partition
, swap_file
, log_partition
, root_partition
);
572 handle
= fopen("/tmp/partitiontable", "w");
577 fprintf(handle
, ",%ld,L,*\n,%ld,S,\n,%ld,L,\n,,L,\n",
578 boot_partition
, swap_file
, root_partition
);
580 fprintf(handle
, ",%ld,L,*\n,0,0,\n,%ld,L,\n,,L,\n",
581 boot_partition
, root_partition
);
586 snprintf(commandstring
, STRING_SIZE
, "/bin/sfdisk -L -uM %s < /tmp/partitiontable", hdparams
.devnode
);
587 if (runcommandwithstatus(commandstring
, ctr
[TR_PARTITIONING_DISK
]))
589 errorbox(ctr
[TR_UNABLE_TO_PARTITION
]);
593 mysystem("/bin/udevstart");
596 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -T ext3 -c %sp1", hdparams
.devnode
);
598 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -T ext3 -c %s1", hdparams
.devnode
);
599 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_BOOT_FILESYSTEM
]))
601 errorbox(ctr
[TR_UNABLE_TO_MAKE_BOOT_FILESYSTEM
]);
607 snprintf(commandstring
, STRING_SIZE
, "/bin/mkswap %sp2", hdparams
.devnode
);
609 snprintf(commandstring
, STRING_SIZE
, "/bin/mkswap %s2", hdparams
.devnode
);
610 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_SWAPSPACE
]))
612 errorbox(ctr
[TR_UNABLE_TO_MAKE_SWAPSPACE
]);
618 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -T ext3 %sp3", hdparams
.devnode
);
620 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -T ext3 %s3", hdparams
.devnode
);
622 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_ROOT_FILESYSTEM
]))
624 errorbox(ctr
[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM
]);
629 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -T ext3 %sp4", hdparams
.devnode
);
631 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -T ext3 %s4", hdparams
.devnode
);
633 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_LOG_FILESYSTEM
]))
635 errorbox(ctr
[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM
]);
639 /* Mount harddisk. */
641 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount %sp3 /harddisk", hdparams
.devnode
);
643 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount %s3 /harddisk", hdparams
.devnode
);
644 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_ROOT_FILESYSTEM
]))
646 errorbox(ctr
[TR_UNABLE_TO_MOUNT_ROOT_FILESYSTEM
]);
650 mkdir("/harddisk/boot", S_IRWXU
|S_IRWXG
|S_IRWXO
);
651 mkdir("/harddisk/var", S_IRWXU
|S_IRWXG
|S_IRWXO
);
652 mkdir("/harddisk/var/log", S_IRWXU
|S_IRWXG
|S_IRWXO
);
655 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount %sp1 /harddisk/boot", hdparams
.devnode
);
657 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount %s1 /harddisk/boot", hdparams
.devnode
);
659 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_BOOT_FILESYSTEM
]))
661 errorbox(ctr
[TR_UNABLE_TO_MOUNT_BOOT_FILESYSTEM
]);
666 snprintf(commandstring
, STRING_SIZE
, "/bin/swapon %sp2", hdparams
.devnode
);
668 snprintf(commandstring
, STRING_SIZE
, "/bin/swapon %s2", hdparams
.devnode
);
669 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_SWAP_PARTITION
]))
671 errorbox(ctr
[TR_UNABLE_TO_MOUNT_SWAP_PARTITION
]);
676 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount %sp4 /harddisk/var", hdparams
.devnode
);
678 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount %s4 /harddisk/var", hdparams
.devnode
);
679 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_LOG_FILESYSTEM
]))
681 errorbox(ctr
[TR_UNABLE_TO_MOUNT_LOG_FILESYSTEM
]);
687 if (installtype
== CDROM_INSTALL
)
689 /* First look for an IDE CDROM. */
690 if (!(cdletter
= findidetype(IDE_CDROM
)))
692 /* If we have a USB attached CDROM then it will
693 * have already appeared at /dev/scd0, so we
694 * try to access it first, before asking for the
697 if (!(try_scsi("scd0"))) {
698 sprintf(insertmessage
, ctr
[TR_INSERT_FLOPPY
], NAME
" SCSI");
699 rc
= newtWinChoice(title
, ctr
[TR_OK
], ctr
[TR_CANCEL
], insertmessage
);
702 errorbox(ctr
[TR_INSTALLATION_CANCELED
]);
706 if (runcommandwithstatus("/bin/tar -C / -xvzf /dev/floppy", ctr
[TR_EXTRACTING_MODULES
]))
708 errorbox(ctr
[TR_UNABLE_TO_EXTRACT_MODULES
]);
714 /* trying to support SCSI pcmcia :-) */
715 runcommandwithstatus("cardmgr -o -c /etc/pcmcia/scsi",
716 ctr
[TR_LOADING_PCMCIA
]);
717 if (try_scsi("scd0"))
721 /* try loading all SCSI modules with default options */
722 /* Should expand this to allow options later though */
724 runcommandwithstatus("/bin/probehw.sh",
725 ctr
[TR_PROBING_HARDWARE
]);
727 /* If it fails, give up. */
728 if (!(try_scsi("scd0"))) {
729 errorbox(ctr
[TR_NO_CDROM
]);
734 sprintf(sourcedrive
, "scd0");
737 sprintf(sourcedrive
, "hd%c", cdletter
);
741 snprintf(cdromparams
.devnode
, STRING_SIZE
, "/dev/%s", sourcedrive
);
742 cdromparams
.module
= 0;
744 sprintf(insertmessage
, ctr
[TR_INSERT_CDROM
], NAME
);
745 strcpy (insertdevnode
, cdromparams
.devnode
);
749 /* If we've done a PXE boot, we can skip the Drivers floppy,
750 * as we've already got the modules in our instroot.gz */
751 if (!(handle
= fopen("/CDROMBOOT", "r"))) {
752 sprintf(insertmessage
, ctr
[TR_INSERT_FLOPPY
], NAME
);
753 strcpy (insertdevnode
, "/dev/floppy");
761 if (scsi_cdrom
|| ide_cdrom
) {
762 /* Try to mount /cdrom in a loop. */
763 snprintf(commandstring
, STRING_SIZE
, "/bin/mount -o ro %s /cdrom", insertdevnode
);
766 rc
= newtWinChoice(title
, ctr
[TR_OK
], ctr
[TR_CANCEL
], insertmessage
);
769 errorbox(ctr
[TR_INSTALLATION_CANCELED
]);
772 if (!(mysystem(commandstring
))) {
773 handle
= fopen ("/cdrom/" SNAME
"-" VERSION
".tgz", "r");
774 if (handle
!= NULL
) {
777 /* If we've booted from CDROM, then
778 * we've already got the drivers,
779 * so we can skip this unpack. */
780 if (!(handle
= fopen("/CDROMBOOT", "r"))) {
781 sprintf(string
, "/bin/tar -C / -xvzf /cdrom/images/drivers-%s.img", VERSION
);
782 if (runcommandwithprogress(60, 4, title
,
784 175, ctr
[TR_EXTRACTING_MODULES
]))
786 errorbox(ctr
[TR_UNABLE_TO_EXTRACT_MODULES
]);
793 mysystem ("/bin/umount /cdrom");
798 snprintf(commandstring
, STRING_SIZE
, "/bin/tar -C / -xvzf /dev/floppy");
801 rc
= newtWinChoice(title
, ctr
[TR_OK
], ctr
[TR_CANCEL
], insertmessage
);
804 errorbox(ctr
[TR_INSTALLATION_CANCELED
]);
807 if (runcommandwithprogress(60, 4, title
,
809 175, ctr
[TR_EXTRACTING_MODULES
]))
811 #if 0 /* disable this, so we allow for people putting in the wrong disk */
812 errorbox(ctr
[TR_UNABLE_TO_EXTRACT_MODULES
]);
818 handle
= fopen ("/bin/mke2fs", "r");
819 if (handle
!= NULL
) {
827 /* PCMCIA controller is already detected
828 * On Boot floppy, we didn't have the PCMCIA drivers
829 * so load them now because they are installed from Drivers. */
830 if (!(handle
= fopen("/CDROMBOOT", "r"))) {
831 if (strstr (line
, "nopcmcia") == NULL
) {
832 fprintf(flog
,"Floppy boot detected, loading PCMCIA drivers.\n");
834 fprintf (flog
, "Detected PCMCIA Controller: %s.\n", pcmcia
);
835 sprintf(commandstring
, "/sbin/modprobe %s", pcmcia
);
836 mysystem("/sbin/modprobe pcmcia_core");
837 mysystem(commandstring
);
838 mysystem("/sbin/modprobe ds");
840 fprintf (flog
, "Detected No PCMCIA Controller.\n");
843 fprintf(flog
, "Skipping PCMCIA detection.\n");
845 if (strstr (line
, "nousb") == NULL
) {
846 fprintf(flog
, "Initializing USB controllers.\n");
849 fprintf(flog
, "Skipping USB detection.\n");
854 /* Configure the network now! */
855 if (installtype
== URL_INSTALL
)
857 /* Network driver and params. */
858 if (!(networkmenu(ethernetkv
)))
860 errorbox(ctr
[TR_NETWORK_SETUP_FAILED
]);
864 /* Check for ipfire-<VERSION>.tgz */
865 if (!(checktarball(SNAME
"-" VERSION
".tgz")))
867 errorbox(ctr
[TR_NO_IPCOP_TARBALL_FOUND
]);
872 /* Get device for the HD. This has to succeed. */
873 if (!(hdletter
= findidetype(IDE_HD
)))
875 if (installtype
== URL_INSTALL
)
877 /* If we've done a PXE boot, we can skip the SCSI
878 * floppy as we've already got the modules in our
880 if (!(handle
= fopen("/CDROMBOOT", "r")))
882 /* search img where it is on a mounted loop iso */
883 sprintf(string
, "images/scsidrv-%s.img", VERSION
);
884 if (!(checktarball(string
)))
886 /* Couldn't find the SCSI drivers on the URL page,
887 * so after 3 failed attempts, ask the user for the
888 * SCSI drivers floppy disk. */
889 errorbox(ctr
[TR_NO_SCSI_IMAGE_FOUND
]);
890 sprintf(insertmessage
, ctr
[TR_INSERT_FLOPPY
], NAME
" SCSI");
891 rc
= newtWinChoice(title
, ctr
[TR_OK
], ctr
[TR_CANCEL
], insertmessage
);
894 errorbox(ctr
[TR_INSTALLATION_CANCELED
]);
898 if (runcommandwithstatus("/bin/tar -C / -xvzf /dev/floppy", ctr
[TR_EXTRACTING_MODULES
]))
900 errorbox(ctr
[TR_UNABLE_TO_EXTRACT_MODULES
]);
905 snprintf(commandstring
, STRING_SIZE
,
906 "/bin/wget -O - %s/%s | /bin/tar -C / -xvzf -",
908 if (runcommandwithprogress(60, 4, title
, commandstring
,
909 4500, ctr
[TR_INSTALLING_FILES
]))
911 errorbox(ctr
[TR_UNABLE_TO_INSTALL_FILES
]);
919 sprintf(string
, "/bin/tar -C / -xvzf /cdrom/images/scsidrv-%s.img", VERSION
);
920 if (runcommandwithstatus(string
, ctr
[TR_EXTRACTING_MODULES
]))
922 errorbox(ctr
[TR_UNABLE_TO_EXTRACT_MODULES
]);
933 /* trying to support SCSI pcmcia :-) */
934 runcommandwithstatus("cardmgr -o -c /etc/pcmcia/scsi",
935 ctr
[TR_LOADING_PCMCIA
]);
941 /* try loading all SCSI modules with default options */
942 /* Should expand this to allow options later though */
944 runcommandwithstatus("/bin/probehw.sh",
945 ctr
[TR_PROBING_HARDWARE
]);
948 /* Need to clean this up at some point */
949 if (!try_scsi("sda")) {
950 if (!try_scsi("ida/c0d0")) {
951 if (!try_scsi("cciss/c0d0")) {
952 if (!try_scsi("rd/c0d0")) {
953 if (!try_scsi("ataraid/d0")) {
954 errorbox(ctr
[TR_NO_HARDDISK
]);
958 sprintf(harddrive
, "ataraid/d0");
962 sprintf(harddrive
, "rd/c0d0");
966 sprintf(harddrive
, "cciss/c0d0");
970 sprintf(harddrive
, "ida/c0d0");
973 sprintf(harddrive
, "sda");
977 sprintf(harddrive
, "hd%c", hdletter
);
979 /* Make the hdparms struct and print the contents. */
980 snprintf(hdparams
.devnode
, STRING_SIZE
, "/dev/%s", harddrive
);
983 rc
= newtWinChoice(title
, ctr
[TR_OK
], ctr
[TR_CANCEL
],
984 ctr
[TR_PREPARE_HARDDISK
], hdparams
.devnode
);
988 /* Calculate amount of memory in machine */
989 if ((handle
= fopen("/proc/meminfo", "r")))
991 while (fgets(line
, STRING_SIZE
-1, handle
)) {
992 if (sscanf (line
, "MemTotal: %s kB", string
)) {
993 memory
= atoi(string
) / 1024 ;
999 /* Partition, mkswp, mkfs.
1000 * before partitioning, first determine the sizes of each
1001 * partition. In order to do that we need to know the size of
1004 /* Don't use mysystem here so we can redirect output */
1005 sprintf(commandstring
, "/bin/sfdisk -s /dev/%s > /disksize 2> /dev/null", harddrive
);
1006 system(commandstring
);
1008 /* Calculate amount of disk space */
1009 if ((handle
= fopen("/disksize", "r")))
1011 fgets(line
, STRING_SIZE
-1, handle
);
1012 if (sscanf (line
, "%s", string
)) {
1013 maximum_free
= atoi(string
) / 1024;
1018 fprintf(flog
, "maximum_free = %d, memory = %d",
1019 maximum_free
, memory
);
1021 /* If you need more than this, you should really add physical memory */
1022 /* Minimum: 192 = 64 real + 128 swap */
1023 swap_file
= memory
< 64 ? 2 * memory
: 192 - memory
;
1024 swap_file
= swap_file
< 32 ? 32 : swap_file
;
1026 if (maximum_free
< 135 + swap_file
)
1028 if (maximum_free
< 135) {
1029 errorbox(ctr
[TR_DISK_TOO_SMALL
]);
1033 rc
= newtWinChoice(title
, ctr
[TR_OK
], ctr
[TR_CANCEL
], ctr
[TR_CONTINUE_NO_SWAP
]);
1039 boot_partition
= 20; /* in MB */
1040 current_free
= maximum_free
- boot_partition
- swap_file
;
1042 /* Give more place for add-on, extend root to 25% of current_free, upper limit to 8 gigas */
1043 root_partition
= current_free
/ 4 ;
1044 root_partition
= root_partition
> 8192 ? 8192 : root_partition
;
1045 root_partition
= current_free
< 860 ? 235 : root_partition
;
1046 root_partition
= current_free
< 380 ? 110 : root_partition
;
1048 current_free
= current_free
- root_partition
;
1049 root_partition
= root_partition
+ swap_file
;
1051 log_partition
= current_free
;
1053 fprintf(flog
, "boot = %d, swap = %d, mylog = %d, root = %d\n",
1054 boot_partition
, swap_file
, log_partition
, root_partition
);
1062 rc
= newtWinChoice(title
, ctr
[TR_OK
], ctr
[TR_CANCEL
], "NOW FDISK");
1067 handle
= fopen("/tmp/partitiontable", "w");
1069 fprintf(handle
, ",%d,83,*\n,%d,83,\n,0,0,\n,,83,\n",
1070 boot_partition
, log_partition
);
1074 snprintf(commandstring
, STRING_SIZE
, "/bin/sfdisk -uM %s < /tmp/partitiontable", hdparams
.devnode
);
1075 if (runcommandwithstatus(commandstring
, ctr
[TR_PARTITIONING_DISK
]))
1077 errorbox(ctr
[TR_UNABLE_TO_PARTITION
]);
1084 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -m 0 -j %sp1", hdparams
.devnode
);
1086 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -m 0 -j %s1", hdparams
.devnode
);
1087 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_BOOT_FILESYSTEM
]))
1089 errorbox(ctr
[TR_UNABLE_TO_MAKE_BOOT_FILESYSTEM
]);
1093 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -j %sp2", hdparams
.devnode
);
1095 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -j %s2", hdparams
.devnode
);
1096 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_LOG_FILESYSTEM
]))
1098 errorbox(ctr
[TR_UNABLE_TO_MAKE_LOG_FILESYSTEM
]);
1102 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -m 1 -j %sp4", hdparams
.devnode
);
1104 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -m 1 -j %s4", hdparams
.devnode
);
1106 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_ROOT_FILESYSTEM
]))
1108 errorbox(ctr
[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM
]);
1111 /* Mount harddisk. */
1113 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount -t ext2 %sp4 /harddisk", hdparams
.devnode
);
1115 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount -t ext2 %s4 /harddisk", hdparams
.devnode
);
1116 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_ROOT_FILESYSTEM
]))
1118 errorbox(ctr
[TR_UNABLE_TO_MOUNT_ROOT_FILESYSTEM
]);
1123 snprintf(commandstring
, STRING_SIZE
, "/bin/dd if=/dev/zero of=/harddisk/swapfile bs=1024k count=%d", swap_file
);
1124 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_SWAPSPACE
]))
1126 errorbox(ctr
[TR_UNABLE_TO_MAKE_SWAPSPACE
]);
1129 snprintf(commandstring
, STRING_SIZE
, "/bin/mkswap /harddisk/swapfile");
1130 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_SWAPSPACE
]))
1132 errorbox(ctr
[TR_UNABLE_TO_MAKE_SWAPSPACE
]);
1136 mkdir("/harddisk/boot", S_IRWXU
|S_IRWXG
|S_IRWXO
);
1137 mkdir("/harddisk/var", S_IRWXU
|S_IRWXG
|S_IRWXO
);
1138 mkdir("/harddisk/var/log", S_IRWXU
|S_IRWXG
|S_IRWXO
);
1141 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount -t ext2 %sp1 /harddisk/boot", hdparams
.devnode
);
1143 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount -t ext2 %s1 /harddisk/boot", hdparams
.devnode
);
1145 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_BOOT_FILESYSTEM
]))
1147 errorbox(ctr
[TR_UNABLE_TO_MOUNT_BOOT_FILESYSTEM
]);
1151 snprintf(commandstring
, STRING_SIZE
, "/bin/swapon /harddisk/swapfile");
1152 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_SWAP_PARTITION
]))
1154 errorbox(ctr
[TR_UNABLE_TO_MOUNT_SWAP_PARTITION
]);
1159 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount -t ext2 %sp2 /harddisk/var/log", hdparams
.devnode
);
1161 snprintf(commandstring
, STRING_SIZE
, "/sbin/mount -t ext2 %s2 /harddisk/var/log", hdparams
.devnode
);
1162 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_LOG_FILESYSTEM
]))
1164 errorbox(ctr
[TR_UNABLE_TO_MOUNT_LOG_FILESYSTEM
]);
1168 /* Either use tarball from cdrom or download. */
1169 if (installtype
== CDROM_INSTALL
)
1170 snprintf(commandstring
, STRING_SIZE
,
1171 "/bin/tar -C /harddisk -xvzf /cdrom/" SNAME
"-" VERSION
".tgz");
1173 snprintf(commandstring
, STRING_SIZE
,
1174 "/bin/wget -O - %s/" SNAME
"-" VERSION
".tgz | /bin/tar -C /harddisk -xvzf -", url
);
1176 /* if (runcommandwithprogress(60, 4, title, commandstring, 4600,
1177 * ctr[TR_INSTALLING_FILES]))
1179 * errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);
1184 if (runcommandwithstatus(commandstring
, ctr
[TR_INSTALLING_FILES
]))
1186 errorbox(ctr
[TR_UNABLE_TO_INSTALL_FILES
]);
1190 /* Save USB controller type to modules.conf */
1191 write_usb_modules_conf();
1193 /* touch the modules.dep files */
1194 snprintf(commandstring
, STRING_SIZE
,
1195 "/bin/chroot /harddisk /bin/touch /lib/modules/%s/modules.dep",
1197 mysystem(commandstring
);
1199 snprintf(commandstring
, STRING_SIZE
,
1200 "/bin/chroot /harddisk /bin/touch /lib/modules/%s-smp/modules.dep",
1202 mysystem(commandstring
);
1206 rename ("/harddisk/bin/uname.bak", "/harddisk/bin/uname");
1208 /* Write PCMCIA Config */
1210 handle
= fopen("/harddisk/etc/modules.conf", "a");
1211 if (handle
!= NULL
) {
1212 fprintf (handle
, "# PCMCIA Settings\n");
1213 fprintf (handle
, "alias pcmcia-controller %s\n", pcmcia
);
1218 handle
= fopen("/harddisk/etc/pcmcia.conf", "w");
1219 if (handle
!= NULL
) {
1221 fprintf (handle
, "PCMCIA=yes\n");
1222 fprintf (handle
, "PCIC=%s\n", pcmcia
);
1224 fprintf (handle
, "PCMCIA=no\n");
1225 fprintf (handle
, "PCIC=\n");
1227 fprintf (handle
, "CARDMGR_OPTS=\n");
1228 fprintf (handle
, "SCHEME=\n");
1232 /* *always* write disk configuration */
1233 if (!(write_disk_configs(&hdparams
))){
1234 errorbox(ctr
[TR_ERROR_WRITING_CONFIG
]);
1239 Allow the user to restore their configuration from a floppy.
1240 It uses tar. If the tar fails for any reason, show user an
1241 error and go back to the restore/skip question. This gives
1242 the user the chance to have another go. */
1244 #ifdef OLD_RESTORECFG
1246 /* set status variables to nonsense values */
1248 /* loop until floppy succeeds or user skips out */
1251 sprintf(message
, ctr
[TR_RESTORE_CONFIGURATION
], NAME
);
1252 if (newtWinChoice(title
, ctr
[TR_RESTORE
], ctr
[TR_SKIP
], message
) == 1)
1254 /* Temporarily mount /proc under /harddisk/proc,
1255 * run updfstab to locate the floppy, and unmount /harddisk/proc
1256 * again. This should be run each time the user tries to restore
1257 * so it can properly detect removable devices */
1258 if (mysystem("/bin/mount -n -t proc /proc /harddisk/proc")) {
1259 errorbox(ctr
[TR_UNABLE_TO_MOUNT_PROC_FILESYSTEM
]);
1262 if (mysystem("/bin/chroot /harddisk /usr/sbin/updfstab")) {
1263 errorbox(ctr
[TR_UNABLE_TO_WRITE_ETC_FSTAB
]);
1266 mysystem("/bin/umount /harddisk/proc");
1268 mkdir("/harddisk/tmp/ipcop", S_IRWXU
|S_IRWXG
|S_IRWXO
);
1270 /* Always extract to /tmp/ipcop for temporary extraction
1271 * just in case floppy fails */
1273 /* try a compressed backup first because it's quicker to fail.
1274 * In exclude.system, files name must be without leading / or
1275 * on extraction, name will never match */
1276 snprintf(commandstring
, STRING_SIZE
,
1277 "/bin/chroot /harddisk /bin/tar -X " CONFIG_ROOT
"/backup/exclude.system -C /tmp/ipcop -xvzf /dev/floppy > %s 2> /dev/null", mylog
);
1279 statuswindow(45, 4, title
, ctr
[TR_INSTALLING_FILES
]);
1280 rc
= system(commandstring
);
1283 /* if it's not compressed, try uncompressed first before failing*/
1284 snprintf(commandstring
, STRING_SIZE
,
1285 "/bin/chroot /harddisk /bin/tar -X " CONFIG_ROOT
"/backup/exclude.system -C /tmp/ipcop -xvf /dev/floppy > %s 2> /dev/null", mylog
);
1286 rc
= system(commandstring
);
1289 /* command failed trying to read from floppy */
1290 errorbox(ctr
[TR_UNABLE_TO_INSTALL_FILES
]);
1292 /* remove badly restored files */
1293 mysystem("/bin/chroot /harddisk /bin/rm -rf /tmp/ipcop");
1296 /* Now copy to correct location */
1297 mysystem("/bin/chroot /harddisk /bin/cp -af /tmp/ipcop/. /");
1298 mysystem("/bin/chroot /harddisk /bin/rm -rf /tmp/ipcop");
1302 /* Upgrade necessary files from v1.2 to v1.3 to v1.4 */
1304 upgrade_v130_v140();
1305 break; /* out of loop at this point because floppy has
1306 successfully restored */
1309 else { /* success */
1310 /* Now copy to correct location */
1311 mysystem("/bin/chroot /harddisk /bin/cp -af /tmp/ipcop/. /");
1312 mysystem("/bin/chroot /harddisk /bin/rm -rf /tmp/ipcop");
1316 /* Upgrade necessary files from v1.2 to v1.3 to v1.4 */
1318 upgrade_v130_v140();
1319 break; /* out of loop at this point because floppy has
1320 successfully restored */
1323 else{ /* user chose to skip install from floppy */
1324 if (installtype
== CDROM_INSTALL
){
1325 /* if we installed from CD ROM then we didn't set up the
1326 network interface yet. Therefore, set up Network
1327 driver and params just before we need them. */
1329 if (!(networkmenu(ethernetkv
))){
1330 /* network setup failed, tell the world */
1331 errorbox(ctr
[TR_NETWORK_SETUP_FAILED
]);
1335 break; /* out of loop because we succeeded with ethernet
1336 set up and user is notrestarting from floppy*/
1340 if (installtype
== CDROM_INSTALL
){
1341 /* if we installed from CD ROM then we didn't set up the
1342 network interface yet. Therefore, set up Network
1343 driver and params just before we need them. */
1345 if (!(networkmenu(ethernetkv
))){
1346 /* network setup failed, tell the world */
1347 errorbox(ctr
[TR_NETWORK_SETUP_FAILED
]);
1353 /* Check the SQUID acl file exists, if not use our 1.4 copy */
1357 if (!(aclreadfile
= fopen ("/harddisk" CONFIG_ROOT
"/proxy/acl", "r"))) {
1358 rename ("/harddisk" CONFIG_ROOT
"/proxy/acl-1.4",
1359 "/harddisk" CONFIG_ROOT
"/proxy/acl");
1361 unlink ("/harddisk" CONFIG_ROOT
"/proxy/acl-1.4");
1362 fclose(aclreadfile
);
1364 chown ("/harddisk" CONFIG_ROOT
"/proxy/acl", 99, 99);
1367 /* Build cache lang file */
1368 mysystem("/bin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT
"/lang.pl'; &Lang::BuildCacheLang\"");
1370 if (!allok_fastexit
){
1371 /* write ethernet and lang configs only if they have not
1372 been restored from floppy already. */
1373 if (!(write_ethernet_configs( ethernetkv
))||
1374 !(write_lang_configs(shortlangname
))){
1375 errorbox(ctr
[TR_ERROR_WRITING_CONFIG
]);
1380 /* if we detected SCSI then fixup */
1381 if ((handle
= fopen("/scsidriver", "r")))
1384 fgets(line
, STRING_SIZE
-1, handle
);
1386 line
[strlen(line
) - 1] = 0;
1387 driver
= strtok(line
, ".");
1388 fprintf(flog
, "Detected SCSI driver %s\n",driver
);
1389 if (strlen(driver
) > 1) {
1390 fprintf(flog
, "Fixing up ipfirerd.img\n");
1391 mysystem("/bin/chroot /harddisk /sbin/modprobe loop");
1392 mkdir("/harddisk/initrd", S_IRWXU
|S_IRWXG
|S_IRWXO
);
1393 snprintf(commandstring
, STRING_SIZE
, "/bin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod --with=%s --with=sd_mod --with=sr_mod --with=libata --with=ataraid /boot/ipfirerd.img %s", driver
, KERNEL_VERSION
);
1394 runcommandwithstatus(commandstring
, ctr
[TR_BUILDING_INITRD
]);
1396 snprintf(commandstring
, STRING_SIZE
, "/bin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod --with=%s --with=sd_mod --with=sr_mod --with=libata --with=ataraid /boot/ipfirerd-smp.img %s-smp", driver
, KERNEL_VERSION
);
1397 runcommandwithstatus(commandstring
, ctr
[TR_BUILDING_INITRD
]);
1398 mysystem("/bin/chroot /harddisk /bin/mv /boot/grub/scsigrub.conf /boot/grub/grub.conf");
1401 snprintf(commandstring
, STRING_SIZE
, "/bin/chroot /harddisk /bin/mv /boot/etc/scsiaboot.conf /boot/etc/aboot.conf");
1402 runcommandwithstatus(commandstring
, ctr
[TR_BUILDING_INITRD
]);
1410 fprintf(flog
, "Detected SCSI driver PCMCIA\n");
1411 fprintf(flog
, "Fixing up ipfirerd.img\n");
1412 mysystem("/bin/chroot /harddisk /sbin/modprobe loop");
1413 mkdir("/harddisk/initrd", S_IRWXU
|S_IRWXG
|S_IRWXO
);
1414 snprintf(commandstring
, STRING_SIZE
, "/bin/chroot /harddisk /sbin/pcinitrd -r %s /boot/ipfirerd.img", KERNEL_VERSION
);
1415 mysystem(commandstring
);
1417 mysystem("/bin/chroot /harddisk /bin/mv /boot/grub/scsigrub.conf /boot/grub/grub.conf");
1420 mysystem("/bin/chroot /harddisk /bin/mv /boot/etc/scsiaboot.conf /boot/etc/aboot.conf");
1426 replace( "/harddisk/boot/grub/grubbatch", "DEVICE", hdparams
.devnode
);
1427 /* restore permissions */
1428 chmod("/harddisk/boot/grub/grubbatch", S_IXUSR
| S_IRUSR
| S_IXGRP
| S_IRGRP
| S_IXOTH
| S_IROTH
);
1431 sprintf(string
, "root=%sp4", hdparams
.devnode
);
1433 sprintf(string
, "root=%s4", hdparams
.devnode
);
1434 replace( "/harddisk/boot/grub/grub.conf", "root=ROOT", string
);
1436 mysystem("/bin/chroot /harddisk /bin/mount -n -t proc none /proc");
1438 snprintf(commandstring
, STRING_SIZE
, "/bin/chroot /harddisk /boot/grub/grubbatch");
1440 if (runcommandwithstatus(commandstring
, ctr
[TR_INSTALLING_GRUB
]))
1442 errorbox(ctr
[TR_UNABLE_TO_INSTALL_GRUB
]);
1445 /* Set Bootsplash */
1446 mysystem("/bin/installbootsplash.sh");
1447 mysystem("/bin/chroot /harddisk /bin/umount -n /proc");
1450 snprintf(commandstring
, STRING_SIZE
, "/bin/chroot /harddisk /sbin/swriteboot -f3 %s /boot/bootlx", hdparams
.devnode
);
1451 mysystem(commandstring
);
1452 snprintf(commandstring
, STRING_SIZE
, "/bin/chroot /harddisk /sbin/abootconf %s 1", hdparams
.devnode
);
1453 mysystem(commandstring
);
1455 sprintf(string
, "root=%sp4", hdparams
.devnode
);
1457 sprintf(string
, "root=%s4", hdparams
.devnode
);
1458 replace( "/harddisk/boot/etc/aboot.conf", "root=ROOT", string
);
1461 /* unmounting happens everywhere because there are places
1462 which require device is to be unmounted under certain
1463 circumstances. This is the last place we can unmount
1464 anything and still succeed. */
1466 if (!unmount_before
&& installtype
== CDROM_INSTALL
){
1467 if (mysystem("/sbin/umount /cdrom"))
1469 errorbox(ctr
[TR_UNABLE_TO_UNMOUNT_CDROM
]);
1474 if (installtype
== CDROM_INSTALL
)
1477 if (!(ejectcdrom(cdromparams
.devnode
)))
1479 errorbox(ctr
[TR_UNABLE_TO_EJECT_CDROM
]);
1485 sprintf(message
, ctr
[TR_CONGRATULATIONS_LONG
],
1486 NAME
, SNAME
, SNAME
, NAME
, NAME
, NAME
);
1487 newtWinMessage(ctr
[TR_CONGRATULATIONS
], ctr
[TR_OK
], message
);
1492 fprintf(flog
, "Install program ended.\n");
1497 newtWinMessage(title
, ctr
[TR_OK
], ctr
[TR_PRESS_OK_TO_REBOOT
]);
1501 freekeyvalues(ethernetkv
);
1503 if (allok
&& !allok_fastexit
)
1505 /* /proc is needed by the module checker. We have to mount it
1506 * so it can be seen by setup, which is run chrooted. */
1507 if (system("/sbin/mount proc -t proc /harddisk/proc"))
1508 printf("Unable to mount proc in /harddisk.");
1511 if (system("/bin/chroot /harddisk /usr/local/sbin/setup /dev/tty2 INSTALL"))
1512 printf("Unable to run setup.\n");
1513 if (system("/sbin/umount /harddisk/proc"))
1514 printf("Unable to umount /harddisk/proc.\n");
1520 system("/bin/swapoff /harddisk/swapfile");
1521 system("/sbin/umount /harddisk/var/log");
1522 system("/sbin/umount /harddisk/boot");
1523 system("/sbin/umount /harddisk");
1525 system("/etc/halt");