2 /* SmoothWall install program.
4 * This program is distributed under the terms of the GNU General Public
5 * Licence. See the file COPYING for details.
7 * (c) Lawrence Manning, 2001
8 * Contains main entry point, and misc functions.6
18 #include <sys/mount.h>
23 #define INST_FILECOUNT 21000
24 #define UNATTENDED_CONF "/cdrom/boot/unattended.conf"
25 #define LICENSE_FILE "/cdrom/COPYING"
37 extern char url
[STRING_SIZE
];
39 struct nic nics
[20] = { { "" , "" , "" } }; // only defined for compile
40 struct knic knics
[20] = { { "" , "" , "" , "" } }; // only defined for compile
51 static int newtChecklist(const char* title
, const char* message
,
52 unsigned int width
, unsigned int height
, unsigned int num_entries
,
53 const char** entries
, int* states
) {
55 const int list_height
= 4;
57 char cbstates
[num_entries
];
59 for (unsigned int i
= 0; i
< num_entries
; i
++) {
60 cbstates
[i
] = states
[i
] ? '*' : ' ';
63 newtCenteredWindow(width
, height
, title
);
65 newtComponent textbox
= newtTextbox(1, 1, width
- 2, height
- 6 - list_height
,
67 newtTextboxSetText(textbox
, message
);
69 int top
= newtTextboxGetNumLines(textbox
) + 2;
71 newtComponent form
= newtForm(NULL
, NULL
, 0);
73 newtComponent sb
= NULL
;
74 if (list_height
< num_entries
) {
75 sb
= newtVerticalScrollbar(
76 width
- 4, top
+ 1, list_height
,
77 NEWT_COLORSET_CHECKBOX
, NEWT_COLORSET_ACTCHECKBOX
);
79 newtFormAddComponent(form
, sb
);
82 newtComponent subform
= newtForm(sb
, NULL
, 0);
83 newtFormSetBackground(subform
, NEWT_COLORSET_CHECKBOX
);
85 newtFormSetHeight(subform
, list_height
);
86 newtFormSetWidth(subform
, width
- 10);
88 for (unsigned int i
= 0; i
< num_entries
; i
++) {
89 newtComponent cb
= newtCheckbox(4, top
+ i
, entries
[i
], cbstates
[i
],
92 newtFormAddComponent(subform
, cb
);
95 newtFormAddComponents(form
, textbox
, subform
, NULL
);
97 newtComponent btn_okay
= newtButton((width
- 18) / 3, height
- 4, ctr
[TR_OK
]);
98 newtComponent btn_cancel
= newtButton((width
- 18) / 3 * 2 + 9, height
- 4, ctr
[TR_CANCEL
]);
99 newtFormAddComponents(form
, btn_okay
, btn_cancel
, NULL
);
101 newtComponent answer
= newtRunForm(form
);
103 if ((answer
== NULL
) || (answer
== btn_cancel
)) {
108 for (unsigned int i
= 0; i
< num_entries
; i
++) {
109 states
[i
] = (cbstates
[i
] != ' ');
116 newtFormDestroy(form
);
122 static int newtWinOkCancel(const char* title
, const char* message
, int width
, int height
,
123 const char* btn_txt_ok
, const char* btn_txt_cancel
) {
126 newtCenteredWindow(width
, height
, title
);
128 newtComponent form
= newtForm(NULL
, NULL
, 0);
130 newtComponent textbox
= newtTextbox(1, 1, width
- 2, height
- 6, NEWT_FLAG_WRAP
);
131 newtTextboxSetText(textbox
, message
);
132 newtFormAddComponent(form
, textbox
);
134 newtComponent btn_ok
= newtButton((width
- 16) / 3, height
- 4, btn_txt_ok
);
135 newtComponent btn_cancel
= newtButton((width
- 16) / 3 * 2 + 9, height
- 4,
138 newtFormAddComponents(form
, btn_ok
, btn_cancel
, NULL
);
140 newtComponent answer
= newtRunForm(form
);
142 if (answer
== btn_ok
) {
146 newtFormDestroy(form
);
152 int main(int argc
, char *argv
[]) {
153 struct hw
* hw
= hw_init();
155 char discl_msg
[40000] = "Disclaimer\n";
157 char *langnames
[] = { "Deutsch", "English", "Français", "Español", "Nederlands", "Polski", "Русский", "Türkçe", NULL
};
158 char *shortlangnames
[] = { "de", "en", "fr", "es", "nl", "pl", "ru", "tr", NULL
};
159 char **langtrs
[] = { de_tr
, en_tr
, fr_tr
, es_tr
, nl_tr
, pl_tr
, ru_tr
, tr_tr
, NULL
};
160 char* sourcedrive
= NULL
;
162 char commandstring
[STRING_SIZE
];
163 char mkfscommand
[STRING_SIZE
];
164 char *fstypes
[] = { "ext2", "ext3", "ext4", "ReiserFS", NULL
};
167 char shortlangname
[10];
168 char message
[STRING_SIZE
];
169 char title
[STRING_SIZE
];
171 int allok_fastexit
=0;
172 struct keyvalue
*ethernetkv
= initkeyvalues();
173 FILE *handle
, *cmdfile
, *copying
;
174 char line
[STRING_SIZE
];
175 char string
[STRING_SIZE
];
176 long memory
= 0, disk
= 0;
177 long system_partition
, boot_partition
, root_partition
, swap_file
;
180 int serialconsole
= 0;
181 struct keyvalue
*unattendedkv
= initkeyvalues();
182 char restore_file
[STRING_SIZE
] = "";
184 setlocale (LC_ALL
, "");
185 sethostname( SNAME
, 10);
187 /* Log file/terminal stuff. */
190 if (!(flog
= fopen(argv
[1], "w+")))
198 fprintf(flog
, "Install program started.\n");
203 newtDrawRootText(14, 0, NAME
" " VERSION
" - " SLOGAN
);
204 sprintf (title
, "%s %s - %s", NAME
, VERSION
, SLOGAN
);
206 if (! (cmdfile
= fopen("/proc/cmdline", "r")))
208 fprintf(flog
, "Couldn't open commandline: /proc/cmdline\n");
210 fgets(line
, STRING_SIZE
, cmdfile
);
212 // check if we have to make an unattended install
213 if (strstr (line
, "unattended") != NULL
) {
215 runcommandwithstatus("/bin/sleep 10", "WARNING: Unattended installation will start in 10 seconds...");
217 // check if we have to patch for serial console
218 if (strstr (line
, "console=ttyS0") != NULL
) {
223 // Load common modules
224 mysystem("/sbin/modprobe vfat"); // USB key
226 /* German is the default */
227 for (choice
= 0; langnames
[choice
]; choice
++)
229 if (strcmp(langnames
[choice
], "English") == 0)
232 if (!langnames
[choice
])
236 rc
= newtWinMenu("Language selection", "Select the language you wish to use for the " NAME
".", 50, 5, 5, 8,
237 langnames
, &choice
, "Ok", NULL
);
240 ctr
= langtrs
[choice
];
241 strcpy(shortlangname
, shortlangnames
[choice
]);
243 newtPushHelpLine(ctr
[TR_HELPLINE
]);
246 sprintf(message
, ctr
[TR_WELCOME
], NAME
);
247 newtWinMessage(title
, ctr
[TR_OK
], message
);
250 /* Search for a source drive that holds the right
251 * version of the image we are going to install. */
252 sourcedrive
= hw_find_source_medium(hw
);
254 fprintf(flog
, "Source drive: %s\n", sourcedrive
);
256 newtWinMessage(title
, ctr
[TR_OK
], ctr
[TR_NO_LOCAL_SOURCE
]);
257 runcommandwithstatus("/bin/downloadsource.sh", ctr
[TR_DOWNLOADING_ISO
]);
258 if ((handle
= fopen("/tmp/source_device", "r")) == NULL
) {
259 errorbox(ctr
[TR_DOWNLOAD_ERROR
]);
263 fgets(sourcedrive
, 5, handle
);
269 int r
= hw_mount(sourcedrive
, SOURCE_MOUNT_PATH
, MS_RDONLY
);
271 fprintf(flog
, "Could not mount %s to %s\n", sourcedrive
, SOURCE_MOUNT_PATH
);
272 fprintf(flog
, strerror(errno
));
276 /* load unattended configuration */
278 fprintf(flog
, "unattended: Reading unattended.conf\n");
280 (void) readkeyvalues(unattendedkv
, UNATTENDED_CONF
);
281 findkey(unattendedkv
, "RESTORE_FILE", restore_file
);
285 // Read the license file.
286 if (!(copying
= fopen(LICENSE_FILE
, "r"))) {
287 sprintf(discl_msg
, "Could not open license file: %s\n", LICENSE_FILE
);
288 fprintf(flog
, discl_msg
);
290 fread(discl_msg
, 1, 40000, copying
);
293 if (disclaimerbox(discl_msg
)==0) {
294 errorbox(ctr
[TR_LICENSE_NOT_ACCEPTED
]);
300 int part_type
= HW_PART_TYPE_NORMAL
;
302 // Scan for disks to install on.
303 struct hw_disk
** disks
= hw_find_disks(hw
);
305 struct hw_disk
** selected_disks
= NULL
;
306 unsigned int num_selected_disks
= 0;
308 // Check how many disks have been found and what
309 // we can do with them.
310 unsigned int num_disks
= hw_count_disks(disks
);
313 // no harddisks found
314 if (num_disks
== 0) {
315 errorbox(ctr
[TR_NO_HARDDISK
]);
318 // exactly one disk has been found
319 } else if (num_disks
== 1) {
320 selected_disks
= hw_select_disks(disks
, NULL
);
322 // more than one usable disk has been found and
323 // the user needs to choose what to do with them
325 const char* disk_names
[num_disks
];
326 int disk_selection
[num_disks
];
328 for (unsigned int i
= 0; i
< num_disks
; i
++) {
329 disk_names
[i
] = &disks
[i
]->description
;
330 disk_selection
[i
] = 0;
333 while (!selected_disks
) {
334 rc
= newtChecklist(ctr
[TR_DISK_SELECTION
], ctr
[TR_DISK_SELECTION_MSG
],
335 50, 20, num_disks
, disk_names
, disk_selection
);
341 // Nothing has been selected
342 } else if (rc
== 0) {
343 errorbox(ctr
[TR_NO_DISK_SELECTED
]);
346 selected_disks
= hw_select_disks(disks
, disk_selection
);
351 num_selected_disks
= hw_count_disks(selected_disks
);
353 if (num_selected_disks
== 1) {
354 snprintf(message
, sizeof(message
), ctr
[TR_DISK_SETUP_DESC
], (*selected_disks
)->description
);
355 rc
= newtWinOkCancel(ctr
[TR_DISK_SETUP
], message
, 50, 10,
356 ctr
[TR_DELETE_ALL_DATA
], ctr
[TR_CANCEL
]);
361 } else if (num_selected_disks
== 2) {
362 snprintf(message
, sizeof(message
), ctr
[TR_RAID_SETUP_DESC
],
363 (*selected_disks
)->description
, (*selected_disks
+ 1)->description
);
364 rc
= newtWinOkCancel(ctr
[TR_RAID_SETUP
], message
, 50, 10,
365 ctr
[TR_DELETE_ALL_DATA
], ctr
[TR_CANCEL
]);
368 part_type
= HW_PART_TYPE_RAID1
;
373 // Currently not supported
375 errorbox(ctr
[TR_DISK_CONFIGURATION_NOT_SUPPORTED
]);
378 if (selected_disks
) {
379 hw_free_disks(selected_disks
);
380 selected_disks
= NULL
;
384 hw_free_disks(disks
);
386 struct hw_destination
* destination
= hw_make_destination(part_type
, selected_disks
);
389 fprintf(flog
, "Destination drive: %s\n", destination
->path
);
390 fprintf(flog
, " boot: %s\n", destination
->part_boot
);
391 fprintf(flog
, " swap: %s\n", destination
->part_swap
);
392 fprintf(flog
, " root: %s\n", destination
->part_root
);
393 fprintf(flog
, " data: %s\n", destination
->part_data
);
395 fstypes
[0]=ctr
[TR_EXT2FS_DESCR
];
396 fstypes
[1]=ctr
[TR_EXT3FS_DESCR
];
397 fstypes
[2]=ctr
[TR_EXT4FS_DESCR
];
398 fstypes
[3]=ctr
[TR_REISERFS_DESCR
];
402 sprintf(message
, ctr
[TR_CHOOSE_FILESYSTEM
]);
403 rc
= newtWinMenu( ctr
[TR_CHOOSE_FILESYSTEM
], message
,
404 50, 5, 5, 6, fstypes
, &fstype
, ctr
[TR_OK
],
405 ctr
[TR_CANCEL
], NULL
);
413 memory
= hw_memory() / 1024 / 1024;
415 /* Partition, mkswp, mkfs.
416 * before partitioning, first determine the sizes of each
417 * partition. In order to do that we need to know the size of
420 disk
= destination
->size
/ 1024 / 1024;
422 fprintf(flog
, "Disksize = %ld, memory = %ld", disk
, memory
);
424 /* Calculating Swap-Size dependend of Ram Size */
427 else if (memory
<= 1024 && memory
> 256)
430 swap_file
= memory
/ 4;
432 /* Calculating Root-Size dependend of Max Disk Space */
434 root_partition
= 1024;
435 else if ( disk
>= 2048 && disk
<= 3072 )
436 root_partition
= 1536;
438 root_partition
= 2048;
441 /* Calculating the amount of free space */
442 boot_partition
= 64; /* in MB */
443 system_partition
= disk
- ( root_partition
+ swap_file
+ boot_partition
);
445 fprintf(flog
, ", boot = %ld, swap = %ld, mylog = %ld, root = %ld\n",
446 boot_partition
, swap_file
, system_partition
, root_partition
);
449 if ( (!unattended
) && (((disk
- (root_partition
+ swap_file
+ boot_partition
)) < 256 ) && ((disk
- (root_partition
+ boot_partition
)) > 256)) ) {
450 rc
= newtWinChoice(title
, ctr
[TR_OK
], ctr
[TR_CANCEL
], ctr
[TR_CONTINUE_NO_SWAP
]);
453 system_partition
= disk
- ( root_partition
+ swap_file
+ boot_partition
);
454 fprintf(flog
, "Changing Swap Size to 0 MB.\n");
457 fprintf(flog
, "Disk is too small.\n");
458 errorbox(ctr
[TR_DISK_TOO_SMALL
]);goto EXIT
;
461 else if (disk
- (root_partition
+ swap_file
+ boot_partition
) >= 256) {
465 fprintf(flog
, "Disk is too small.\n");
466 errorbox(ctr
[TR_DISK_TOO_SMALL
]);goto EXIT
;
469 handle
= fopen("/tmp/partitiontable", "w");
473 fprintf(handle
, ",%ld,L,*\n,%ld,S,\n,%ld,L,\n,,L,\n",
474 boot_partition
, swap_file
, root_partition
);
476 fprintf(handle
, ",%ld,L,*\n,0,0,\n,%ld,L,\n,,L,\n",
477 boot_partition
, root_partition
);
482 if (disk
< 2097150) {
483 // <2TB use sfdisk and normal mbr
484 snprintf(commandstring
, STRING_SIZE
, "/sbin/sfdisk -L -uM %s < /tmp/partitiontable", destination
->path
);
486 // >2TB use parted with gpt
487 snprintf(commandstring
, STRING_SIZE
, "/usr/sbin/parted -s %s mklabel gpt mkpart boot ext2 1M 64M mkpart swap linux-swap 64M 1000M mkpart root ext4 1000M 5000M mkpart var ext4 5000M 100%% disk_set pmbr_boot on", destination
->path
);
490 if (runcommandwithstatus(commandstring
, ctr
[TR_PARTITIONING_DISK
]))
492 errorbox(ctr
[TR_UNABLE_TO_PARTITION
]);
496 if (fstype
== EXT2
) {
497 // mysystem("/sbin/modprobe ext2");
498 sprintf(mkfscommand
, "/sbin/mke2fs -T ext2");
499 } else if (fstype
== REISERFS
) {
500 mysystem("/sbin/modprobe reiserfs");
501 sprintf(mkfscommand
, "/sbin/mkreiserfs -f");
502 } else if (fstype
== EXT3
) {
503 // mysystem("/sbin/modprobe ext3");
504 sprintf(mkfscommand
, "/sbin/mke2fs -T ext3");
505 } else if (fstype
== EXT4
) {
506 // mysystem("/sbin/modprobe ext4");
507 sprintf(mkfscommand
, "/sbin/mke2fs -T ext4");
510 snprintf(commandstring
, STRING_SIZE
, "/sbin/mke2fs -T ext2 -I 128 %s", destination
->part_boot
);
511 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_BOOT_FILESYSTEM
]))
513 errorbox(ctr
[TR_UNABLE_TO_MAKE_BOOT_FILESYSTEM
]);
518 snprintf(commandstring
, STRING_SIZE
, "/sbin/mkswap %s", destination
->part_swap
);
519 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_SWAPSPACE
]))
521 errorbox(ctr
[TR_UNABLE_TO_MAKE_SWAPSPACE
]);
526 snprintf(commandstring
, STRING_SIZE
, "%s %s", mkfscommand
, destination
->part_root
);
527 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_ROOT_FILESYSTEM
]))
529 errorbox(ctr
[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM
]);
533 snprintf(commandstring
, STRING_SIZE
, "%s %s", mkfscommand
, destination
->part_data
);
534 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_LOG_FILESYSTEM
]))
536 errorbox(ctr
[TR_UNABLE_TO_MAKE_LOG_FILESYSTEM
]);
540 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %s /harddisk", destination
->part_root
);
541 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_ROOT_FILESYSTEM
]))
543 errorbox(ctr
[TR_UNABLE_TO_MOUNT_ROOT_FILESYSTEM
]);
547 mkdir("/harddisk/boot", S_IRWXU
|S_IRWXG
|S_IRWXO
);
548 mkdir("/harddisk/var", S_IRWXU
|S_IRWXG
|S_IRWXO
);
549 mkdir("/harddisk/var/log", S_IRWXU
|S_IRWXG
|S_IRWXO
);
551 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %s /harddisk/boot", destination
->part_boot
);
552 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_BOOT_FILESYSTEM
]))
554 errorbox(ctr
[TR_UNABLE_TO_MOUNT_BOOT_FILESYSTEM
]);
558 snprintf(commandstring
, STRING_SIZE
, "/sbin/swapon %s", destination
->part_swap
);
559 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_SWAP_PARTITION
]))
561 errorbox(ctr
[TR_UNABLE_TO_MOUNT_SWAP_PARTITION
]);
565 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %s /harddisk/var", destination
->part_data
);
566 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_LOG_FILESYSTEM
]))
568 errorbox(ctr
[TR_UNABLE_TO_MOUNT_LOG_FILESYSTEM
]);
572 snprintf(commandstring
, STRING_SIZE
,
573 "/bin/tar -C /harddisk -xvf /cdrom/" SNAME
"-" VERSION
".tlz --lzma 2>/dev/null");
575 if (runcommandwithprogress(60, 4, title
, commandstring
, INST_FILECOUNT
,
576 ctr
[TR_INSTALLING_FILES
]))
578 errorbox(ctr
[TR_UNABLE_TO_INSTALL_FILES
]);
582 /* Save language und local settings */
583 write_lang_configs(shortlangname
);
585 /* mount proc filesystem */
586 mysystem("mkdir /harddisk/proc");
587 mysystem("/bin/mount --bind /proc /harddisk/proc");
588 mysystem("/bin/mount --bind /dev /harddisk/dev");
589 mysystem("/bin/mount --bind /sys /harddisk/sys");
591 /* Build cache lang file */
592 snprintf(commandstring
, STRING_SIZE
, "/usr/sbin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT
"/lang.pl'; &Lang::BuildCacheLang\"");
593 if (runcommandwithstatus(commandstring
, ctr
[TR_INSTALLING_LANG_CACHE
]))
595 errorbox(ctr
[TR_UNABLE_TO_INSTALL_LANG_CACHE
]);
599 /* Update /etc/fstab */
600 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
);
601 system(commandstring
);
602 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
);
603 system(commandstring
);
604 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
);
605 system(commandstring
);
606 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
);
607 system(commandstring
);
609 if (fstype
== EXT2
) {
610 replace("/harddisk/etc/fstab", "FSTYPE", "ext2");
611 replace("/harddisk/boot/grub/grub.conf", "MOUNT", "ro");
612 } else if (fstype
== REISERFS
) {
613 replace("/harddisk/etc/fstab", "FSTYPE", "reiserfs");
614 replace("/harddisk/boot/grub/grub.conf", "MOUNT", "ro");
615 } else if (fstype
== EXT3
) {
616 replace("/harddisk/etc/fstab", "FSTYPE", "ext3");
617 replace("/harddisk/boot/grub/grub.conf", "MOUNT", "ro");
618 } else if (fstype
== EXT4
) {
619 replace("/harddisk/etc/fstab", "FSTYPE", "ext4");
620 replace("/harddisk/boot/grub/grub.conf", "MOUNT", "ro");
623 replace("/harddisk/boot/grub/grub.conf", "KVER", KERNEL_VERSION
);
625 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
);
626 system(commandstring
);
628 mysystem("ln -s grub.conf /harddisk/boot/grub/menu.lst");
630 system("/bin/sed -e 's#/harddisk#/#g' -e 's#//#/#g' < /proc/mounts > /harddisk/etc/mtab");
633 * Generate device.map to help grub finding the device to install itself on.
636 if (f
= fopen("/harddisk/boot/grub/device.map", "w")) {
637 fprintf(f
, "(hd0) %s\n", destination
->path
);
641 snprintf(commandstring
, STRING_SIZE
,
642 "/usr/sbin/chroot /harddisk /usr/sbin/grub-install --no-floppy %s", destination
->path
);
643 if (runcommandwithstatus(commandstring
, ctr
[TR_INSTALLING_GRUB
])) {
644 errorbox(ctr
[TR_UNABLE_TO_INSTALL_GRUB
]);
648 /* Serial console ? */
651 replace("/harddisk/boot/grub/grub.conf", "splashimage", "#splashimage");
652 replace("/harddisk/boot/grub/grub.conf", "#serial", "serial");
653 replace("/harddisk/boot/grub/grub.conf", "#terminal", "terminal");
654 replace("/harddisk/boot/grub/grub.conf", " panic=10 ", " console=ttyS0,115200n8 panic=10 ");
657 replace("/harddisk/etc/inittab", "1:2345:respawn:", "#1:2345:respawn:");
658 replace("/harddisk/etc/inittab", "2:2345:respawn:", "#2:2345:respawn:");
659 replace("/harddisk/etc/inittab", "3:2345:respawn:", "#3:2345:respawn:");
660 replace("/harddisk/etc/inittab", "4:2345:respawn:", "#4:2345:respawn:");
661 replace("/harddisk/etc/inittab", "5:2345:respawn:", "#5:2345:respawn:");
662 replace("/harddisk/etc/inittab", "6:2345:respawn:", "#6:2345:respawn:");
663 replace("/harddisk/etc/inittab", "#7:2345:respawn:", "7:2345:respawn:");
666 /* Set marker that the user has already accepted the gpl */
667 mysystem("/usr/bin/touch /harddisk/var/ipfire/main/gpl_accepted");
669 /* Copy restore file from cdrom */
670 if (unattended
&& (strlen(restore_file
) > 0)) {
671 fprintf(flog
, "unattended: Copy restore file\n");
672 snprintf(commandstring
, STRING_SIZE
,
673 "cp /cdrom/%s /harddisk/var/ipfire/backup", restore_file
);
674 mysystem(commandstring
);
677 mysystem("umount /cdrom");
678 snprintf(commandstring
, STRING_SIZE
, "/usr/bin/eject /dev/%s", sourcedrive
);
679 mysystem(commandstring
);
682 sprintf(message
, ctr
[TR_CONGRATULATIONS_LONG
],
684 newtWinMessage(ctr
[TR_CONGRATULATIONS
], ctr
[TR_PRESS_OK_TO_REBOOT
], message
);
690 fprintf(flog
, "Install program ended.\n");
693 newtWinMessage(title
, ctr
[TR_OK
], ctr
[TR_PRESS_OK_TO_REBOOT
]);
695 freekeyvalues(ethernetkv
);
697 if (allok
&& !allok_fastexit
)
700 fprintf(flog
, "Entering unattended setup\n");
701 if (unattended_setup(unattendedkv
)) {
702 snprintf(commandstring
, STRING_SIZE
, "/bin/sleep 10");
703 runcommandwithstatus(commandstring
, "Unattended installation finished, system will reboot");
705 errorbox("Unattended setup failed.");
714 if (system("/bin/umount /harddisk/proc"))
715 printf("Unable to umount /harddisk/proc.\n");
725 snprintf(commandstring
, STRING_SIZE
, "/bin/swapoff %s", destination
->part_swap
);
730 system("/bin/umount /harddisk/proc >/dev/null 2>&1");
731 system("/bin/umount /harddisk/dev >/dev/null 2>&1");
732 system("/bin/umount /harddisk/sys >/dev/null 2>&1");
734 system("/bin/umount /harddisk/var >/dev/null 2>&1");
735 system("/bin/umount /harddisk/boot >/dev/null 2>&1");
736 system("/bin/umount /harddisk >/dev/null 2>&1");
746 hw_free_disks(selected_disks
);