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 7000
18 #define UNATTENDED_CONF "/cdrom/boot/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 long calc_swapsize(long memory
, long disk
) {
60 int unattended_setup(struct keyvalue
*unattendedkv
) {
61 struct keyvalue
*mainsettings
= initkeyvalues();
62 struct keyvalue
*ethernetkv
= initkeyvalues();
64 char commandstring
[STRING_SIZE
];
66 char domainname
[STRING_SIZE
];
67 char hostname
[STRING_SIZE
];
68 char keymap
[STRING_SIZE
];
69 char language
[STRING_SIZE
];
70 char timezone
[STRING_SIZE
];
71 char theme
[STRING_SIZE
];
72 char green_address
[STRING_SIZE
];
73 char green_netmask
[STRING_SIZE
];
74 char green_netaddress
[STRING_SIZE
];
75 char green_broadcast
[STRING_SIZE
];
76 char root_password
[STRING_SIZE
];
77 char admin_password
[STRING_SIZE
];
79 findkey(unattendedkv
, "DOMAINNAME", domainname
);
80 findkey(unattendedkv
, "HOSTNAME", hostname
);
81 findkey(unattendedkv
, "KEYMAP", keymap
);
82 findkey(unattendedkv
, "LANGUAGE", language
);
83 findkey(unattendedkv
, "TIMEZONE", timezone
);
84 findkey(unattendedkv
, "THEME", theme
);
85 findkey(unattendedkv
, "GREEN_ADDRESS", green_address
);
86 findkey(unattendedkv
, "GREEN_NETMASK", green_netmask
);
87 findkey(unattendedkv
, "GREEN_NETADDRESS", green_netaddress
);
88 findkey(unattendedkv
, "GREEN_BROADCAST", green_broadcast
);
89 findkey(unattendedkv
, "ROOT_PASSWORD", root_password
);
90 findkey(unattendedkv
, "ADMIN_PASSWORD", admin_password
);
92 /* write main/settings. */
93 replacekeyvalue(mainsettings
, "DOMAINNAME", domainname
);
94 replacekeyvalue(mainsettings
, "HOSTNAME", hostname
);
95 replacekeyvalue(mainsettings
, "KEYMAP", keymap
);
96 replacekeyvalue(mainsettings
, "LANGUAGE", language
);
97 replacekeyvalue(mainsettings
, "TIMEZONE", timezone
);
98 replacekeyvalue(mainsettings
, "THEME", theme
);
99 writekeyvalues(mainsettings
, "/harddisk" CONFIG_ROOT
"/main/settings");
100 freekeyvalues(mainsettings
);
103 fprintf(flog
, "unattended: Starting setup\n");
106 fprintf(flog
, "unattended: setting up network configuration\n");
108 (void) readkeyvalues(ethernetkv
, "/harddisk" CONFIG_ROOT
"/ethernet/settings");
109 replacekeyvalue(ethernetkv
, "GREEN_ADDRESS", green_address
);
110 replacekeyvalue(ethernetkv
, "GREEN_NETMASK", green_netmask
);
111 replacekeyvalue(ethernetkv
, "GREEN_NETADDRESS", green_netaddress
);
112 replacekeyvalue(ethernetkv
, "GREEN_BROADCAST", green_broadcast
);
113 replacekeyvalue(ethernetkv
, "CONFIG_TYPE", "0");
114 replacekeyvalue(ethernetkv
, "GREEN_DEV", "eth0");
115 write_ethernet_configs(ethernetkv
);
116 freekeyvalues(ethernetkv
);
119 unlink("/harddisk/etc/localtime");
120 snprintf(commandstring
, STRING_SIZE
, "/harddisk/%s", timezone
);
121 link(commandstring
, "/harddisk/etc/localtime");
124 fprintf(flog
, "unattended: writing hostname.conf\n");
125 if (!(file
= fopen("/harddisk" CONFIG_ROOT
"/main/hostname.conf", "w")))
127 errorbox("unattended: ERROR writing hostname.conf");
130 fprintf(file
, "ServerName %s\n", hostname
);
133 fprintf(flog
, "unattended: writing hosts\n");
134 if (!(hosts
= fopen("/harddisk/etc/hosts", "w")))
136 errorbox("unattended: ERROR writing hosts");
139 fprintf(hosts
, "127.0.0.1\tlocalhost\n");
140 fprintf(hosts
, "%s\t%s.%s\t%s\n", green_address
, hostname
, domainname
, hostname
);
143 fprintf(flog
, "unattended: writing hosts.allow\n");
144 if (!(file
= fopen("/harddisk/etc/hosts.allow", "w")))
146 errorbox("unattended: ERROR writing hosts.allow");
149 fprintf(file
, "sshd : ALL\n");
150 fprintf(file
, "ALL : localhost\n");
151 fprintf(file
, "ALL : %s/%s\n", green_netaddress
, green_netmask
);
154 fprintf(flog
, "unattended: writing hosts.deny\n");
155 if (!(file
= fopen("/harddisk/etc/hosts.deny", "w")))
157 errorbox("unattended: ERROR writing hosts.deny");
160 fprintf(file
, "ALL : ALL\n");
163 /* set root password */
164 fprintf(flog
, "unattended: setting root password\n");
165 snprintf(commandstring
, STRING_SIZE
,
166 "/sbin/chroot /harddisk /bin/sh -c \"echo 'root:%s' | /usr/sbin/chpasswd\"", root_password
);
167 if (mysystem(commandstring
)) {
168 errorbox("unattended: ERROR setting root password");
172 /* set admin password */
173 fprintf(flog
, "unattended: setting admin password\n");
174 snprintf(commandstring
, STRING_SIZE
,
175 "/sbin/chroot /harddisk /usr/sbin/htpasswd -c -m -b " CONFIG_ROOT
"/auth/users admin '%s'", admin_password
);
176 if (mysystem(commandstring
)) {
177 errorbox("unattended: ERROR setting admin password");
183 int main(int argc
, char *argv
[])
185 char *langnames
[] = { "Deutsch", "English", NULL
};
186 char *shortlangnames
[] = { "de", "en", NULL
};
187 char **langtrs
[] = { de_tr
, en_tr
, NULL
};
188 char hdletter
, cdletter
;
189 char harddrive
[5], sourcedrive
[5]; /* Device holder. */
190 struct devparams hdparams
, cdromparams
; /* Params for CDROM and HD */
191 int cdmounted
= 0; /* Loop flag for inserting a cd. */
193 char commandstring
[STRING_SIZE
];
194 char *installtypes
[] = { "CDROM/USB", "HTTP/FTP", NULL
};
195 int installtype
= CDROM_INSTALL
;
196 char insertmessage
[STRING_SIZE
];
197 char insertdevnode
[STRING_SIZE
];
199 char shortlangname
[10];
201 char title
[STRING_SIZE
];
203 int allok_fastexit
=0;
204 int unmount_before
=0;
205 struct keyvalue
*ethernetkv
= initkeyvalues();
206 FILE *handle
, *cmdfile
;
207 char line
[STRING_SIZE
];
208 char string
[STRING_SIZE
];
209 long maximum_free
= 0, current_free
;
211 long system_partition
, boot_partition
, root_partition
, swap_file
;
214 int pcmcia_cdrom
= 0;
219 char *yesnoharddisk
[] = { "NO", "YES", NULL
};
220 char *yesno
[] = { "NO", "YES", NULL
};
221 char green
[STRING_SIZE
];
223 struct keyvalue
*unattendedkv
= initkeyvalues();
224 char packages
[STRING_SIZE
];
225 int serial_console
= 0;
226 char megabridge
[STRING_SIZE
];
228 setlocale (LC_ALL
, "");
229 sethostname( SNAME
, 10);
231 memset(&hdparams
, 0, sizeof(struct devparams
));
232 memset(&cdromparams
, 0, sizeof(struct devparams
));
234 /* Log file/terminal stuff. */
237 if (!(flog
= fopen(argv
[1], "w+")))
245 fprintf(flog
, "Install program started.\n");
250 /* Do usb detection first for usb keyboard */
251 if (! (cmdfile
= fopen("/proc/cmdline", "r")))
253 fprintf(flog
, "Couldn't open commandline: /proc/cmdline\n");
255 fgets(line
, STRING_SIZE
, cmdfile
);
256 if (strstr (line
, "fdisk") != NULL
) {
257 fprintf(flog
, "Manual FDISK selected.\n");
260 if (strstr (line
, "nousb") == NULL
) {
261 fprintf(flog
, "Initializing USB controllers.\n");
264 fprintf(flog
, "Skipping USB detection.\n");
266 // check if we have to make an unattended install
267 if (strstr (line
, "unattended") != NULL
) {
272 // make some beeps before wiping the system :)
274 runcommandwithstatus("/bin/sleep 10", "WARNING: Unattended installation will start in 10 seconds...");
277 /* German is the default */
278 for (choice
= 0; langnames
[choice
]; choice
++)
280 if (strcmp(langnames
[choice
], "Deutsch") == 0)
283 if (!langnames
[choice
])
287 rc
= newtWinMenu("Language selection",
288 "Select the language you wish to use for the " NAME
".", 50, 5, 5, 8,
289 langnames
, &choice
, "Ok", NULL
);
292 ctr
= langtrs
[choice
];
293 strcpy(shortlangname
, shortlangnames
[choice
]);
295 mysystem("/bin/setfont lat0-16");
297 newtDrawRootText(14, 0, NAME
" " VERSION
" - " SLOGAN
);
298 newtPushHelpLine(ctr
[TR_HELPLINE
]);
301 sprintf(message
, ctr
[TR_WELCOME
], NAME
);
302 sprintf (title
, "%s %s - %s", NAME
, VERSION
, SLOGAN
);
303 newtWinMessage(title
, ctr
[TR_OK
], message
);
305 sprintf(message
, ctr
[TR_SELECT_INSTALLATION_MEDIA_LONG
], NAME
);
306 rc
= newtWinMenu(ctr
[TR_SELECT_INSTALLATION_MEDIA
], message
,
307 50, 5, 5, 6, installtypes
, &installtype
, ctr
[TR_OK
],
308 ctr
[TR_CANCEL
], NULL
);
312 installtype
= CDROM_INSTALL
;
318 // Starting hardware detection
319 runcommandwithstatus("/bin/probehw.sh", ctr
[TR_PROBING_HARDWARE
]);
322 if (installtype
== CDROM_INSTALL
) {
324 switch (mysystem("/bin/mountsource.sh")) {
326 installtype
= CDROM_INSTALL
;
330 installtype
= DISK_INSTALL
;
333 errorbox(ctr
[TR_NO_CDROM
]);
337 /* read source drive letter */
338 if ((handle
= fopen("/tmp/source_device", "r")) == NULL
) {
339 errorbox(ctr
[TR_ERROR_PROBING_CDROM
]);
342 fgets(sourcedrive
, 5, handle
);
343 fprintf(flog
, "Source drive: %s\n", sourcedrive
);
346 snprintf(cdromparams
.devnode
, STRING_SIZE
, "/dev/%s", sourcedrive
);
347 cdromparams
.module
= 0;
348 fprintf(flog
, "Source device: %s\n", cdromparams
.devnode
);
351 /* Configure the network now! */
352 if (installtype
== URL_INSTALL
) {
353 /* Network driver and params. */
354 if (!(networkmenu(ethernetkv
))) {
355 errorbox(ctr
[TR_NETWORK_SETUP_FAILED
]);
359 /* Check for ipcop-<VERSION>.tbz2 */
360 if (checktarball(SNAME
"-" VERSION
".tbz2", ctr
[TR_ENTER_URL
])) {
361 errorbox(ctr
[TR_NO_IPCOP_TARBALL_FOUND
]);
366 /* Get device for the HD. This has to succeed. */
367 if (!(hdletter
= findidetype(IDE_HD
)))
369 /* Need to clean this up at some point */
370 if (!try_scsi("sda") || strstr(sourcedrive
, "sda") != NULL
) {
371 if (!try_scsi("ida/c0d0")) {
372 if (!try_scsi("cciss/c0d0")) {
373 if (!try_scsi("rd/c0d0")) {
374 if (!try_scsi("ataraid/d0")) {
375 errorbox(ctr
[TR_NO_HARDDISK
]);
379 sprintf(harddrive
, "ataraid/d0");
383 sprintf(harddrive
, "rd/c0d0");
387 sprintf(harddrive
, "cciss/c0d0");
391 sprintf(harddrive
, "ida/c0d0");
394 if (strstr(sourcedrive
, "sda") != NULL
) {
395 // probably installing from usb stick, try sdb
396 if (try_scsi("sdb")) {
397 sprintf(harddrive
, "sdb");
400 errorbox(ctr
[TR_NO_HARDDISK
]);
405 sprintf(harddrive
, "sda");
410 sprintf(harddrive
, "hd%c", hdletter
);
412 fprintf(flog
, "Destination drive: %s\n", harddrive
);
414 /* load unattended configuration */
416 fprintf(flog
, "unattended: Reading unattended.conf\n");
418 (void) readkeyvalues(unattendedkv
, UNATTENDED_CONF
);
421 /* Make the hdparms struct and print the contents. */
422 snprintf(hdparams
.devnode
, STRING_SIZE
, "/dev/%s", harddrive
);
425 sprintf(message
, ctr
[TR_PREPARE_HARDDISK
], hdparams
.devnode
);
432 rc
= newtWinMenu(title
, message
,
433 50, 5, 5, 6, yesnoharddisk
,
435 ctr
[TR_CANCEL
], NULL
);
443 /* Calculate amount of memory in machine */
444 if ((handle
= fopen("/proc/meminfo", "r")))
446 while (fgets(line
, STRING_SIZE
-1, handle
)) {
447 if (sscanf (line
, "MemTotal: %s kB", string
)) {
448 memory
= atoi(string
) / 1024 ;
454 /* Partition, mkswp, mkfs.
455 * before partitioning, first determine the sizes of each
456 * partition. In order to do that we need to know the size of
459 /* Don't use mysystem here so we can redirect output */
460 sprintf(commandstring
, "/bin/sfdisk -s /dev/%s > /tmp/disksize 2> /dev/null", harddrive
);
461 system(commandstring
);
463 /* Calculate amount of disk space */
464 if ((handle
= fopen("/tmp/disksize", "r")))
466 fgets(line
, STRING_SIZE
-1, handle
);
467 if (sscanf (line
, "%s", string
)) {
468 maximum_free
= atoi(string
) / 1024;
473 fprintf(flog
, "maximum_free = %ld, memory = %ld",
474 maximum_free
, memory
);
476 swap_file
= calc_swapsize(memory
, maximum_free
);
478 if (maximum_free
< 512 + swap_file
) {
479 if (maximum_free
< 512) {
480 errorbox(ctr
[TR_DISK_TOO_SMALL
]);
485 rc
= newtWinChoice(title
, ctr
[TR_OK
], ctr
[TR_CANCEL
], ctr
[TR_CONTINUE_NO_SWAP
]);
496 boot_partition
= 20; /* in MB */
497 current_free
= maximum_free
- boot_partition
- swap_file
;
499 root_partition
= 2048 ;
500 if (current_free
< 512) {
501 errorbox(ctr
[TR_DISK_TOO_SMALL
]);
505 current_free
= current_free
- root_partition
;
507 root_partition
= root_partition
+ swap_file
;
510 system_partition
= current_free
;
512 fprintf(flog
, "boot = %ld, swap = %ld, mylog = %ld, root = %ld\n",
513 boot_partition
, swap_file
, system_partition
, root_partition
);
515 handle
= fopen("/tmp/partitiontable", "w");
519 fprintf(handle
, ",%ld,L,*\n,%ld,S,\n,%ld,L,\n,,L,\n",
520 boot_partition
, swap_file
, root_partition
);
522 fprintf(handle
, ",%ld,L,*\n,0,0,\n,%ld,L,\n,,L,\n",
523 boot_partition
, root_partition
);
528 snprintf(commandstring
, STRING_SIZE
, "/bin/sfdisk -L -uM %s < /tmp/partitiontable", hdparams
.devnode
);
529 if (runcommandwithstatus(commandstring
, ctr
[TR_PARTITIONING_DISK
]))
531 errorbox(ctr
[TR_UNABLE_TO_PARTITION
]);
535 mysystem("/sbin/udevstart");
538 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -T ext2 -c %sp1", hdparams
.devnode
);
540 snprintf(commandstring
, STRING_SIZE
, "/bin/mke2fs -T ext2 -c %s1", hdparams
.devnode
);
541 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_BOOT_FILESYSTEM
]))
543 errorbox(ctr
[TR_UNABLE_TO_MAKE_BOOT_FILESYSTEM
]);
549 snprintf(commandstring
, STRING_SIZE
, "/sbin/mkswap %sp2", hdparams
.devnode
);
551 snprintf(commandstring
, STRING_SIZE
, "/sbin/mkswap %s2", hdparams
.devnode
);
552 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_SWAPSPACE
]))
554 errorbox(ctr
[TR_UNABLE_TO_MAKE_SWAPSPACE
]);
560 snprintf(commandstring
, STRING_SIZE
, "/sbin/mkfs.reiser4 -f %sp3", hdparams
.devnode
);
562 snprintf(commandstring
, STRING_SIZE
, "/sbin/mkfs.reiser4 -f %s3", hdparams
.devnode
);
564 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_ROOT_FILESYSTEM
]))
566 errorbox(ctr
[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM
]);
571 snprintf(commandstring
, STRING_SIZE
, "/sbin/mkfs.reiser4 -f %sp4", hdparams
.devnode
);
573 snprintf(commandstring
, STRING_SIZE
, "/sbin/mkfs.reiser4 -f %s4", hdparams
.devnode
);
575 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_LOG_FILESYSTEM
]))
577 errorbox(ctr
[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM
]);
581 /* Mount harddisk. */
583 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %sp3 /harddisk", hdparams
.devnode
);
585 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %s3 /harddisk", hdparams
.devnode
);
586 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_ROOT_FILESYSTEM
]))
588 errorbox(ctr
[TR_UNABLE_TO_MOUNT_ROOT_FILESYSTEM
]);
592 mkdir("/harddisk/boot", S_IRWXU
|S_IRWXG
|S_IRWXO
);
593 mkdir("/harddisk/var", S_IRWXU
|S_IRWXG
|S_IRWXO
);
594 mkdir("/harddisk/var/log", S_IRWXU
|S_IRWXG
|S_IRWXO
);
597 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %sp1 /harddisk/boot", hdparams
.devnode
);
599 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %s1 /harddisk/boot", hdparams
.devnode
);
601 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_BOOT_FILESYSTEM
]))
603 errorbox(ctr
[TR_UNABLE_TO_MOUNT_BOOT_FILESYSTEM
]);
608 snprintf(commandstring
, STRING_SIZE
, "/sbin/swapon %sp2", hdparams
.devnode
);
610 snprintf(commandstring
, STRING_SIZE
, "/sbin/swapon %s2", hdparams
.devnode
);
611 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_SWAP_PARTITION
]))
613 errorbox(ctr
[TR_UNABLE_TO_MOUNT_SWAP_PARTITION
]);
618 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %sp4 /harddisk/var", hdparams
.devnode
);
620 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %s4 /harddisk/var", hdparams
.devnode
);
621 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_LOG_FILESYSTEM
]))
623 errorbox(ctr
[TR_UNABLE_TO_MOUNT_LOG_FILESYSTEM
]);
627 snprintf(commandstring
, STRING_SIZE
, "/bin/tar -C /harddisk -xvjf /cdrom/" SNAME
"-" VERSION
".tbz2");
629 if (runcommandwithprogress(60, 4, title
, commandstring
, INST_FILECOUNT
,
630 ctr
[TR_INSTALLING_FILES
]))
632 errorbox(ctr
[TR_UNABLE_TO_INSTALL_FILES
]);
636 /* Save USB controller type to modules.conf */
637 write_usb_modules_conf();
639 /* touch the modules.dep files */
640 snprintf(commandstring
, STRING_SIZE
,
641 "/sbin/chroot /harddisk /usr/bin/touch /lib/modules/%s/modules.dep",
643 mysystem(commandstring
);
644 snprintf(commandstring
, STRING_SIZE
,
645 "/sbin/chroot /harddisk /usr/bin/touch /lib/modules/%s-smp/modules.dep",
647 mysystem(commandstring
);
650 rename ("/harddisk/bin/uname.bak", "/harddisk/bin/uname");
652 /* *always* write disk configuration */
653 if (!(write_disk_configs(&hdparams
))){
654 errorbox(ctr
[TR_ERROR_WRITING_CONFIG
]);
658 /* mount proc filesystem */
659 mysystem("mkdir /harddisk/proc");
660 mysystem("/bin/mount -t proc none /harddisk/proc");
661 mysystem("/bin/mount --bind /dev /harddisk/dev");
665 /* if we detected SCSI then fixup */
666 /* doesn't really work cause it sometimes creates a ramdisk on ide systems */
667 /* mysystem("/bin/probecntrl.sh");
668 if ((handle = fopen("/cntrldriver", "r")))
671 fgets(line, STRING_SIZE-1, handle);
673 line[strlen(line) - 1] = 0;
674 driver = strtok(line, ".");
675 fprintf(flog, "Detected SCSI driver %s\n",driver);
676 if (strlen(driver) > 1) {
677 fprintf(flog, "Fixing up ipfirerd.img\n");
678 mysystem("/sbin/chroot /harddisk /sbin/modprobe loop");
679 mkdir("/harddisk/initrd", S_IRWXU|S_IRWXG|S_IRWXO);
680 snprintf(commandstring, STRING_SIZE, "/sbin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod --with=%s --with=sd_mod --with=sr_mod --with=libata /boot/ipfirerd.img %s", driver, KERNEL_VERSION);
681 runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]);
682 snprintf(commandstring, STRING_SIZE, "/sbin/chroot /harddisk /sbin/mkinitrd --with=scsi_mod --with=%s --with=sd_mod --with=sr_mod --with=libata /boot/ipfirerd-smp.img %s-smp", driver, KERNEL_VERSION);
683 runcommandwithstatus(commandstring, ctr[TR_BUILDING_INITRD]);
684 mysystem("/sbin/chroot /harddisk /bin/mv /boot/grub/scsigrub.conf /boot/grub/grub.conf");
688 /* Build cache lang file */
689 snprintf(commandstring
, STRING_SIZE
, "/sbin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT
"/lang.pl'; &Lang::BuildCacheLang\"");
690 if (runcommandwithstatus(commandstring
, ctr
[TR_INSTALLING_LANG_CACHE
]))
692 errorbox(ctr
[TR_UNABLE_TO_INSTALL_LANG_CACHE
]);
697 sprintf(string
, "root=%sp3", hdparams
.devnode
);
699 sprintf(string
, "root=%s3", hdparams
.devnode
);
700 replace( "/harddisk/boot/grub/grub.conf", "root=ROOT", string
);
701 replace( "/harddisk/boot/grub/grubbatch", "DEVICE", hdparams
.devnode
);
703 /* restore permissions */
704 chmod("/harddisk/boot/grub/grubbatch", S_IXUSR
| S_IRUSR
| S_IXGRP
| S_IRGRP
| S_IXOTH
| S_IROTH
);
706 snprintf(commandstring
, STRING_SIZE
,
707 "/sbin/chroot /harddisk /boot/grub/grubbatch");
708 if (runcommandwithstatus(commandstring
, ctr
[TR_INSTALLING_GRUB
])) {
709 errorbox(ctr
[TR_UNABLE_TO_INSTALL_GRUB
]);
713 /* Update /etc/fstab */
714 replace( "/harddisk/etc/fstab", "DEVICE", hdparams
.devnode
);
716 /* Install bootsplash */
717 mysystem("/bin/installbootsplash.sh");
719 mysystem("ln -s grub.conf /harddisk/boot/grub/menu.lst");
720 mysystem("umount /harddisk/proc");
721 mysystem("umount /harddisk/dev");
724 sprintf(message
, ctr
[TR_CONGRATULATIONS_LONG
],
725 NAME
, SNAME
, SNAME
, NAME
, NAME
, NAME
);
726 newtWinMessage(ctr
[TR_CONGRATULATIONS
], ctr
[TR_OK
], message
);
732 fprintf(flog
, "Install program ended.\n");
737 newtWinMessage(title
, ctr
[TR_OK
], ctr
[TR_PRESS_OK_TO_REBOOT
]);
741 freekeyvalues(ethernetkv
);
743 if (allok
&& !allok_fastexit
)
745 /* /proc is needed by the module checker. We have to mount it
746 * so it can be seen by setup, which is run chrooted. */
747 if (system("/bin/mount proc -t proc /harddisk/proc"))
748 printf("Unable to mount proc in /harddisk.");
753 if (system("/sbin/chroot /harddisk /usr/local/sbin/setup /dev/tty2 INSTALL"))
754 printf("Unable to run setup.\n");
757 fprintf(flog
, "Entering unattended setup\n");
758 unattended_setup(unattendedkv
);
759 snprintf(commandstring
, STRING_SIZE
, "/bin/sleep 10");
760 runcommandwithstatus(commandstring
, "Unattended installation finished, system will reboot");
763 if (system("/bin/umount /harddisk/proc"))
764 printf("Unable to umount /harddisk/proc.\n");
772 snprintf(commandstring
, STRING_SIZE
, "/bin/swapoff %sp2", hdparams
.devnode
);
774 snprintf(commandstring
, STRING_SIZE
, "/bin/swapoff %s2", hdparams
.devnode
);
779 system("/bin/umount /harddisk/var");
780 system("/bin/umount /harddisk/boot");
781 system("/bin/umount /harddisk");