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 /* Calculate amount of memory in machine */
414 if ((handle
= fopen("/proc/meminfo", "r")))
416 while (fgets(line
, STRING_SIZE
-1, handle
)) {
417 if (sscanf (line
, "MemTotal: %s kB", string
)) {
418 memory
= atoi(string
) / 1024 ;
424 /* Partition, mkswp, mkfs.
425 * before partitioning, first determine the sizes of each
426 * partition. In order to do that we need to know the size of
429 disk
= destination
->size
/ 1024 / 1024;
431 fprintf(flog
, "Disksize = %ld, memory = %ld", disk
, memory
);
433 /* Calculating Swap-Size dependend of Ram Size */
436 else if (memory
<= 1024 && memory
> 256)
439 swap_file
= memory
/ 4;
441 /* Calculating Root-Size dependend of Max Disk Space */
443 root_partition
= 1024;
444 else if ( disk
>= 2048 && disk
<= 3072 )
445 root_partition
= 1536;
447 root_partition
= 2048;
450 /* Calculating the amount of free space */
451 boot_partition
= 64; /* in MB */
452 system_partition
= disk
- ( root_partition
+ swap_file
+ boot_partition
);
454 fprintf(flog
, ", boot = %ld, swap = %ld, mylog = %ld, root = %ld\n",
455 boot_partition
, swap_file
, system_partition
, root_partition
);
458 if ( (!unattended
) && (((disk
- (root_partition
+ swap_file
+ boot_partition
)) < 256 ) && ((disk
- (root_partition
+ boot_partition
)) > 256)) ) {
459 rc
= newtWinChoice(title
, ctr
[TR_OK
], ctr
[TR_CANCEL
], ctr
[TR_CONTINUE_NO_SWAP
]);
462 system_partition
= disk
- ( root_partition
+ swap_file
+ boot_partition
);
463 fprintf(flog
, "Changing Swap Size to 0 MB.\n");
466 fprintf(flog
, "Disk is too small.\n");
467 errorbox(ctr
[TR_DISK_TOO_SMALL
]);goto EXIT
;
470 else if (disk
- (root_partition
+ swap_file
+ boot_partition
) >= 256) {
474 fprintf(flog
, "Disk is too small.\n");
475 errorbox(ctr
[TR_DISK_TOO_SMALL
]);goto EXIT
;
478 handle
= fopen("/tmp/partitiontable", "w");
482 fprintf(handle
, ",%ld,L,*\n,%ld,S,\n,%ld,L,\n,,L,\n",
483 boot_partition
, swap_file
, root_partition
);
485 fprintf(handle
, ",%ld,L,*\n,0,0,\n,%ld,L,\n,,L,\n",
486 boot_partition
, root_partition
);
491 if (disk
< 2097150) {
492 // <2TB use sfdisk and normal mbr
493 snprintf(commandstring
, STRING_SIZE
, "/sbin/sfdisk -L -uM %s < /tmp/partitiontable", destination
->path
);
495 // >2TB use parted with gpt
496 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
);
499 if (runcommandwithstatus(commandstring
, ctr
[TR_PARTITIONING_DISK
]))
501 errorbox(ctr
[TR_UNABLE_TO_PARTITION
]);
505 if (fstype
== EXT2
) {
506 // mysystem("/sbin/modprobe ext2");
507 sprintf(mkfscommand
, "/sbin/mke2fs -T ext2");
508 } else if (fstype
== REISERFS
) {
509 mysystem("/sbin/modprobe reiserfs");
510 sprintf(mkfscommand
, "/sbin/mkreiserfs -f");
511 } else if (fstype
== EXT3
) {
512 // mysystem("/sbin/modprobe ext3");
513 sprintf(mkfscommand
, "/sbin/mke2fs -T ext3");
514 } else if (fstype
== EXT4
) {
515 // mysystem("/sbin/modprobe ext4");
516 sprintf(mkfscommand
, "/sbin/mke2fs -T ext4");
519 snprintf(commandstring
, STRING_SIZE
, "/sbin/mke2fs -T ext2 -I 128 %s", destination
->part_boot
);
520 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_BOOT_FILESYSTEM
]))
522 errorbox(ctr
[TR_UNABLE_TO_MAKE_BOOT_FILESYSTEM
]);
527 snprintf(commandstring
, STRING_SIZE
, "/sbin/mkswap %s", destination
->part_swap
);
528 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_SWAPSPACE
]))
530 errorbox(ctr
[TR_UNABLE_TO_MAKE_SWAPSPACE
]);
535 snprintf(commandstring
, STRING_SIZE
, "%s %s", mkfscommand
, destination
->part_root
);
536 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_ROOT_FILESYSTEM
]))
538 errorbox(ctr
[TR_UNABLE_TO_MAKE_ROOT_FILESYSTEM
]);
542 snprintf(commandstring
, STRING_SIZE
, "%s %s", mkfscommand
, destination
->part_data
);
543 if (runcommandwithstatus(commandstring
, ctr
[TR_MAKING_LOG_FILESYSTEM
]))
545 errorbox(ctr
[TR_UNABLE_TO_MAKE_LOG_FILESYSTEM
]);
549 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %s /harddisk", destination
->part_root
);
550 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_ROOT_FILESYSTEM
]))
552 errorbox(ctr
[TR_UNABLE_TO_MOUNT_ROOT_FILESYSTEM
]);
556 mkdir("/harddisk/boot", S_IRWXU
|S_IRWXG
|S_IRWXO
);
557 mkdir("/harddisk/var", S_IRWXU
|S_IRWXG
|S_IRWXO
);
558 mkdir("/harddisk/var/log", S_IRWXU
|S_IRWXG
|S_IRWXO
);
560 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %s /harddisk/boot", destination
->part_boot
);
561 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_BOOT_FILESYSTEM
]))
563 errorbox(ctr
[TR_UNABLE_TO_MOUNT_BOOT_FILESYSTEM
]);
567 snprintf(commandstring
, STRING_SIZE
, "/sbin/swapon %s", destination
->part_swap
);
568 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_SWAP_PARTITION
]))
570 errorbox(ctr
[TR_UNABLE_TO_MOUNT_SWAP_PARTITION
]);
574 snprintf(commandstring
, STRING_SIZE
, "/bin/mount %s /harddisk/var", destination
->part_data
);
575 if (runcommandwithstatus(commandstring
, ctr
[TR_MOUNTING_LOG_FILESYSTEM
]))
577 errorbox(ctr
[TR_UNABLE_TO_MOUNT_LOG_FILESYSTEM
]);
581 snprintf(commandstring
, STRING_SIZE
,
582 "/bin/tar -C /harddisk -xvf /cdrom/" SNAME
"-" VERSION
".tlz --lzma 2>/dev/null");
584 if (runcommandwithprogress(60, 4, title
, commandstring
, INST_FILECOUNT
,
585 ctr
[TR_INSTALLING_FILES
]))
587 errorbox(ctr
[TR_UNABLE_TO_INSTALL_FILES
]);
591 /* Save language und local settings */
592 write_lang_configs(shortlangname
);
594 /* mount proc filesystem */
595 mysystem("mkdir /harddisk/proc");
596 mysystem("/bin/mount --bind /proc /harddisk/proc");
597 mysystem("/bin/mount --bind /dev /harddisk/dev");
598 mysystem("/bin/mount --bind /sys /harddisk/sys");
600 /* Build cache lang file */
601 snprintf(commandstring
, STRING_SIZE
, "/usr/sbin/chroot /harddisk /usr/bin/perl -e \"require '" CONFIG_ROOT
"/lang.pl'; &Lang::BuildCacheLang\"");
602 if (runcommandwithstatus(commandstring
, ctr
[TR_INSTALLING_LANG_CACHE
]))
604 errorbox(ctr
[TR_UNABLE_TO_INSTALL_LANG_CACHE
]);
608 /* Update /etc/fstab */
609 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
);
610 system(commandstring
);
611 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
);
612 system(commandstring
);
613 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
);
614 system(commandstring
);
615 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
);
616 system(commandstring
);
618 if (fstype
== EXT2
) {
619 replace("/harddisk/etc/fstab", "FSTYPE", "ext2");
620 replace("/harddisk/boot/grub/grub.conf", "MOUNT", "ro");
621 } else if (fstype
== REISERFS
) {
622 replace("/harddisk/etc/fstab", "FSTYPE", "reiserfs");
623 replace("/harddisk/boot/grub/grub.conf", "MOUNT", "ro");
624 } else if (fstype
== EXT3
) {
625 replace("/harddisk/etc/fstab", "FSTYPE", "ext3");
626 replace("/harddisk/boot/grub/grub.conf", "MOUNT", "ro");
627 } else if (fstype
== EXT4
) {
628 replace("/harddisk/etc/fstab", "FSTYPE", "ext4");
629 replace("/harddisk/boot/grub/grub.conf", "MOUNT", "ro");
632 replace("/harddisk/boot/grub/grub.conf", "KVER", KERNEL_VERSION
);
634 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
);
635 system(commandstring
);
637 mysystem("ln -s grub.conf /harddisk/boot/grub/menu.lst");
639 system("/bin/sed -e 's#/harddisk#/#g' -e 's#//#/#g' < /proc/mounts > /harddisk/etc/mtab");
642 * Generate device.map to help grub finding the device to install itself on.
645 if (f
= fopen("/harddisk/boot/grub/device.map", "w")) {
646 fprintf(f
, "(hd0) %s\n", destination
->path
);
650 snprintf(commandstring
, STRING_SIZE
,
651 "/usr/sbin/chroot /harddisk /usr/sbin/grub-install --no-floppy %s", destination
->path
);
652 if (runcommandwithstatus(commandstring
, ctr
[TR_INSTALLING_GRUB
])) {
653 errorbox(ctr
[TR_UNABLE_TO_INSTALL_GRUB
]);
657 /* Serial console ? */
660 replace("/harddisk/boot/grub/grub.conf", "splashimage", "#splashimage");
661 replace("/harddisk/boot/grub/grub.conf", "#serial", "serial");
662 replace("/harddisk/boot/grub/grub.conf", "#terminal", "terminal");
663 replace("/harddisk/boot/grub/grub.conf", " panic=10 ", " console=ttyS0,115200n8 panic=10 ");
666 replace("/harddisk/etc/inittab", "1:2345:respawn:", "#1:2345:respawn:");
667 replace("/harddisk/etc/inittab", "2:2345:respawn:", "#2:2345:respawn:");
668 replace("/harddisk/etc/inittab", "3:2345:respawn:", "#3:2345:respawn:");
669 replace("/harddisk/etc/inittab", "4:2345:respawn:", "#4:2345:respawn:");
670 replace("/harddisk/etc/inittab", "5:2345:respawn:", "#5:2345:respawn:");
671 replace("/harddisk/etc/inittab", "6:2345:respawn:", "#6:2345:respawn:");
672 replace("/harddisk/etc/inittab", "#7:2345:respawn:", "7:2345:respawn:");
675 /* Set marker that the user has already accepted the gpl */
676 mysystem("/usr/bin/touch /harddisk/var/ipfire/main/gpl_accepted");
678 /* Copy restore file from cdrom */
679 if (unattended
&& (strlen(restore_file
) > 0)) {
680 fprintf(flog
, "unattended: Copy restore file\n");
681 snprintf(commandstring
, STRING_SIZE
,
682 "cp /cdrom/%s /harddisk/var/ipfire/backup", restore_file
);
683 mysystem(commandstring
);
686 mysystem("umount /cdrom");
687 snprintf(commandstring
, STRING_SIZE
, "/usr/bin/eject /dev/%s", sourcedrive
);
688 mysystem(commandstring
);
691 sprintf(message
, ctr
[TR_CONGRATULATIONS_LONG
],
693 newtWinMessage(ctr
[TR_CONGRATULATIONS
], ctr
[TR_PRESS_OK_TO_REBOOT
], message
);
699 fprintf(flog
, "Install program ended.\n");
702 newtWinMessage(title
, ctr
[TR_OK
], ctr
[TR_PRESS_OK_TO_REBOOT
]);
704 freekeyvalues(ethernetkv
);
706 if (allok
&& !allok_fastexit
)
709 fprintf(flog
, "Entering unattended setup\n");
710 if (unattended_setup(unattendedkv
)) {
711 snprintf(commandstring
, STRING_SIZE
, "/bin/sleep 10");
712 runcommandwithstatus(commandstring
, "Unattended installation finished, system will reboot");
714 errorbox("Unattended setup failed.");
723 if (system("/bin/umount /harddisk/proc"))
724 printf("Unable to umount /harddisk/proc.\n");
734 snprintf(commandstring
, STRING_SIZE
, "/bin/swapoff %s", destination
->part_swap
);
739 system("/bin/umount /harddisk/proc >/dev/null 2>&1");
740 system("/bin/umount /harddisk/dev >/dev/null 2>&1");
741 system("/bin/umount /harddisk/sys >/dev/null 2>&1");
743 system("/bin/umount /harddisk/var >/dev/null 2>&1");
744 system("/bin/umount /harddisk/boot >/dev/null 2>&1");
745 system("/bin/umount /harddisk >/dev/null 2>&1");
755 hw_free_disks(selected_disks
);