]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | /* SmoothWall install program.\r |
2 | *\r | |
3 | * This program is distributed under the terms of the GNU General Public\r | |
4 | * Licence. See the file COPYING for details.\r | |
5 | *\r | |
6 | * (c) Lawrence Manning, 2001\r | |
7 | * Contains main entry point, and misc functions.\r | |
8 | * \r | |
9 | * $Id: main.c,v 1.63.2.64 2006/01/11 01:01:38 franck78 Exp $\r | |
10 | * \r | |
11 | */\r | |
12 | #include "install.h"\r | |
13 | \r | |
14 | #define CDROM_INSTALL 0\r | |
15 | #define URL_INSTALL 1\r | |
16 | \r | |
17 | int raid_disk = 0;\r | |
18 | FILE *flog = NULL;\r | |
19 | char *mylog;\r | |
20 | char **ctr;\r | |
21 | \r | |
22 | char *pcmcia = NULL;\r | |
23 | extern char url[STRING_SIZE];\r | |
24 | \r | |
25 | /* \r | |
26 | To include a translated string in the final installer, you must reference\r | |
27 | it here with a simplr comment. This save a lot a space in the installer\r | |
28 | */\r | |
29 | /* TR_WELCOME */\r | |
30 | /* TR_HELPLINE */\r | |
31 | /* TR_OK */\r | |
32 | /* TR_ERROR */\r | |
33 | /* TR_SELECT_INSTALLATION_MEDIA_LONG */\r | |
34 | /* TR_SELECT_INSTALLATION_MEDIA */\r | |
35 | /* TR_CANCEL */\r | |
36 | /* TR_INSERT_FLOPPY */\r | |
37 | /* TR_INSTALLATION_CANCELED */\r | |
38 | /* TR_EXTRACTING_MODULES */\r | |
39 | /* TR_UNABLE_TO_EXTRACT_MODULES */\r | |
40 | /* TR_LOADING_PCMCIA */\r | |
41 | /* TR_PROBING_SCSI */\r | |
42 | /* TR_NO_CDROM */\r | |
43 | /* TR_INSERT_CDROM */\r | |
44 | /* TR_USB_KEY_VFAT_ERR */\r | |
45 | /* TR_NETWORK_SETUP_FAILED */\r | |
46 | /* TR_NO_IPCOP_TARBALL_FOUND */\r | |
47 | /* TR_NO_SCSI_IMAGE_FOUND */\r | |
48 | /* TR_INSTALLING_FILES */\r | |
49 | /* TR_UNABLE_TO_INSTALL_FILES */\r | |
50 | /* TR_NO_HARDDISK */\r | |
51 | /* TR_PREPARE_HARDDISK */\r | |
52 | /* TR_DISK_TOO_SMALL */\r | |
53 | /* TR_CONTINUE_NO_SWAP */\r | |
54 | /* TR_PARTITIONING_DISK */\r | |
55 | /* TR_UNABLE_TO_PARTITION */\r | |
56 | /* TR_MAKING_BOOT_FILESYSTEM */\r | |
57 | /* TR_UNABLE_TO_MAKE_BOOT_FILESYSTEM */\r | |
58 | /* TR_MAKING_LOG_FILESYSTEM */\r | |
59 | /* TR_UNABLE_TO_MAKE_LOG_FILESYSTEM */\r | |
60 | /* TR_MAKING_ROOT_FILESYSTEM */\r | |
61 | /* TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM */\r | |
62 | /* TR_MOUNTING_ROOT_FILESYSTEM */\r | |
63 | /* TR_UNABLE_TO_MOUNT_ROOT_FILESYSTEM */\r | |
64 | /* TR_MAKING_SWAPSPACE */\r | |
65 | /* TR_UNABLE_TO_MAKE_SWAPSPACE */\r | |
66 | /* TR_MOUNTING_SWAP_PARTITION */\r | |
67 | /* TR_UNABLE_TO_MOUNT_SWAP_PARTITION */\r | |
68 | /* TR_MOUNTING_BOOT_FILESYSTEM */\r | |
69 | /* TR_UNABLE_TO_MOUNT_BOOT_FILESYSTEM */\r | |
70 | /* TR_MOUNTING_LOG_FILESYSTEM */\r | |
71 | /* TR_UNABLE_TO_MOUNT_LOG_FILESYSTEM */\r | |
72 | /* TR_ERROR_WRITING_CONFIG */\r | |
73 | /* TR_INSTALLING_GRUB */\r | |
74 | /* TR_UNABLE_TO_INSTALL_GRUB */\r | |
75 | /* TR_UNABLE_TO_UNMOUNT_CDROM */\r | |
76 | /* TR_UNABLE_TO_EJECT_CDROM */\r | |
77 | /* TR_CONGRATULATIONS_LONG */\r | |
78 | /* TR_CONGRATULATIONS */\r | |
79 | /* TR_PRESS_OK_TO_REBOOT */\r | |
80 | \r | |
81 | // in nic.c\r | |
82 | /* TR_CONFIGURE_NETWORKING */\r | |
83 | /* TR_PROBE */\r | |
84 | /* TR_SELECT */\r | |
85 | /* TR_CONFIGURE_NETWORKING_LONG */\r | |
86 | /* TR_PROBE_FAILED */\r | |
87 | /* TR_FOUND_NIC */\r | |
88 | /* TR_INTERFACE_FAILED_TO_COME_UP */\r | |
89 | \r | |
90 | //netc.c\r | |
91 | /* TR_CHECKING */\r | |
92 | /* TR_FAILED_TO_FIND */\r | |
93 | /* TR_ENTER_URL */\r | |
94 | \r | |
95 | //setup.c\r | |
96 | /* TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK1 */\r | |
97 | /* TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK2 */\r | |
98 | /* TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK3 */\r | |
99 | /* TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK4 */\r | |
100 | /* TR_UNABLE_TO_MAKE_SYMLINK_DEV_HARDDISK */\r | |
101 | /* TR_UNABLE_TO_MAKE_SYMLINK_DEV_ROOT */\r | |
102 | /* TR_PASSWORD_PROMPT */\r | |
103 | /* TR_AGAIN_PROMPT */\r | |
104 | /* TR_PASSWORD_CANNOT_BE_BLANK */\r | |
105 | /* TR_PASSWORDS_DO_NOT_MATCH */\r | |
106 | \r | |
107 | //libsmooth\r | |
108 | /* TR_INTERFACE */\r | |
109 | /* TR_ENTER_THE_IP_ADDRESS_INFORMATION */\r | |
110 | /* TR_STATIC */\r | |
111 | /* TR_DHCP_HOSTNAME */\r | |
112 | /* TR_IP_ADDRESS_PROMPT */\r | |
113 | /* TR_NETMASK_PROMPT */\r | |
114 | /* TR_INVALID_FIELDS */\r | |
115 | /* TR_IP_ADDRESS_CR */\r | |
116 | /* TR_NETWORK_MASK_CR */\r | |
117 | /* TR_DHCP_HOSTNAME_CR */\r | |
118 | /* TR_LOOKING_FOR_NIC */\r | |
119 | /* TR_MANUAL */\r | |
120 | /* TR_SELECT_NETWORK_DRIVER */\r | |
121 | /* TR_SELECT_NETWORK_DRIVER_LONG */\r | |
122 | /* TR_UNABLE_TO_LOAD_DRIVER_MODULE */\r | |
123 | /* TR_THIS_DRIVER_MODULE_IS_ALREADY_LOADED */\r | |
124 | /* TR_MODULE_PARAMETERS */\r | |
125 | /* TR_LOADING_MODULE */\r | |
126 | /* TR_MODULE_NAME_CANNOT_BE_BLANK */\r | |
127 | \r | |
128 | \r | |
129 | int main(int argc, char *argv[])\r | |
130 | {\r | |
131 | #ifdef LANG_EN_ONLY\r | |
132 | char *langnames[] = { "English", NULL };\r | |
133 | char *shortlangnames[] = { "en", NULL };\r | |
134 | char **langtrs[] = { en_tr, NULL };\r | |
135 | #else\r | |
136 | char *langnames[] = { "Brasil", "Cestina", "Dansk", "Deutsch", "English", "Español", "Français", "Hellenic", "Italiano", "Spanish Latino", "Magyar", "Nederlands", "Norsk", "Polski", "Português", "Slovak", "Soomali", "Suomi", "Svenska", "Türkçe", "Tieng Viet", NULL };\r | |
137 | char *shortlangnames[] = { "bz", "cs", "da", "de", "en", "es", "fr", "el", "it", "la", "hu", "nl", "no", "pl", "pt", "sk", "so", "fi", "sv", "tr", "vi", NULL };\r | |
138 | char **langtrs[] = { bz_tr, cs_tr, da_tr, de_tr, en_tr, es_tr, fr_tr, el_tr, it_tr, la_tr, hu_tr, nl_tr, no_tr, pl_tr, pt_tr, sk_tr, so_tr, fi_tr, sv_tr, tr_tr, vi_tr, NULL };\r | |
139 | #endif\r | |
140 | char hdletter, cdletter;\r | |
141 | char harddrive[5], cdromdrive[5]; /* Device holder. */\r | |
142 | struct devparams hdparams, cdromparams; /* Params for CDROM and HD */\r | |
143 | int cdmounted = 0; /* Loop flag for inserting a cd. */ \r | |
144 | int rc;\r | |
145 | char commandstring[STRING_SIZE];\r | |
146 | char *installtypes[] = { "CDROM/USB-KEY", "HTTP/FTP", NULL };\r | |
147 | int installtype = CDROM_INSTALL; \r | |
148 | char insertmessage[STRING_SIZE];\r | |
149 | char insertdevnode[STRING_SIZE];\r | |
150 | int choice;\r | |
151 | char shortlangname[10];\r | |
152 | char message[1000];\r | |
153 | char title[STRING_SIZE];\r | |
154 | int allok = 0;\r | |
155 | int no_restore=0;\r | |
156 | int unmount_before=0;\r | |
157 | struct keyvalue *ethernetkv = initkeyvalues();\r | |
158 | FILE *handle, *cmdfile;\r | |
159 | char line[STRING_SIZE];\r | |
160 | char string[STRING_SIZE];\r | |
161 | int maximum_free = 0, current_free;\r | |
162 | int memory = 0;\r | |
163 | int log_partition, boot_partition, root_partition, swap_file;\r | |
164 | int scsi_disk = 0;\r | |
165 | int pcmcia_disk = 0;\r | |
166 | int pcmcia_cdrom = 0;\r | |
167 | int scsi_cdrom = 0;\r | |
168 | int ide_cdrom = 0;\r | |
169 | int fdisk = 0;\r | |
170 | int usb_cdrom = 0;\r | |
171 | \r | |
172 | setlocale (LC_ALL, "");\r | |
173 | sethostname(SNAME, 10);\r | |
174 | \r | |
175 | memset(&hdparams, 0, sizeof(struct devparams));\r | |
176 | memset(&cdromparams, 0, sizeof(struct devparams));\r | |
177 | \r | |
178 | /* Log file/terminal stuff. */\r | |
179 | if (argc >= 2)\r | |
180 | { \r | |
181 | if (!(flog = fopen(argv[1], "w+")))\r | |
182 | return 0;\r | |
183 | }\r | |
184 | else\r | |
185 | return 0;\r | |
186 | \r | |
187 | mylog = argv[1];\r | |
188 | \r | |
189 | fprintf(flog, "Install program started.\n");\r | |
190 | \r | |
191 | newtInit();\r | |
192 | newtCls();\r | |
193 | \r | |
194 | /* Do usb detection first for usb keyboard */\r | |
195 | if (! (cmdfile = fopen("/proc/cmdline", "r")))\r | |
196 | {\r | |
197 | fprintf(flog, "Couldn't open commandline: /proc/cmdline\n");\r | |
198 | } else {\r | |
199 | fgets(line, STRING_SIZE, cmdfile);\r | |
200 | if (strstr (line, "fdisk") != NULL) {\r | |
201 | fprintf(flog, "Manual FDISK selected.\n");\r | |
202 | fdisk = 1;\r | |
203 | }\r | |
204 | if (strstr (line, "nopcmcia") == NULL) {\r | |
205 | fprintf(flog, "Initializing PCMCIA controllers.\n");\r | |
206 | pcmcia = initialize_pcmcia();\r | |
207 | if (pcmcia) {\r | |
208 | fprintf (flog, "Detected PCMCIA Controller: %s.\n", pcmcia);\r | |
209 | sprintf(commandstring, "/sbin/modprobe %s", pcmcia);\r | |
210 | mysystem("/sbin/modprobe pcmcia_core");\r | |
211 | mysystem(commandstring);\r | |
212 | mysystem("/sbin/modprobe ds");\r | |
213 | /* pcmcia netcard drivers are not available from Boot floppy,\r | |
214 | * they will be loaded from Drivers floppy later */\r | |
215 | } else {\r | |
216 | fprintf (flog, "Detected No PCMCIA Controller.\n");\r | |
217 | }\r | |
218 | } else {\r | |
219 | fprintf(flog, "Skipping PCMCIA detection.\n");\r | |
220 | }\r | |
221 | if (strstr (line, "nousb") == NULL) {\r | |
222 | fprintf(flog, "Initializing USB controllers.\n");\r | |
223 | initialize_usb();\r | |
224 | } else {\r | |
225 | fprintf(flog, "Skipping USB detection.\n");\r | |
226 | }\r | |
227 | }\r | |
228 | \r | |
229 | /* English is the default */\r | |
230 | for (choice = 0; langnames[choice]; choice++)\r | |
231 | {\r | |
232 | if (strcmp(langnames[choice], "English") == 0)\r | |
233 | break;\r | |
234 | }\r | |
235 | if (!langnames[choice])\r | |
236 | goto EXIT;\r | |
237 | \r | |
238 | #ifdef LANG_EN_ONLY\r | |
239 | /* No need to ask. "choice" already has the index for English */\r | |
240 | #else\r | |
241 | rc = newtWinMenu("Language selection",\r | |
242 | "Select the language you wish to use for the " NAME ".", 50, 5, 5, 8,\r | |
243 | langnames, &choice, "Ok", NULL);\r | |
244 | #endif\r | |
245 | ctr = langtrs[choice];\r | |
246 | strcpy(shortlangname, shortlangnames[choice]);\r | |
247 | if (strcmp(shortlangname, "el") == 0)\r | |
248 | mysystem("/bin/setfont iso07u-16");\r | |
249 | else if (strcmp(shortlangname, "pt") == 0)\r | |
250 | mysystem("/bin/setfont lat1-16");\r | |
251 | else if (strcmp(shortlangname, "bz") == 0)\r | |
252 | mysystem("/bin/setfont lat1-16");\r | |
253 | else if (strcmp(shortlangname, "cs") == 0)\r | |
254 | mysystem("/bin/setfont lat2-16");\r | |
255 | else if (strcmp(shortlangname, "hu") == 0)\r | |
256 | mysystem("/bin/setfont lat2-16");\r | |
257 | else if (strcmp(shortlangname, "pl") == 0)\r | |
258 | mysystem("/bin/setfont lat2-16");\r | |
259 | else if (strcmp(shortlangname, "sk") == 0)\r | |
260 | mysystem("/bin/setfont lat2-16");\r | |
261 | else if (strcmp(shortlangname, "tr") == 0)\r | |
262 | mysystem("/bin/setfont lat5-16");\r | |
263 | else if (strcmp(shortlangname, "vi") == 0)\r | |
264 | mysystem("/bin/setfont viscii10-8x16");\r | |
265 | else\r | |
266 | mysystem("/bin/setfont lat0-16");\r | |
267 | \r | |
268 | /* need this for reading from formatted device */\r | |
269 | modprobe("vfat");\r | |
270 | \r | |
271 | newtDrawRootText(14, 0, NAME " v" VERSION " - " SLOGAN );\r | |
272 | newtPushHelpLine(ctr[TR_HELPLINE]);\r | |
273 | \r | |
274 | snprintf(message, STRING_SIZE, ctr[TR_WELCOME], NAME);\r | |
275 | snprintf (title, STRING_SIZE, "%s v%s - %s", NAME, VERSION, SLOGAN);\r | |
276 | newtWinMessage(title, ctr[TR_OK], message);\r | |
277 | \r | |
278 | snprintf(message,STRING_SIZE, ctr[TR_SELECT_INSTALLATION_MEDIA_LONG], NAME);\r | |
279 | rc = newtWinMenu(ctr[TR_SELECT_INSTALLATION_MEDIA], message,\r | |
280 | 50, 5, 5, 6, installtypes, &installtype, ctr[TR_OK],\r | |
281 | ctr[TR_CANCEL], NULL);\r | |
282 | \r | |
283 | if (rc == 2)\r | |
284 | goto EXIT;\r | |
285 | \r | |
286 | if (installtype == CDROM_INSTALL) // CD or USB-key\r | |
287 | {\r | |
288 | \r | |
289 | /* try usb key in superfloppy format only */\r | |
290 | if (checkusb("sda")) {\r | |
291 | sprintf(cdromdrive, "sda");\r | |
292 | usb_cdrom = 1;\r | |
293 | goto FOUND_SOURCE;\r | |
294 | }\r | |
295 | if (checkusb("sdb")) {\r | |
296 | sprintf(cdromdrive, "sdb");\r | |
297 | usb_cdrom = 1;\r | |
298 | goto FOUND_SOURCE;\r | |
299 | }\r | |
300 | \r | |
301 | /* look for an IDE CDROM. */\r | |
302 | if ((cdletter = findidetype(IDE_CDROM)))\r | |
303 | {\r | |
304 | sprintf(cdromdrive, "hd%c", cdletter);\r | |
305 | ide_cdrom = 1;\r | |
306 | goto FOUND_SOURCE;\r | |
307 | }\r | |
308 | \r | |
309 | /* If we have a USB attached CDROM then it will\r | |
310 | * have already appeared at /dev/scd0, so we\r | |
311 | * try to access it first, before asking for the\r | |
312 | * SCSI drivers disk.\r | |
313 | */\r | |
314 | if (try_scsi("scd0")) {\r | |
315 | sprintf(cdromdrive, "scd0");\r | |
316 | scsi_cdrom = 1;\r | |
317 | goto FOUND_SOURCE;\r | |
318 | }\r | |
319 | \r | |
320 | /* ask for supplemental SCSI driver */\r | |
321 | snprintf(insertmessage, STRING_SIZE, ctr[TR_INSERT_FLOPPY], NAME" SCSI");\r | |
322 | if (newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], insertmessage) != 1)\r | |
323 | {\r | |
324 | errorbox(ctr[TR_INSTALLATION_CANCELED]);\r | |
325 | goto EXIT;\r | |
326 | }\r | |
327 | \r | |
328 | /* extract new modules */\r | |
329 | if (runcommandwithstatus("/bin/tar -C / -xvzf /dev/floppy", ctr[TR_EXTRACTING_MODULES]))\r | |
330 | {\r | |
331 | errorbox(ctr[TR_UNABLE_TO_EXTRACT_MODULES]);\r | |
332 | goto EXIT;\r | |
333 | }\r | |
334 | /* and load PCMCIA */\r | |
335 | if (pcmcia)\r | |
336 | {\r | |
337 | /* trying to support SCSI pcmcia :-) */\r | |
338 | runcommandwithstatus("cardmgr -o -c /etc/pcmcia/scsi",\r | |
339 | ctr[TR_LOADING_PCMCIA]);\r | |
340 | if (try_scsi("scd0")) {\r | |
341 | sprintf(cdromdrive, "scd0");\r | |
342 | pcmcia_cdrom = 1;\r | |
343 | goto FOUND_SOURCE;\r | |
344 | }\r | |
345 | }\r | |
346 | \r | |
347 | /* try loading all SCSI modules with default options */\r | |
348 | /* Should expand this to allow options later though */\r | |
349 | runcommandwithstatus("/bin/probescsi.sh", ctr[TR_PROBING_SCSI]);\r | |
350 | \r | |
351 | /* If it fails, give up. */\r | |
352 | if (try_scsi("scd0")) {\r | |
353 | sprintf(cdromdrive, "scd0");\r | |
354 | scsi_cdrom = 1;\r | |
355 | goto FOUND_SOURCE;\r | |
356 | }\r | |
357 | \r | |
358 | /* Unable to find a valid source, give up */\r | |
359 | errorbox(ctr[TR_NO_CDROM]);\r | |
360 | goto EXIT;\r | |
361 | \r | |
362 | FOUND_SOURCE:\r | |
363 | sprintf(cdromparams.devnode_disk, "/dev/%s", cdromdrive);\r | |
364 | // cdromparams.module = 0;\r | |
365 | \r | |
366 | snprintf(insertmessage,STRING_SIZE ,ctr[TR_INSERT_CDROM], NAME);\r | |
367 | strcpy (insertdevnode, cdromparams.devnode_disk);\r | |
368 | }\r | |
369 | else /* don't understand why this follows... */\r | |
370 | {\r | |
371 | /* If we've done a PXE boot, we can skip the Drivers floppy,\r | |
372 | * as we've already got the modules in our instroot.gz */\r | |
373 | if (!(handle = fopen("/CDROMBOOT", "r"))) {\r | |
374 | snprintf(insertmessage, STRING_SIZE-12, ctr[TR_INSERT_FLOPPY], NAME);\r | |
375 | strcpy (insertdevnode , "/dev/floppy");\r | |
376 | } else {\r | |
377 | fclose(handle);\r | |
378 | cdmounted = 1;\r | |
379 | unmount_before = 1;\r | |
380 | }\r | |
381 | }\r | |
382 | \r | |
383 | /* Try to mount /cdrom with the device discovered */\r | |
384 | if (scsi_cdrom || ide_cdrom || usb_cdrom) {\r | |
385 | snprintf(commandstring, STRING_SIZE, "/bin/mount -o ro %s /cdrom", insertdevnode);\r | |
386 | int skip_dialog = 1;\r | |
387 | int sd_test = 0;\r | |
388 | while (!cdmounted)\r | |
389 | {\r | |
390 | /* for usb-key, we have to try sda then sda1. The key cannot be unpluged */\r | |
391 | if (sd_test == 1) { //change to sda1\r | |
392 | sprintf(commandstring, "/bin/mount -o ro %s1 /cdrom", insertdevnode);\r | |
393 | }\r | |
394 | if (sd_test == 2) { //the key do not contains a vfat file system\r | |
395 | errorbox(ctr[TR_USB_KEY_VFAT_ERR]);\r | |
396 | goto EXIT;\r | |
397 | }\r | |
398 | if (usb_cdrom) sd_test++; // next USB test\r | |
399 | \r | |
400 | if (!skip_dialog && !usb_cdrom) {\r | |
401 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], insertmessage);\r | |
402 | if (rc != 1)\r | |
403 | {\r | |
404 | errorbox(ctr[TR_INSTALLATION_CANCELED]);\r | |
405 | goto EXIT;\r | |
406 | }\r | |
407 | }\r | |
408 | skip_dialog = 0;\r | |
409 | if (mysystem(commandstring))\r | |
410 | continue; //mount failed, try again\r | |
411 | \r | |
412 | /*verify it's what we want */\r | |
413 | handle = fopen ("/cdrom/" SNAME "-" VERSION ".tgz", "r");\r | |
414 | if (handle == NULL) {\r | |
415 | mysystem ("/bin/umount /cdrom");\r | |
416 | continue; /* bad disk ! */\r | |
417 | }\r | |
418 | \r | |
419 | fclose (handle);\r | |
420 | cdmounted = 1;\r | |
421 | /* If we've booted from CDROM, then\r | |
422 | * we've already got the drivers,\r | |
423 | * so we can skip this unpack. */\r | |
424 | if ((handle = fopen("/CDROMBOOT", "r"))) {\r | |
425 | fclose(handle);\r | |
426 | break; /* ok we go everything */\r | |
427 | }\r | |
428 | /* unpack drivers */\r | |
429 | if (runcommandwithprogress(60, 4, title,\r | |
430 | "/bin/tar -C / -xvzf /cdrom/images/drivers-"VERSION".img",\r | |
431 | 175, ctr[TR_EXTRACTING_MODULES]))\r | |
432 | {\r | |
433 | errorbox(ctr[TR_UNABLE_TO_EXTRACT_MODULES]);\r | |
434 | goto EXIT;\r | |
435 | }\r | |
436 | }\r | |
437 | } else { /* no cd device were discovered, ask second diskette */\r | |
438 | sprintf(commandstring, "/bin/tar -C / -xvzf /dev/floppy");\r | |
439 | while (!cdmounted)\r | |
440 | {\r | |
441 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], insertmessage);\r | |
442 | if (rc != 1)\r | |
443 | {\r | |
444 | errorbox(ctr[TR_INSTALLATION_CANCELED]);\r | |
445 | goto EXIT;\r | |
446 | }\r | |
447 | if (runcommandwithprogress(60, 4, title, \r | |
448 | commandstring,\r | |
449 | 175, ctr[TR_EXTRACTING_MODULES]))\r | |
450 | {\r | |
451 | #if 0 /* disable this, so we allow for people putting in the wrong disk */\r | |
452 | errorbox(ctr[TR_UNABLE_TO_EXTRACT_MODULES]);\r | |
453 | goto EXIT;\r | |
454 | #endif\r | |
455 | }\r | |
456 | else\r | |
457 | {\r | |
458 | handle = fopen ("/bin/mke2fs", "r");\r | |
459 | if (handle != NULL) {\r | |
460 | fclose (handle);\r | |
461 | cdmounted = 1;\r | |
462 | }\r | |
463 | }\r | |
464 | }\r | |
465 | }\r | |
466 | \r | |
467 | /* PCMCIA controller is already detected\r | |
468 | * On Boot floppy, we didn't have the PCMCIA drivers\r | |
469 | * so load them now because they are installed from Drivers. */\r | |
470 | if (!(handle = fopen("/CDROMBOOT", "r"))) {\r | |
471 | if (strstr (line, "nopcmcia") == NULL) {\r | |
472 | fprintf(flog,"Floppy boot detected, loading PCMCIA drivers.\n");\r | |
473 | if (pcmcia) {\r | |
474 | fprintf (flog, "Detected PCMCIA Controller: %s.\n", pcmcia);\r | |
475 | sprintf(commandstring, "/sbin/modprobe %s", pcmcia);\r | |
476 | mysystem("/sbin/modprobe pcmcia_core");\r | |
477 | mysystem(commandstring);\r | |
478 | mysystem("/sbin/modprobe ds");\r | |
479 | } else {\r | |
480 | fprintf (flog, "Detected No PCMCIA Controller.\n");\r | |
481 | }\r | |
482 | } else {\r | |
483 | fprintf(flog, "Skipping PCMCIA detection.\n");\r | |
484 | }\r | |
485 | if (strstr (line, "nousb") == NULL) {\r | |
486 | fprintf(flog, "Initializing USB controllers.\n");\r | |
487 | initialize_usb();\r | |
488 | } else {\r | |
489 | fprintf(flog, "Skipping USB detection.\n");\r | |
490 | }\r | |
491 | } else\r | |
492 | fclose(handle);\r | |
493 | \r | |
494 | /* Configure the network now! */\r | |
495 | if (installtype == URL_INSTALL)\r | |
496 | {\r | |
497 | /* Network driver and params. */\r | |
498 | if (!(networkmenu(ethernetkv)))\r | |
499 | {\r | |
500 | errorbox(ctr[TR_NETWORK_SETUP_FAILED]);\r | |
501 | goto EXIT;\r | |
502 | }\r | |
503 | \r | |
504 | /* Check for ipcop-<VERSION>.tgz */\r | |
505 | if (!(checktarball(SNAME "-" VERSION ".tgz")))\r | |
506 | {\r | |
507 | errorbox(ctr[TR_NO_IPCOP_TARBALL_FOUND]);\r | |
508 | goto EXIT;\r | |
509 | }\r | |
510 | }\r | |
511 | \r | |
512 | /* Get device for the HD. This has to succeed. */\r | |
513 | /* first try an IDE disk */\r | |
514 | if ((hdletter = findidetype(IDE_HD)))\r | |
515 | {\r | |
516 | sprintf(harddrive, "hd%c", hdletter);\r | |
517 | goto FOUND_DESTINATION;\r | |
518 | }\r | |
519 | /* unpack SCSI driver if not done during CD detection */\r | |
520 | if (installtype == URL_INSTALL)\r | |
521 | {\r | |
522 | /* If we've done a PXE boot, we can skip the SCSI\r | |
523 | * floppy as we've already got the modules in our \r | |
524 | * instroot.gz */\r | |
525 | if (!(handle = fopen("/CDROMBOOT", "r"))) \r | |
526 | {\r | |
527 | /* search img where it is on a mounted loop iso */\r | |
528 | if (!(checktarball("images/scsidrv-"VERSION".img")))\r | |
529 | {\r | |
530 | /* Couldn't find the SCSI drivers on the URL page,\r | |
531 | * so after 3 failed attempts, ask the user for the\r | |
532 | * SCSI drivers floppy disk. */\r | |
533 | errorbox(ctr[TR_NO_SCSI_IMAGE_FOUND]);\r | |
534 | snprintf(insertmessage, STRING_SIZE, ctr[TR_INSERT_FLOPPY], NAME" SCSI");\r | |
535 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], insertmessage);\r | |
536 | if (rc != 1)\r | |
537 | {\r | |
538 | errorbox(ctr[TR_INSTALLATION_CANCELED]);\r | |
539 | goto EXIT;\r | |
540 | }\r | |
541 | \r | |
542 | if (runcommandwithstatus("/bin/tar -C / -xvzf /dev/floppy", ctr[TR_EXTRACTING_MODULES]))\r | |
543 | {\r | |
544 | errorbox(ctr[TR_UNABLE_TO_EXTRACT_MODULES]);\r | |
545 | goto EXIT;\r | |
546 | }\r | |
547 | } else {\r | |
548 | /* unpack... THIS DO NOT WORK BECAUSE var "string" is empty*/\r | |
549 | snprintf(commandstring, STRING_SIZE,\r | |
550 | "/bin/wget -O - %s/%s | /bin/tar -C / -xvzf -",\r | |
551 | url, string);\r | |
552 | if (runcommandwithprogress(60, 4, title, commandstring,\r | |
553 | 4500, ctr[TR_INSTALLING_FILES]))\r | |
554 | {\r | |
555 | errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);\r | |
556 | goto EXIT;\r | |
557 | }\r | |
558 | }\r | |
559 | } else\r | |
560 | fclose(handle);\r | |
561 | } else { /* cdrom/usb install, install SCSI id not done */\r | |
562 | if (ide_cdrom) {\r | |
563 | if (runcommandwithstatus("/bin/tar -C / -xvzf /cdrom/images/scsidrv-"VERSION".img", ctr[TR_EXTRACTING_MODULES]))\r | |
564 | {\r | |
565 | errorbox(ctr[TR_UNABLE_TO_EXTRACT_MODULES]);\r | |
566 | goto EXIT;\r | |
567 | }\r | |
568 | }\r | |
569 | }\r | |
570 | \r | |
571 | /* load SCSI/pcmcia drivers if not done during CD detection */\r | |
572 | if (!scsi_cdrom) {\r | |
573 | #if 0 /* not yet */\r | |
574 | if (pcmcia)\r | |
575 | {\r | |
576 | /* trying to support SCSI pcmcia :-) */\r | |
577 | runcommandwithstatus("cardmgr -o -c /etc/pcmcia/scsi", \r | |
578 | ctr[TR_LOADING_PCMCIA]);\r | |
579 | if (try_scsi(usb_cdrom ? "sdb":"sda")) {\r | |
580 | scsi_disk = 1;\r | |
581 | pcmcia_disk = 1;\r | |
582 | }\r | |
583 | if (checkusb("sdb") && try_scsi("sdc")) {\r | |
584 | scsi_disk = 1;\r | |
585 | pcmcia_disk = 1;\r | |
586 | }\r | |
587 | }\r | |
588 | #endif\r | |
589 | /* try loading all SCSI modules with default options */\r | |
590 | /* Should expand this to allow options later though */\r | |
591 | if (!pcmcia_disk)\r | |
592 | runcommandwithstatus("/bin/probescsi.sh",\r | |
593 | ctr[TR_PROBING_SCSI]);\r | |
594 | }\r | |
595 | /* Now try to find destination device... \r | |
596 | Need to clean this up at some point\r | |
597 | scsi disk is sdb/sdc when sda/sdb is used for usb-key\r | |
598 | if scsi-disk is is sdd or more, it is not discovered\r | |
599 | */\r | |
600 | if (try_scsi(usb_cdrom ? "sdb":"sda")) {\r | |
601 | scsi_disk = 1;\r | |
602 | sprintf(harddrive, usb_cdrom ? "sdb":"sda");\r | |
603 | goto FOUND_DESTINATION;\r | |
604 | }\r | |
605 | if (checkusb("sdb") && try_scsi("sdc")) {\r | |
606 | scsi_disk = 1;\r | |
607 | sprintf(harddrive, "sdc");\r | |
608 | goto FOUND_DESTINATION;\r | |
609 | }\r | |
610 | if (try_scsi("ida/c0d0")) {\r | |
611 | raid_disk = 1;\r | |
612 | sprintf(harddrive, "ida/c0d0");\r | |
613 | goto FOUND_DESTINATION;\r | |
614 | }\r | |
615 | if (try_scsi("cciss/c0d0")) {\r | |
616 | raid_disk = 1;\r | |
617 | sprintf(harddrive, "cciss/c0d0");\r | |
618 | goto FOUND_DESTINATION;\r | |
619 | }\r | |
620 | if (try_scsi("rd/c0d0")) {\r | |
621 | raid_disk = 1;\r | |
622 | sprintf(harddrive, "rd/c0d0");\r | |
623 | goto FOUND_DESTINATION;\r | |
624 | }\r | |
625 | if (try_scsi("ataraid/d0")) {\r | |
626 | raid_disk = 1;\r | |
627 | sprintf(harddrive, "ataraid/d0");\r | |
628 | goto FOUND_DESTINATION;\r | |
629 | }\r | |
630 | /* nothing worked, give up */\r | |
631 | errorbox(ctr[TR_NO_HARDDISK]);\r | |
632 | goto EXIT;\r | |
633 | \r | |
634 | FOUND_DESTINATION:\r | |
635 | /* Make the hdparms struct and print the contents.\r | |
636 | With USB-KEY install and SCSI disk, while installing, the disk\r | |
637 | is named 'sdb,sdc,...' (following keys)\r | |
638 | On reboot, it will become 'sda'\r | |
639 | To avoid many test, all names are built in the struct.\r | |
640 | */\r | |
641 | sprintf(hdparams.devnode_disk, "/dev/%s", harddrive);\r | |
642 | /* Address the partition or raid partition (eg dev/sda or /dev/sdap1 */\r | |
643 | sprintf(hdparams.devnode_part, "/dev/%s%s", harddrive,raid_disk ? "p" : "");\r | |
644 | /* now the names after the machine is booted. Today only scsi is affected \r | |
645 | and we only install on the first scsi disk.\r | |
646 | */\r | |
647 | { char tmp[30];\r | |
648 | strcpy(tmp, scsi_disk ? "sda" : harddrive);\r | |
649 | sprintf(hdparams.devnode_disk_run, "/dev/%s", tmp);\r | |
650 | sprintf(hdparams.devnode_part_run, "/dev/%s%s", tmp, raid_disk ? "p" : "");\r | |
651 | }\r | |
652 | \r | |
653 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL],\r | |
654 | ctr[TR_PREPARE_HARDDISK], hdparams.devnode_disk_run);\r | |
655 | if (rc != 1)\r | |
656 | goto EXIT;\r | |
657 | \r | |
658 | /* Calculate amount of memory in machine */\r | |
659 | if ((handle = fopen("/proc/meminfo", "r")))\r | |
660 | {\r | |
661 | while (fgets(line, STRING_SIZE-1, handle)) {\r | |
662 | if (sscanf (line, "MemTotal: %s kB", string)) {\r | |
663 | memory = atoi(string) / 1024 ;\r | |
664 | }\r | |
665 | }\r | |
666 | fclose(handle);\r | |
667 | }\r | |
668 | \r | |
669 | /* Partition, mkswp, mkfs.\r | |
670 | * before partitioning, first determine the sizes of each\r | |
671 | * partition. In order to do that we need to know the size of\r | |
672 | * the disk. \r | |
673 | */\r | |
674 | /* Don't use mysystem here so we can redirect output */\r | |
675 | sprintf(commandstring, "/bin/sfdisk -s /dev/%s > /disksize 2> /dev/null", harddrive);\r | |
676 | system(commandstring);\r | |
677 | \r | |
678 | /* Calculate amount of disk space */\r | |
679 | if ((handle = fopen("/disksize", "r")))\r | |
680 | {\r | |
681 | fgets(line, STRING_SIZE-1, handle);\r | |
682 | if (sscanf (line, "%s", string)) {\r | |
683 | maximum_free = atoi(string) / 1024;\r | |
684 | }\r | |
685 | fclose(handle);\r | |
686 | }\r | |
687 | \r | |
688 | fprintf(flog, "maximum_free = %d, memory = %d", maximum_free, memory);\r | |
689 | \r | |
690 | /* If you need more than this, you should really add physical memory */\r | |
691 | /* Minimum: 192 = 64 real + 128 swap */\r | |
692 | swap_file = memory < 64 ? 2 * memory : 192 - memory ;\r | |
693 | swap_file = swap_file < 32 ? 32 : swap_file ;\r | |
694 | \r | |
695 | if (maximum_free < 135 + swap_file )\r | |
696 | {\r | |
697 | if (maximum_free < 135) {\r | |
698 | errorbox(ctr[TR_DISK_TOO_SMALL]);\r | |
699 | goto EXIT;\r | |
700 | }\r | |
701 | \r | |
702 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], ctr[TR_CONTINUE_NO_SWAP]);\r | |
703 | if (rc != 1)\r | |
704 | goto EXIT;\r | |
705 | swap_file = 0;\r | |
706 | }\r | |
707 | \r | |
708 | boot_partition = 8; /* in MB */\r | |
709 | current_free = maximum_free - boot_partition - swap_file;\r | |
710 | \r | |
711 | /* Give more place for add-on, extend root to 25% of current_free, upper limit to 8 gigas */\r | |
712 | root_partition = current_free / 4 ;\r | |
713 | root_partition = root_partition > 8192 ? 8192 : root_partition ;\r | |
714 | root_partition = current_free < 860 ? 235 : root_partition;\r | |
715 | root_partition = current_free < 380 ? 110 : root_partition;\r | |
716 | \r | |
717 | current_free = current_free - root_partition;\r | |
718 | root_partition = root_partition + swap_file;\r | |
719 | \r | |
720 | log_partition = current_free;\r | |
721 | \r | |
722 | fprintf(flog, "boot = %d, swap = %d, mylog = %d, root = %d\n",\r | |
723 | boot_partition, swap_file, log_partition, root_partition);\r | |
724 | \r | |
725 | #ifdef __alpha__\r | |
726 | fdisk = 1;\r | |
727 | #endif\r | |
728 | \r | |
729 | if (fdisk) {\r | |
730 | rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], "NOW FDISK");\r | |
731 | if (rc != 1)\r | |
732 | goto EXIT;\r | |
733 | } else {\r | |
734 | #ifdef __i386__\r | |
735 | handle = fopen("/tmp/partitiontable", "w");\r | |
736 | \r | |
737 | fprintf(handle, ",%d,83,*\n,%d,83,\n,0,0,\n,,83,\n",\r | |
738 | boot_partition, log_partition);\r | |
739 | \r | |
740 | fclose(handle); \r | |
741 | \r | |
742 | sprintf(commandstring, "/bin/sfdisk -uM %s < /tmp/partitiontable", hdparams.devnode_disk);\r | |
743 | if (runcommandwithstatus(commandstring, ctr[TR_PARTITIONING_DISK]))\r | |
744 | {\r | |
745 | errorbox(ctr[TR_UNABLE_TO_PARTITION]);\r | |
746 | goto EXIT;\r | |
747 | }\r | |
748 | #endif\r | |
749 | }\r | |
750 | /* create filesystem boot partition 1 */\r | |
751 | sprintf(commandstring, "/bin/mke2fs -m 0 -j %s1", hdparams.devnode_part);\r | |
752 | if (runcommandwithstatus(commandstring, ctr[TR_MAKING_BOOT_FILESYSTEM]))\r | |
753 | {\r | |
754 | errorbox(ctr[TR_UNABLE_TO_MAKE_BOOT_FILESYSTEM]);\r | |
755 | goto EXIT;\r | |
756 | }\r | |
757 | \r | |
758 | /* create filesystem log partition 2 */\r | |
759 | sprintf(commandstring, "/bin/mke2fs -j %s2", hdparams.devnode_part);\r | |
760 | if (runcommandwithstatus(commandstring, ctr[TR_MAKING_LOG_FILESYSTEM]))\r | |
761 | {\r | |
762 | errorbox(ctr[TR_UNABLE_TO_MAKE_LOG_FILESYSTEM]);\r | |
763 | goto EXIT;\r | |
764 | }\r | |
765 | \r | |
766 | /* create filesystem root partition 4 */\r | |
767 | sprintf(commandstring, "/bin/mke2fs -m 1 -j %s4", hdparams.devnode_part);\r | |
768 | if (runcommandwithstatus(commandstring, ctr[TR_MAKING_ROOT_FILESYSTEM]))\r | |
769 | {\r | |
770 | errorbox(ctr[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM]);\r | |
771 | goto EXIT;\r | |
772 | }\r | |
773 | \r | |
774 | /* Mount root on partition 4 */\r | |
775 | sprintf(commandstring, "/sbin/mount -t ext2 %s4 /harddisk", hdparams.devnode_part);\r | |
776 | if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_ROOT_FILESYSTEM]))\r | |
777 | {\r | |
778 | errorbox(ctr[TR_UNABLE_TO_MOUNT_ROOT_FILESYSTEM]);\r | |
779 | goto EXIT;\r | |
780 | }\r | |
781 | mkdir("/harddisk/boot", S_IRWXU|S_IRWXG|S_IRWXO);\r | |
782 | mkdir("/harddisk/var", S_IRWXU|S_IRWXG|S_IRWXO); \r | |
783 | mkdir("/harddisk/var/log", S_IRWXU|S_IRWXG|S_IRWXO);\r | |
784 | \r | |
785 | /* Make,mount swapfile */\r | |
786 | if (swap_file) {\r | |
787 | sprintf(commandstring, "/bin/dd if=/dev/zero of=/harddisk/swapfile bs=1024k count=%d", swap_file);\r | |
788 | if (runcommandwithstatus(commandstring, ctr[TR_MAKING_SWAPSPACE]))\r | |
789 | {\r | |
790 | errorbox(ctr[TR_UNABLE_TO_MAKE_SWAPSPACE]);\r | |
791 | goto EXIT;\r | |
792 | }\r | |
793 | if (runcommandwithstatus("/bin/mkswap /harddisk/swapfile", ctr[TR_MAKING_SWAPSPACE]))\r | |
794 | {\r | |
795 | errorbox(ctr[TR_UNABLE_TO_MAKE_SWAPSPACE]);\r | |
796 | goto EXIT;\r | |
797 | }\r | |
798 | if (runcommandwithstatus("/bin/swapon /harddisk/swapfile", ctr[TR_MOUNTING_SWAP_PARTITION]))\r | |
799 | {\r | |
800 | errorbox(ctr[TR_UNABLE_TO_MOUNT_SWAP_PARTITION]);\r | |
801 | goto EXIT;\r | |
802 | }\r | |
803 | }\r | |
804 | \r | |
805 | /* Mount boot on partition 1 */\r | |
806 | sprintf(commandstring, "/sbin/mount -t ext2 %s1 /harddisk/boot", hdparams.devnode_part);\r | |
807 | if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_BOOT_FILESYSTEM]))\r | |
808 | {\r | |
809 | errorbox(ctr[TR_UNABLE_TO_MOUNT_BOOT_FILESYSTEM]);\r | |
810 | goto EXIT;\r | |
811 | }\r | |
812 | \r | |
813 | /* Mount log on partition 2 */\r | |
814 | sprintf(commandstring, "/sbin/mount -t ext2 %s2 /harddisk/var/log", hdparams.devnode_part);\r | |
815 | if (runcommandwithstatus(commandstring, ctr[TR_MOUNTING_LOG_FILESYSTEM]))\r | |
816 | {\r | |
817 | errorbox(ctr[TR_UNABLE_TO_MOUNT_LOG_FILESYSTEM]);\r | |
818 | goto EXIT;\r | |
819 | }\r | |
820 | \r | |
821 | /* Either use tarball from cdrom or download. */\r | |
822 | if (installtype == CDROM_INSTALL)\r | |
823 | snprintf(commandstring, STRING_SIZE, \r | |
824 | "/bin/tar -C /harddisk -xvzf /cdrom/" SNAME "-" VERSION ".tgz");\r | |
825 | else\r | |
826 | snprintf(commandstring, STRING_SIZE, \r | |
827 | "/bin/wget -O - %s/" SNAME "-" VERSION ".tgz | /bin/tar -C /harddisk -xvzf -", url);\r | |
828 | \r | |
829 | if (runcommandwithprogress(60, 4, title, commandstring, 4600,\r | |
830 | ctr[TR_INSTALLING_FILES]))\r | |
831 | {\r | |
832 | errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);\r | |
833 | goto EXIT;\r | |
834 | }\r | |
835 | \r | |
836 | /* Save USB controller type to modules.conf */\r | |
837 | write_usb_modules_conf();\r | |
838 | \r | |
839 | /* touch the modules.dep files */\r | |
840 | mysystem("/bin/chroot /harddisk /bin/touch /lib/modules/"KERNEL_VERSION"/modules.dep");\r | |
841 | #ifdef __i386__\r | |
842 | mysystem("/bin/chroot /harddisk /bin/touch /lib/modules/"KERNEL_VERSION"-smp/modules.dep");\r | |
843 | #endif\r | |
844 | \r | |
845 | /* Rename uname */\r | |
846 | rename ("/harddisk/bin/uname.bak", "/harddisk/bin/uname");\r | |
847 | \r | |
848 | /* Write PCMCIA Config */\r | |
849 | if (pcmcia) {\r | |
850 | handle = fopen("/harddisk/etc/modules.conf", "a");\r | |
851 | if (handle != NULL) {\r | |
852 | fprintf (handle, "# PCMCIA Settings\n");\r | |
853 | fprintf (handle, "alias pcmcia-controller %s\n", pcmcia);\r | |
854 | fclose(handle);\r | |
855 | }\r | |
856 | }\r | |
857 | \r | |
858 | handle = fopen("/harddisk/etc/pcmcia.conf", "w");\r | |
859 | if (handle != NULL) {\r | |
860 | if (pcmcia) {\r | |
861 | fprintf (handle, "PCMCIA=yes\n");\r | |
862 | fprintf (handle, "PCIC=%s\n", pcmcia);\r | |
863 | } else {\r | |
864 | fprintf (handle, "PCMCIA=no\n");\r | |
865 | fprintf (handle, "PCIC=\n");\r | |
866 | }\r | |
867 | fprintf (handle, "CARDMGR_OPTS=\n");\r | |
868 | fprintf (handle, "SCHEME=\n");\r | |
869 | fclose(handle);\r | |
870 | }\r | |
871 | \r | |
872 | /* *always* write disk configuration */\r | |
873 | if (!(write_disk_configs(&hdparams))){\r | |
874 | errorbox(ctr[TR_ERROR_WRITING_CONFIG]);\r | |
875 | goto EXIT;\r | |
876 | }\r | |
877 | \r | |
878 | /* \r | |
879 | Allow the user to restore their configuration from a floppy.\r | |
880 | It uses tar. If the tar fails for any reason, show user an\r | |
881 | error and go back to the restore/skip question. This gives\r | |
882 | the user the chance to have another go. */\r | |
883 | \r | |
884 | /* Program is outside install to save space on floppy \r | |
885 | */\r | |
886 | fprintf(flog, "Passing control to install2.\n"); \r | |
887 | fflush(flog);\r | |
888 | //newtSuspend();\r | |
889 | /* pass needed parameter for install 2 by position\r | |
890 | choice: index of langage selected\r | |
891 | devnode_disk: to prevent unmounting of it\r | |
892 | url: if network, allow restaure from it\r | |
893 | */\r | |
894 | sprintf(commandstring, "/harddisk/usr/local/bin/install2 %d %s %s",\r | |
895 | choice,\r | |
896 | strlen(cdromparams.devnode_disk ) ? cdromparams.devnode_disk : "none",\r | |
897 | strlen(url) ? url : "none"\r | |
898 | );\r | |
899 | no_restore = system(commandstring);\r | |
900 | //newtResume();\r | |
901 | \r | |
902 | /* if we installed from CD ROM then we didn't set up the\r | |
903 | network interface yet. Therefore, set up Network\r | |
904 | driver and params just before we need them.\r | |
905 | */\r | |
906 | if (no_restore && (installtype == CDROM_INSTALL)) { \r | |
907 | if (!(networkmenu(ethernetkv))){\r | |
908 | errorbox(ctr[TR_NETWORK_SETUP_FAILED]);\r | |
909 | goto EXIT;\r | |
910 | }\r | |
911 | }\r | |
912 | \r | |
913 | /* Build cache lang file */\r | |
914 | mysystem("/bin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT "/lang.pl'; &Lang::BuildCacheLang\"");\r | |
915 | \r | |
916 | /* write ethernet and lang configs only if they have not\r | |
917 | been restored from floppy already. */\r | |
918 | if (no_restore) {\r | |
919 | if (!write_ethernet_configs(ethernetkv)||\r | |
920 | !write_lang_configs(shortlangname)) {\r | |
921 | errorbox(ctr[TR_ERROR_WRITING_CONFIG]);\r | |
922 | goto EXIT;\r | |
923 | }\r | |
924 | }\r | |
925 | \r | |
926 | \r | |
927 | #if 0 /* not yet */\r | |
928 | if (pcmcia_disk)\r | |
929 | {\r | |
930 | fprintf(flog, "Detected SCSI driver PCMCIA\n");\r | |
931 | fprintf(flog, "Fixing up ipcoprd.img\n");\r | |
932 | mysystem("/bin/chroot /harddisk /sbin/modprobe loop");\r | |
933 | mkdir("/harddisk/initrd", S_IRWXU|S_IRWXG|S_IRWXO);\r | |
934 | mysystem("/bin/chroot /harddisk /sbin/pcinitrd -r "KERNEL_VERSION" /boot/ipcoprd.img");\r | |
935 | #ifdef __i386__\r | |
936 | mysystem("/bin/chroot /harddisk /bin/mv /boot/grub/scsigrub.conf /boot/grub/grub.conf");\r | |
937 | #endif\r | |
938 | #ifdef __alpha__\r | |
939 | mysystem("/bin/chroot /harddisk /bin/mv /boot/etc/scsiaboot.conf /boot/etc/aboot.conf");\r | |
940 | #endif\r | |
941 | }\r | |
942 | #endif\r | |
943 | \r | |
944 | #ifdef __i386__\r | |
945 | // to verify: with USB-key grubbatch install on sdb and boot sda....\r | |
946 | replace( "/harddisk/boot/grub/grubbatch", "DEVICE", hdparams.devnode_disk);\r | |
947 | /* restore permissions */\r | |
948 | chmod("/harddisk/boot/grub/grubbatch", S_IXUSR | S_IRUSR | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH);\r | |
949 | \r | |
950 | sprintf(string, "root=%s4", hdparams.devnode_part_run);\r | |
951 | replace( "/harddisk/boot/grub/grub.conf", "root=ROOT", string);\r | |
952 | \r | |
953 | mysystem("/bin/chroot /harddisk /bin/mount -n -t proc none /proc");\r | |
954 | \r | |
955 | if (runcommandwithstatus("/bin/chroot /harddisk /boot/grub/grubbatch", ctr[TR_INSTALLING_GRUB]))\r | |
956 | {\r | |
957 | errorbox(ctr[TR_UNABLE_TO_INSTALL_GRUB]);\r | |
958 | goto EXIT;\r | |
959 | }\r | |
960 | mysystem("/bin/chroot /harddisk /bin/umount -n /proc");\r | |
961 | #endif\r | |
962 | #ifdef __alpha__\r | |
963 | sprintf(commandstring, "/bin/chroot /harddisk /sbin/swriteboot -f3 %s /boot/bootlx", hdparams.devnode_disk);\r | |
964 | mysystem(commandstring);\r | |
965 | sprintf(commandstring, "/bin/chroot /harddisk /sbin/abootconf %s 1", hdparams.devnode_disk_run);\r | |
966 | mysystem(commandstring);\r | |
967 | sprintf(string, "root=%s4", hdparams.devnode_part_run);\r | |
968 | replace( "/harddisk/boot/etc/aboot.conf", "root=ROOT", string);\r | |
969 | #endif\r | |
970 | \r | |
971 | /* unmounting happens everywhere because there are places\r | |
972 | which require device is to be unmounted under certain\r | |
973 | circumstances. This is the last place we can unmount\r | |
974 | anything and still succeed.\r | |
975 | */\r | |
976 | \r | |
977 | if (!unmount_before && !usb_cdrom && installtype == CDROM_INSTALL){\r | |
978 | if (mysystem("/sbin/umount /cdrom"))\r | |
979 | {\r | |
980 | errorbox(ctr[TR_UNABLE_TO_UNMOUNT_CDROM]);\r | |
981 | goto EXIT;\r | |
982 | }\r | |
983 | }\r | |
984 | \r | |
985 | if ((installtype == CDROM_INSTALL) && !usb_cdrom)\r | |
986 | {\r | |
987 | if (!(ejectcdrom(cdromparams.devnode_disk)))\r | |
988 | {\r | |
989 | errorbox(ctr[TR_UNABLE_TO_EJECT_CDROM]);\r | |
990 | // goto EXIT;\r | |
991 | }\r | |
992 | }\r | |
993 | \r | |
994 | snprintf(message, STRING_SIZE, ctr[TR_CONGRATULATIONS_LONG],\r | |
995 | NAME, SNAME, SNAME, NAME, NAME, NAME);\r | |
996 | newtWinMessage(ctr[TR_CONGRATULATIONS], ctr[TR_OK], message);\r | |
997 | \r | |
998 | allok = 1;\r | |
999 | \r | |
1000 | EXIT:\r | |
1001 | fprintf(flog, "Install program ended.\n");\r | |
1002 | fflush(flog);\r | |
1003 | fclose(flog);\r | |
1004 | \r | |
1005 | if (!allok)\r | |
1006 | newtWinMessage(title, ctr[TR_OK], ctr[TR_PRESS_OK_TO_REBOOT]); \r | |
1007 | \r | |
1008 | newtFinished();\r | |
1009 | \r | |
1010 | freekeyvalues(ethernetkv);\r | |
1011 | //no more needed\r | |
1012 | mysystem("/bin/chroot /harddisk /bin/rm /usr/local/bin/install2");\r | |
1013 | \r | |
1014 | /* run setup only if config not restored from floppy already. */\r | |
1015 | if (allok && no_restore)\r | |
1016 | {\r | |
1017 | /* /proc is needed by the module checker. We have to mount it\r | |
1018 | * so it can be seen by setup, which is run chrooted. */\r | |
1019 | if (system("/sbin/mount proc -t proc /harddisk/proc"))\r | |
1020 | printf("Unable to mount proc in /harddisk.");\r | |
1021 | else\r | |
1022 | {\r | |
1023 | if (system("/bin/chroot /harddisk /usr/local/sbin/setup /dev/tty2 INSTALL"))\r | |
1024 | printf("Unable to run setup.\n");\r | |
1025 | if (system("/sbin/umount /harddisk/proc"))\r | |
1026 | printf("Unable to umount /harddisk/proc.\n");\r | |
1027 | }\r | |
1028 | }\r | |
1029 | \r | |
1030 | fcloseall();\r | |
1031 | \r | |
1032 | system("/bin/swapoff /harddisk/swapfile");\r | |
1033 | system("/sbin/umount /harddisk/var/log");\r | |
1034 | system("/sbin/umount /harddisk/boot");\r | |
1035 | system("/sbin/umount /harddisk");\r | |
1036 | system("/etc/halt");\r | |
1037 | \r | |
1038 | return 0;\r | |
1039 | }\r | |
1040 | \r | |
1041 | int modprobe (char *mod) {\r | |
1042 | char commandstring[STRING_SIZE];\r | |
1043 | sprintf (commandstring,"/sbin/modprobe %s", mod);\r | |
1044 | return mysystem (commandstring); \r | |
1045 | }\r | |
1046 | \r | |
1047 | int rmmod (char *mod) {\r | |
1048 | char commandstring[STRING_SIZE];\r | |
1049 | sprintf (commandstring,"/sbin/rmmod %s", mod);\r | |
1050 | return mysystem (commandstring); \r | |
1051 | }\r |