]> git.ipfire.org Git - ipfire-2.x.git/blame - src/install+setup/install/main.c
installer: Rewrite license box.
[ipfire-2.x.git] / src / install+setup / install / main.c
CommitLineData
2bb7b134 1
d6aaa55d
MT
2/* SmoothWall install program.
3 *
4 * This program is distributed under the terms of the GNU General Public
5 * Licence. See the file COPYING for details.
6 *
7 * (c) Lawrence Manning, 2001
f9cc0d70 8 * Contains main entry point, and misc functions.6
d6aaa55d 9 *
d6aaa55d 10 */
10bc6f06 11
72d80898 12#define _GNU_SOURCE
f0fa1795
MT
13
14#include <assert.h>
15#include <errno.h>
16#include <stdlib.h>
17#include <string.h>
18#include <sys/mount.h>
19
20#include "hw.h"
21#include "install.h"
72d80898 22
68561214 23#define INST_FILECOUNT 21000
33634aa8 24#define UNATTENDED_CONF "/cdrom/boot/unattended.conf"
918546e2 25#define LICENSE_FILE "/cdrom/COPYING"
d6aaa55d 26
d6aaa55d
MT
27FILE *flog = NULL;
28char *mylog;
10bc6f06 29
d6aaa55d
MT
30char **ctr;
31
d6aaa55d
MT
32extern char url[STRING_SIZE];
33
f9cc0d70
HS
34struct nic nics[20] = { { "" , "" , "" } }; // only defined for compile
35struct knic knics[20] = { { "" , "" , "" , "" } }; // only defined for compile
5057b611 36
10bc6f06 37extern char *en_tr[];
cf4dd3c0 38extern char *es_tr[];
10bc6f06 39extern char *de_tr[];
462515e4 40extern char *fr_tr[];
1d76272b 41extern char *nl_tr[];
b6c9668f 42extern char *pl_tr[];
2bb7b134 43extern char *ru_tr[];
910193da 44extern char *tr_tr[];
d6aaa55d 45
d7dd283b
MT
46static int newtChecklist(const char* title, const char* message,
47 unsigned int width, unsigned int height, unsigned int num_entries,
48 const char** entries, int* states) {
49 int ret;
50 const int list_height = 4;
51
52 char cbstates[num_entries];
53
54 for (unsigned int i = 0; i < num_entries; i++) {
55 cbstates[i] = states[i] ? '*' : ' ';
56 }
57
58 newtCenteredWindow(width, height, title);
59
60 newtComponent textbox = newtTextbox(1, 1, width - 2, height - 6 - list_height,
61 NEWT_FLAG_WRAP);
62 newtTextboxSetText(textbox, message);
63
64 int top = newtTextboxGetNumLines(textbox) + 2;
65
66 newtComponent form = newtForm(NULL, NULL, 0);
67
68 newtComponent sb = NULL;
69 if (list_height < num_entries) {
70 sb = newtVerticalScrollbar(
71 width - 4, top + 1, list_height,
72 NEWT_COLORSET_CHECKBOX, NEWT_COLORSET_ACTCHECKBOX);
73
74 newtFormAddComponent(form, sb);
75 }
76
77 newtComponent subform = newtForm(sb, NULL, 0);
78 newtFormSetBackground(subform, NEWT_COLORSET_CHECKBOX);
79
80 newtFormSetHeight(subform, list_height);
81 newtFormSetWidth(subform, width - 10);
82
83 for (unsigned int i = 0; i < num_entries; i++) {
84 newtComponent cb = newtCheckbox(4, top + i, entries[i], cbstates[i],
85 NULL, &cbstates[i]);
86
87 newtFormAddComponent(subform, cb);
88 }
89
90 newtFormAddComponents(form, textbox, subform, NULL);
91
92 newtComponent btn_okay = newtButton((width - 18) / 3, height - 4, ctr[TR_OK]);
93 newtComponent btn_cancel = newtButton((width - 18) / 3 * 2 + 9, height - 4, ctr[TR_CANCEL]);
94 newtFormAddComponents(form, btn_okay, btn_cancel, NULL);
95
96 newtComponent answer = newtRunForm(form);
97
98 if ((answer == NULL) || (answer == btn_cancel)) {
99 ret = -1;
100 } else {
101 ret = 0;
102
103 for (unsigned int i = 0; i < num_entries; i++) {
104 states[i] = (cbstates[i] != ' ');
105
106 if (states[i])
107 ret++;
108 }
109 }
110
111 newtFormDestroy(form);
112 newtPopWindow();
113
114 return ret;
115}
116
117static int newtWinOkCancel(const char* title, const char* message, int width, int height,
118 const char* btn_txt_ok, const char* btn_txt_cancel) {
119 int ret = 1;
120
121 newtCenteredWindow(width, height, title);
122
123 newtComponent form = newtForm(NULL, NULL, 0);
124
125 newtComponent textbox = newtTextbox(1, 1, width - 2, height - 6, NEWT_FLAG_WRAP);
126 newtTextboxSetText(textbox, message);
127 newtFormAddComponent(form, textbox);
128
129 newtComponent btn_ok = newtButton((width - 16) / 3, height - 4, btn_txt_ok);
130 newtComponent btn_cancel = newtButton((width - 16) / 3 * 2 + 9, height - 4,
131 btn_txt_cancel);
132
133 newtFormAddComponents(form, btn_ok, btn_cancel, NULL);
134
135 newtComponent answer = newtRunForm(form);
136
137 if (answer == btn_ok) {
138 ret = 0;
139 }
140
141 newtFormDestroy(form);
142 newtPopWindow();
143
144 return ret;
145}
146
bd5e7c29
MT
147static int newtLicenseBox(const char* title, const char* text, int width, int height) {
148 int ret = 1;
149
150 newtCenteredWindow(width, height, title);
151
152 newtComponent form = newtForm(NULL, NULL, 0);
153
154 newtComponent textbox = newtTextbox(1, 1, width - 2, height - 7,
155 NEWT_FLAG_WRAP|NEWT_FLAG_SCROLL);
156 newtTextboxSetText(textbox, text);
157 newtFormAddComponent(form, textbox);
158
159 char choice;
160 newtComponent checkbox = newtCheckbox(3, height - 3, ctr[TR_LICENSE_ACCEPT],
161 ' ', " *", &choice);
162
163 newtComponent btn = newtButton(width - 15, height - 4, ctr[TR_OK]);
164
165 newtFormAddComponents(form, checkbox, btn, NULL);
166
167 newtComponent answer = newtRunForm(form);
168 if (answer == btn && choice == '*')
169 ret = 0;
170
171 newtFormDestroy(form);
172 newtPopWindow();
173
174 return ret;
175}
176
f0fa1795
MT
177int main(int argc, char *argv[]) {
178 struct hw* hw = hw_init();
e0bbaf87
AF
179
180 char discl_msg[40000] = "Disclaimer\n";
181
910193da
EY
182 char *langnames[] = { "Deutsch", "English", "Français", "Español", "Nederlands", "Polski", "Русский", "Türkçe", NULL };
183 char *shortlangnames[] = { "de", "en", "fr", "es", "nl", "pl", "ru", "tr", NULL };
184 char **langtrs[] = { de_tr, en_tr, fr_tr, es_tr, nl_tr, pl_tr, ru_tr, tr_tr, NULL };
f0fa1795 185 char* sourcedrive = NULL;
72d80898 186 int rc = 0;
d6aaa55d 187 char commandstring[STRING_SIZE];
d6aaa55d
MT
188 int choice;
189 char shortlangname[10];
d7dd283b 190 char message[STRING_SIZE];
d6aaa55d
MT
191 char title[STRING_SIZE];
192 int allok = 0;
e0bbaf87 193 FILE *handle, *cmdfile, *copying;
d6aaa55d 194 char line[STRING_SIZE];
5057b611 195
72d80898 196 int unattended = 0;
5faa66cf 197 int serialconsole = 0;
72d80898 198 struct keyvalue *unattendedkv = initkeyvalues();
66335974 199 char restore_file[STRING_SIZE] = "";
d6aaa55d
MT
200
201 setlocale (LC_ALL, "");
10bc6f06 202 sethostname( SNAME , 10);
72d80898 203
d6aaa55d
MT
204 /* Log file/terminal stuff. */
205 if (argc >= 2)
206 {
207 if (!(flog = fopen(argv[1], "w+")))
208 return 0;
209 }
210 else
211 return 0;
212
213 mylog = argv[1];
214
215 fprintf(flog, "Install program started.\n");
216
217 newtInit();
218 newtCls();
219
7ea444c8
AF
220 newtDrawRootText(14, 0, NAME " " VERSION " - " SLOGAN );
221 sprintf (title, "%s %s - %s", NAME, VERSION, SLOGAN);
222
d6aaa55d
MT
223 if (! (cmdfile = fopen("/proc/cmdline", "r")))
224 {
225 fprintf(flog, "Couldn't open commandline: /proc/cmdline\n");
226 } else {
227 fgets(line, STRING_SIZE, cmdfile);
61e3d218 228
72d80898 229 // check if we have to make an unattended install
ee78a5ef 230 if (strstr (line, "unattended") != NULL) {
72d80898 231 unattended = 1;
bba7212c
MT
232 runcommandwithstatus("/bin/sleep 10", "WARNING: Unattended installation will start in 10 seconds...");
233 }
5faa66cf
AF
234 // check if we have to patch for serial console
235 if (strstr (line, "console=ttyS0") != NULL) {
236 serialconsole = 1;
237 }
d6aaa55d 238 }
0db33b56 239
7ea444c8 240 // Load common modules
bba7212c 241 mysystem("/sbin/modprobe vfat"); // USB key
d6aaa55d 242
72d80898 243 /* German is the default */
d6aaa55d
MT
244 for (choice = 0; langnames[choice]; choice++)
245 {
215bd18d 246 if (strcmp(langnames[choice], "English") == 0)
d6aaa55d
MT
247 break;
248 }
249 if (!langnames[choice])
250 goto EXIT;
251
72d80898 252 if (!unattended) {
51f3b7f5 253 rc = newtWinMenu("Language selection", "Select the language you wish to use for the " NAME ".", 50, 5, 5, 8,
72d80898
MT
254 langnames, &choice, "Ok", NULL);
255 }
256
d6aaa55d
MT
257 ctr = langtrs[choice];
258 strcpy(shortlangname, shortlangnames[choice]);
3d6e1202 259
d6aaa55d 260 newtPushHelpLine(ctr[TR_HELPLINE]);
0db33b56 261
e0bbaf87 262 if (!unattended) {
c5685c24
MT
263 sprintf(message, ctr[TR_WELCOME], NAME);
264 newtWinMessage(title, ctr[TR_OK], message);
e0bbaf87
AF
265 }
266
f0fa1795
MT
267 /* Search for a source drive that holds the right
268 * version of the image we are going to install. */
269 sourcedrive = hw_find_source_medium(hw);
9607771a 270
f0fa1795
MT
271 fprintf(flog, "Source drive: %s\n", sourcedrive);
272 if (!sourcedrive) {
0f680bcc 273 newtWinMessage(title, ctr[TR_OK], ctr[TR_NO_LOCAL_SOURCE]);
f0fa1795 274 runcommandwithstatus("/bin/downloadsource.sh", ctr[TR_DOWNLOADING_ISO]);
0f680bcc
AF
275 if ((handle = fopen("/tmp/source_device", "r")) == NULL) {
276 errorbox(ctr[TR_DOWNLOAD_ERROR]);
277 goto EXIT;
278 }
f0fa1795
MT
279
280 fgets(sourcedrive, 5, handle);
281 fclose(handle);
72d80898 282 }
0f680bcc 283
f0fa1795
MT
284 assert(sourcedrive);
285
25fcce25 286 int r = hw_mount(sourcedrive, SOURCE_MOUNT_PATH, "iso9660", MS_RDONLY);
f0fa1795
MT
287 if (r) {
288 fprintf(flog, "Could not mount %s to %s\n", sourcedrive, SOURCE_MOUNT_PATH);
289 fprintf(flog, strerror(errno));
290 exit(1);
291 }
918546e2 292
d7dd283b
MT
293 /* load unattended configuration */
294 if (unattended) {
295 fprintf(flog, "unattended: Reading unattended.conf\n");
296
297 (void) readkeyvalues(unattendedkv, UNATTENDED_CONF);
298 findkey(unattendedkv, "RESTORE_FILE", restore_file);
299 }
300
918546e2
MT
301 if (!unattended) {
302 // Read the license file.
303 if (!(copying = fopen(LICENSE_FILE, "r"))) {
304 sprintf(discl_msg, "Could not open license file: %s\n", LICENSE_FILE);
305 fprintf(flog, discl_msg);
306 } else {
307 fread(discl_msg, 1, 40000, copying);
308 fclose(copying);
309
bd5e7c29 310 if (newtLicenseBox(title, discl_msg, 75, 20)) {
918546e2 311 errorbox(ctr[TR_LICENSE_NOT_ACCEPTED]);
bd5e7c29 312
918546e2
MT
313 goto EXIT;
314 }
315 }
316 }
317
d7dd283b 318 int part_type = HW_PART_TYPE_NORMAL;
ee78a5ef 319
d7dd283b
MT
320 // Scan for disks to install on.
321 struct hw_disk** disks = hw_find_disks(hw);
322
323 struct hw_disk** selected_disks = NULL;
324 unsigned int num_selected_disks = 0;
325
326 // Check how many disks have been found and what
327 // we can do with them.
328 unsigned int num_disks = hw_count_disks(disks);
329
330 while (1) {
331 // no harddisks found
332 if (num_disks == 0) {
333 errorbox(ctr[TR_NO_HARDDISK]);
334 goto EXIT;
335
336 // exactly one disk has been found
337 } else if (num_disks == 1) {
338 selected_disks = hw_select_disks(disks, NULL);
339
340 // more than one usable disk has been found and
341 // the user needs to choose what to do with them
342 } else {
343 const char* disk_names[num_disks];
344 int disk_selection[num_disks];
345
346 for (unsigned int i = 0; i < num_disks; i++) {
347 disk_names[i] = &disks[i]->description;
348 disk_selection[i] = 0;
349 }
350
351 while (!selected_disks) {
352 rc = newtChecklist(ctr[TR_DISK_SELECTION], ctr[TR_DISK_SELECTION_MSG],
353 50, 20, num_disks, disk_names, disk_selection);
354
355 // Error
356 if (rc < 0) {
357 goto EXIT;
358
359 // Nothing has been selected
360 } else if (rc == 0) {
361 errorbox(ctr[TR_NO_DISK_SELECTED]);
362
363 } else {
364 selected_disks = hw_select_disks(disks, disk_selection);
365 }
366 }
367 }
368
369 num_selected_disks = hw_count_disks(selected_disks);
370
371 if (num_selected_disks == 1) {
372 snprintf(message, sizeof(message), ctr[TR_DISK_SETUP_DESC], (*selected_disks)->description);
373 rc = newtWinOkCancel(ctr[TR_DISK_SETUP], message, 50, 10,
374 ctr[TR_DELETE_ALL_DATA], ctr[TR_CANCEL]);
375
376 if (rc == 0)
56b548f1 377 break;
d7dd283b
MT
378
379 } else if (num_selected_disks == 2) {
380 snprintf(message, sizeof(message), ctr[TR_RAID_SETUP_DESC],
381 (*selected_disks)->description, (*selected_disks + 1)->description);
382 rc = newtWinOkCancel(ctr[TR_RAID_SETUP], message, 50, 10,
383 ctr[TR_DELETE_ALL_DATA], ctr[TR_CANCEL]);
384
385 if (rc == 0) {
386 part_type = HW_PART_TYPE_RAID1;
387
ee78a5ef 388 break;
d7dd283b
MT
389 }
390
391 // Currently not supported
392 } else {
393 errorbox(ctr[TR_DISK_CONFIGURATION_NOT_SUPPORTED]);
aee3027d 394 }
ee78a5ef 395
d7dd283b
MT
396 if (selected_disks) {
397 hw_free_disks(selected_disks);
398 selected_disks = NULL;
399 }
212cab4f 400 }
212cab4f 401
d7dd283b 402 hw_free_disks(disks);
72d80898 403
d7dd283b 404 struct hw_destination* destination = hw_make_destination(part_type, selected_disks);
5057b611 405
25fcce25
MT
406 if (!destination) {
407 errorbox(ctr[TR_DISK_TOO_SMALL]);
cd8dd8dd 408 goto EXIT;
25fcce25 409 }
cd8dd8dd 410
25fcce25
MT
411 fprintf(flog, "Destination drive: %s\n", destination->path);
412 fprintf(flog, " boot: %s (%lluMB)\n", destination->part_boot, BYTES2MB(destination->size_boot));
413 fprintf(flog, " swap: %s (%lluMB)\n", destination->part_swap, BYTES2MB(destination->size_swap));
414 fprintf(flog, " root: %s (%lluMB)\n", destination->part_root, BYTES2MB(destination->size_root));
415 fprintf(flog, " data: %s (%lluMB)\n", destination->part_data, BYTES2MB(destination->size_data));
72d80898 416
25fcce25
MT
417 // Warn the user if there is not enough space to create a swap partition
418 if (!unattended && !*destination->part_swap) {
419 rc = newtWinChoice(title, ctr[TR_OK], ctr[TR_CANCEL], ctr[TR_CONTINUE_NO_SWAP]);
4f26ff7f 420
25fcce25
MT
421 if (rc != 1)
422 goto EXIT;
72d80898 423 }
9a3d3d95 424
25fcce25
MT
425 // Filesystem selection
426 if (!unattended) {
427 struct filesystems {
428 int fstype;
429 const char* description;
430 } filesystems[] = {
431 { HW_FS_EXT4, ctr[TR_EXT4FS] },
432 { HW_FS_EXT4_WO_JOURNAL, ctr[TR_EXT4FS_WO_JOURNAL] },
433 { HW_FS_REISERFS, ctr[TR_REISERFS] },
434 { 0, NULL },
435 };
436 unsigned int num_filesystems = sizeof(filesystems) / sizeof(*filesystems);
437
438 char* fs_names[num_filesystems];
439 int fs_choice = 0;
440 for (unsigned int i = 0; i < num_filesystems; i++) {
441 if (HW_FS_DEFAULT == filesystems[i].fstype)
442 fs_choice = i;
443
444 fs_names[i] = filesystems[i].description;
445 }
72d80898 446
25fcce25
MT
447 rc = newtWinMenu(ctr[TR_CHOOSE_FILESYSTEM], ctr[TR_CHOOSE_FILESYSTEM],
448 50, 5, 5, 6, fs_names, &fs_choice, ctr[TR_OK], ctr[TR_CANCEL], NULL);
449
450 if (rc == 0)
451 destination->filesystem = filesystems[fs_choice].fstype;
72d80898 452
25fcce25 453 else
72d80898 454 goto EXIT;
72d80898
MT
455 }
456
25fcce25
MT
457 // Execute the partitioning...
458 statuswindow(60, 4, title, ctr[TR_PARTITIONING_DISK]);
72d80898 459
25fcce25
MT
460 rc = hw_create_partitions(destination);
461 if (rc) {
462 errorbox(ctr[TR_UNABLE_TO_PARTITION]);
72d80898 463 goto EXIT;
9607771a 464 }
72d80898 465
25fcce25 466 newtPopWindow();
72d80898 467
25fcce25
MT
468 // Execute the formatting...
469 statuswindow(60, 4, title, ctr[TR_CREATING_FILESYSTEMS]);
b8e2d108 470
25fcce25
MT
471 rc = hw_create_filesystems(destination);
472 if (rc) {
473 errorbox(ctr[TR_UNABLE_TO_CREATE_FILESYSTEMS]);
72d80898
MT
474 goto EXIT;
475 }
25fcce25
MT
476
477 rc = hw_mount_filesystems(destination, DESTINATION_MOUNT_PATH);
478 if (rc) {
479 errorbox(ctr[TR_UNABLE_TO_MOUNT_FILESYSTEMS]);
72d80898 480 goto EXIT;
9607771a 481 }
c78a77eb 482
25fcce25
MT
483 newtPopWindow();
484
485 // Extract files...
03d956be 486 snprintf(commandstring, STRING_SIZE,
23ed79cb 487 "/bin/tar -C /harddisk -xvf /cdrom/" SNAME "-" VERSION ".tlz --lzma 2>/dev/null");
d6aaa55d 488
edd536b6
MT
489 if (runcommandwithprogress(60, 4, title, commandstring, INST_FILECOUNT,
490 ctr[TR_INSTALLING_FILES]))
d6aaa55d
MT
491 {
492 errorbox(ctr[TR_UNABLE_TO_INSTALL_FILES]);
493 goto EXIT;
494 }
406f019f
MT
495
496 /* Save language und local settings */
497 write_lang_configs(shortlangname);
d6aaa55d 498
330345c2 499 /* Build cache lang file */
6cf9e770 500 snprintf(commandstring, STRING_SIZE, "/usr/sbin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT "/lang.pl'; &Lang::BuildCacheLang\"");
330345c2
MT
501 if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_LANG_CACHE]))
502 {
503 errorbox(ctr[TR_UNABLE_TO_INSTALL_LANG_CACHE]);
504 goto EXIT;
505 }
506
507 /* Update /etc/fstab */
d7dd283b 508 snprintf(commandstring, STRING_SIZE, "/bin/sed -i -e \"s#DEVICE1#UUID=$(/sbin/blkid %s -sUUID | /usr/bin/cut -d'\"' -f2)#g\" /harddisk/etc/fstab", destination->part_boot);
a9a26c5a 509 system(commandstring);
d7dd283b 510 snprintf(commandstring, STRING_SIZE, "/bin/sed -i -e \"s#DEVICE2#UUID=$(/sbin/blkid %s -sUUID | /usr/bin/cut -d'\"' -f2)#g\" /harddisk/etc/fstab", destination->part_swap);
a9a26c5a 511 system(commandstring);
d7dd283b 512 snprintf(commandstring, STRING_SIZE, "/bin/sed -i -e \"s#DEVICE3#UUID=$(/sbin/blkid %s -sUUID | /usr/bin/cut -d'\"' -f2)#g\" /harddisk/etc/fstab", destination->part_root);
a9a26c5a 513 system(commandstring);
d7dd283b 514 snprintf(commandstring, STRING_SIZE, "/bin/sed -i -e \"s#DEVICE4#UUID=$(/sbin/blkid %s -sUUID | /usr/bin/cut -d'\"' -f2)#g\" /harddisk/etc/fstab", destination->part_data);
a9a26c5a
AF
515 system(commandstring);
516
25fcce25
MT
517 switch (destination->filesystem) {
518 case HW_FS_REISERFS:
519 replace("/harddisk/etc/fstab", "FSTYPE", "reiserfs");
520 replace("/harddisk/boot/grub/grub.conf", "MOUNT", "ro");
521 break;
522
523 case HW_FS_EXT4:
524 case HW_FS_EXT4_WO_JOURNAL:
525 replace("/harddisk/etc/fstab", "FSTYPE", "ext4");
526 replace("/harddisk/boot/grub/grub.conf", "MOUNT", "ro");
527 break;
528
529 default:
530 assert(0);
cd8dd8dd 531 }
73d9a908 532
a869b064
AF
533 replace("/harddisk/boot/grub/grub.conf", "KVER", KERNEL_VERSION);
534
d7dd283b 535 snprintf(commandstring, STRING_SIZE, "/bin/sed -i -e \"s#root=ROOT#root=UUID=$(/sbin/blkid %s -sUUID | /usr/bin/cut -d'\"' -f2)#g\" /harddisk/boot/grub/grub.conf", destination->part_root);
a9a26c5a
AF
536 system(commandstring);
537
f4e27420 538 mysystem("ln -s grub.conf /harddisk/boot/grub/menu.lst");
fd0763dc 539
a9a26c5a 540 system("/bin/sed -e 's#/harddisk#/#g' -e 's#//#/#g' < /proc/mounts > /harddisk/etc/mtab");
edd536b6 541
423400cf
MT
542 /*
543 * Generate device.map to help grub finding the device to install itself on.
544 */
545 FILE *f = NULL;
546 if (f = fopen("/harddisk/boot/grub/device.map", "w")) {
d7dd283b 547 fprintf(f, "(hd0) %s\n", destination->path);
423400cf
MT
548 fclose(f);
549 }
550
edd536b6 551 snprintf(commandstring, STRING_SIZE,
d7dd283b 552 "/usr/sbin/chroot /harddisk /usr/sbin/grub-install --no-floppy %s", destination->path);
edd536b6
MT
553 if (runcommandwithstatus(commandstring, ctr[TR_INSTALLING_GRUB])) {
554 errorbox(ctr[TR_UNABLE_TO_INSTALL_GRUB]);
555 goto EXIT;
556 }
5faa66cf
AF
557
558 /* Serial console ? */
559 if (serialconsole) {
560 /* grub */
561 replace("/harddisk/boot/grub/grub.conf", "splashimage", "#splashimage");
562 replace("/harddisk/boot/grub/grub.conf", "#serial", "serial");
563 replace("/harddisk/boot/grub/grub.conf", "#terminal", "terminal");
1445c9e0 564 replace("/harddisk/boot/grub/grub.conf", " panic=10 ", " console=ttyS0,115200n8 panic=10 ");
5faa66cf
AF
565
566 /*inittab*/
567 replace("/harddisk/etc/inittab", "1:2345:respawn:", "#1:2345:respawn:");
568 replace("/harddisk/etc/inittab", "2:2345:respawn:", "#2:2345:respawn:");
569 replace("/harddisk/etc/inittab", "3:2345:respawn:", "#3:2345:respawn:");
570 replace("/harddisk/etc/inittab", "4:2345:respawn:", "#4:2345:respawn:");
571 replace("/harddisk/etc/inittab", "5:2345:respawn:", "#5:2345:respawn:");
572 replace("/harddisk/etc/inittab", "6:2345:respawn:", "#6:2345:respawn:");
573 replace("/harddisk/etc/inittab", "#7:2345:respawn:", "7:2345:respawn:");
574 }
575
dfa59dbd
AF
576 /* Set marker that the user has already accepted the gpl */
577 mysystem("/usr/bin/touch /harddisk/var/ipfire/main/gpl_accepted");
578
c25a0343 579 /* Copy restore file from cdrom */
7062cecd 580 if (unattended && (strlen(restore_file) > 0)) {
c25a0343 581 fprintf(flog, "unattended: Copy restore file\n");
dca095e1 582 snprintf(commandstring, STRING_SIZE,
c25a0343 583 "cp /cdrom/%s /harddisk/var/ipfire/backup", restore_file);
dca095e1 584 mysystem(commandstring);
c25a0343 585 }
2c9c458c
MT
586
587 // Umount source drive and eject
588 hw_umount(SOURCE_MOUNT_PATH);
589
590 snprintf(commandstring, STRING_SIZE, "/usr/bin/eject %s", sourcedrive);
3ef6c343 591 mysystem(commandstring);
22b9e405 592
73d9a908
MT
593 if (!unattended) {
594 sprintf(message, ctr[TR_CONGRATULATIONS_LONG],
3ad8835c 595 NAME, SNAME, NAME);
fac85ccd 596 newtWinMessage(ctr[TR_CONGRATULATIONS], ctr[TR_PRESS_OK_TO_REBOOT], message);
73d9a908 597 }
cd8dd8dd 598
22b9e405 599 allok = 1;
edd536b6 600
d6aaa55d 601EXIT:
10bc6f06 602 fprintf(flog, "Install program ended.\n");
d6aaa55d 603
10bc6f06 604 if (!(allok))
d6aaa55d 605 newtWinMessage(title, ctr[TR_OK], ctr[TR_PRESS_OK_TO_REBOOT]);
d6aaa55d 606
25fcce25 607 if (allok) {
ee78a5ef
MT
608 fflush(flog);
609 fclose(flog);
3a1019f6
MT
610 }
611
612 newtFinished();
613
f0fa1795
MT
614 // Free resources
615 free(sourcedrive);
25fcce25
MT
616
617 if (destination) {
618 hw_umount_filesystems(destination, DESTINATION_MOUNT_PATH);
619 free(destination);
620 }
d7dd283b
MT
621
622 if (selected_disks)
623 hw_free_disks(selected_disks);
624
625 hw_free(hw);
f0fa1795 626
25fcce25
MT
627 fcloseall();
628
629 if (!(allok))
630 system("/etc/halt");
631
d6aaa55d
MT
632 return 0;
633}