1
|
<?php
|
2
|
/*
|
3
|
installer.php (pfSense webInstaller)
|
4
|
part of pfSense (https://www.pfsense.org/)
|
5
|
Copyright (C) 2010 Scott Ullrich <sullrich@gmail.com>
|
6
|
All rights reserved.
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
|
30
|
$nocsrf = true;
|
31
|
|
32
|
require("globals.inc");
|
33
|
require("guiconfig.inc");
|
34
|
|
35
|
define('PC_SYSINSTALL', '/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh');
|
36
|
|
37
|
if($g['platform'] == "pfSense" or $g['platform'] == "nanobsd") {
|
38
|
header("Location: /");
|
39
|
exit;
|
40
|
}
|
41
|
|
42
|
// Main switch dispatcher
|
43
|
switch ($_REQUEST['state']) {
|
44
|
case "update_installer_status":
|
45
|
update_installer_status();
|
46
|
exit;
|
47
|
case "custominstall":
|
48
|
installer_custom();
|
49
|
exit;
|
50
|
case "begin_install":
|
51
|
installing_gui();
|
52
|
begin_install();
|
53
|
exit;
|
54
|
case "verify_before_install":
|
55
|
verify_before_install();
|
56
|
exit;
|
57
|
case "easy_install_ufs":
|
58
|
easy_install("UFS+S");
|
59
|
exit;
|
60
|
case "easy_install_ufs":
|
61
|
easy_install("ZFS");
|
62
|
exit;
|
63
|
|
64
|
default:
|
65
|
installer_main();
|
66
|
}
|
67
|
|
68
|
function easy_install($fstype = "UFS+S") {
|
69
|
// Calculate swap and disk sizes
|
70
|
$disks = installer_find_all_disks();
|
71
|
$memory = get_memory();
|
72
|
$swap_size = $memory[0] * 2;
|
73
|
$first_disk = trim(installer_find_first_disk());
|
74
|
$disk_info = pcsysinstall_get_disk_info($first_disk);
|
75
|
$size = $disk_info['size'];
|
76
|
$first_disk_size = $size - $swap_size;
|
77
|
$disk_setup = array();
|
78
|
$tmp_array = array();
|
79
|
// Build the disk layout for /
|
80
|
$tmp_array['disk'] = $first_disk;
|
81
|
$tmp_array['size'] = $first_disk_size;
|
82
|
$tmp_array['mountpoint'] = "/";
|
83
|
$tmp_array['fstype'] = $fstype;
|
84
|
$disk_setup[] = $tmp_array;
|
85
|
unset($tmp_array);
|
86
|
$tmp_array = array();
|
87
|
// Build the disk layout for SWAP
|
88
|
$tmp_array['disk'] = $first_disk;
|
89
|
$tmp_array['size'] = $swap_size;
|
90
|
$tmp_array['mountpoint'] = "none";
|
91
|
$tmp_array['fstype'] = "SWAP";
|
92
|
$disk_setup[] = $tmp_array;
|
93
|
unset($tmp_array);
|
94
|
$bootmanager = "bsd";
|
95
|
file_put_contents("/tmp/webInstaller_disk_layout.txt", serialize($disk_setup));
|
96
|
file_put_contents("/tmp/webInstaller_disk_bootmanager.txt", serialize($bootmanager));
|
97
|
header("Location: installer.php?state=verify_before_install");
|
98
|
exit;
|
99
|
}
|
100
|
|
101
|
function write_out_pc_sysinstaller_config($disks, $bootmanager = "bsd") {
|
102
|
$diskareas = "";
|
103
|
$fd = fopen("/usr/sbin/pc-sysinstall/examples/pfSense-install.cfg", "w");
|
104
|
if(!$fd)
|
105
|
return true;
|
106
|
if($bootmanager == "")
|
107
|
$bootmanager = "none";
|
108
|
// Yes, -1. We ++ early in loop.
|
109
|
$numdisks = -1;
|
110
|
$lastdisk = "";
|
111
|
$diskdefs = "";
|
112
|
// Run through the disks and create the conf areas for pc-sysinstaller
|
113
|
foreach($disks as $disksa) {
|
114
|
$fstype = $disksa['fstype'];
|
115
|
$size = $disksa['size'];
|
116
|
$mountpoint = $disksa['mountpoint'];
|
117
|
$disk = $disksa['disk'];
|
118
|
if($disk <> $lastdisk) {
|
119
|
$lastdisk = $disk;
|
120
|
$numdisks++;
|
121
|
$diskdefs .= "# disk {$disk}\n";
|
122
|
$diskdefs .= "disk{$numdisks}={$disk}\n";
|
123
|
$diskdefs .= "partition=all\n";
|
124
|
$diskdefs .= "bootManager={$bootmanager}\n";
|
125
|
$diskdefs .= "commitDiskPart\n\n";
|
126
|
}
|
127
|
$diskareas .= "disk{$numdisks}-part={$fstype} {$size} {$mountpoint} \n";
|
128
|
if($encpass)
|
129
|
$diskareas .= "encpass={$encpass}\n";
|
130
|
}
|
131
|
|
132
|
$config = <<<EOF
|
133
|
# Sample configuration file for an installation using pc-sysinstall
|
134
|
# This file was automatically generated by installer.php
|
135
|
|
136
|
installMode=fresh
|
137
|
installInteractive=yes
|
138
|
installType=FreeBSD
|
139
|
installMedium=LiveCD
|
140
|
|
141
|
# Set the disk parameters
|
142
|
{$diskdefs}
|
143
|
|
144
|
# Setup the disk label
|
145
|
# All sizes are expressed in MB
|
146
|
# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP
|
147
|
# Size 0 means use the rest of the slice size
|
148
|
# Alternatively, you can append .eli to any of
|
149
|
# the above filesystem types to encrypt that disk.
|
150
|
# If you with to use a passphrase with this
|
151
|
# encrypted partition, on the next line
|
152
|
# the flag "encpass=" should be entered:
|
153
|
# encpass=mypass
|
154
|
# disk0-part=UFS 500 /boot
|
155
|
# disk0-part=UFS.eli 500 /
|
156
|
# disk0-part=UFS.eli 500 /usr
|
157
|
{$diskareas}
|
158
|
|
159
|
# Do it now!
|
160
|
commitDiskLabel
|
161
|
|
162
|
# Set if we are installing via optical, USB, or FTP
|
163
|
installType=FreeBSD
|
164
|
|
165
|
packageType=cpdup
|
166
|
|
167
|
# Optional Components
|
168
|
cpdupPaths=boot,COPYRIGHT,bin,conf,conf.default,dev,etc,home,kernels,libexec,lib,root,sbin,usr,var
|
169
|
|
170
|
# runExtCommand=chmod a+rx /usr/local/bin/after_installation_routines.sh ; cd / ; /usr/local/bin/after_installation_routines.sh
|
171
|
EOF;
|
172
|
fwrite($fd, $config);
|
173
|
fclose($fd);
|
174
|
return;
|
175
|
}
|
176
|
|
177
|
function start_installation() {
|
178
|
global $g, $fstype, $savemsg;
|
179
|
if(file_exists("/tmp/install_complete"))
|
180
|
return;
|
181
|
$ps_running = exec("/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep 'sh /tmp/installer.sh'");
|
182
|
if($ps_running)
|
183
|
return;
|
184
|
$fd = fopen("/tmp/installer.sh", "w");
|
185
|
if(!$fd) {
|
186
|
die(gettext("Could not open /tmp/installer.sh for writing"));
|
187
|
exit;
|
188
|
}
|
189
|
fwrite($fd, "/bin/rm /tmp/.pc-sysinstall/pc-sysinstall.log 2>/dev/null\n");
|
190
|
fwrite($fd, "/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh -c /usr/sbin/pc-sysinstall/examples/pfSense-install.cfg \n");
|
191
|
fwrite($fd, "/bin/chmod a+rx /usr/local/bin/after_installation_routines.sh\n");
|
192
|
fwrite($fd, "cd / && /usr/local/bin/after_installation_routines.sh\n");
|
193
|
fwrite($fd, "/bin/mkdir /mnt/tmp\n");
|
194
|
fwrite($fd, "/usr/bin/touch /tmp/install_complete\n");
|
195
|
fclose($fd);
|
196
|
exec("/bin/chmod a+rx /tmp/installer.sh");
|
197
|
mwexec_bg("/bin/sh /tmp/installer.sh");
|
198
|
}
|
199
|
|
200
|
function installer_find_first_disk() {
|
201
|
global $g, $fstype, $savemsg;
|
202
|
$disk = `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-list | head -n1 | cut -d':' -f1`;
|
203
|
return trim($disk);
|
204
|
}
|
205
|
|
206
|
function pcsysinstall_get_disk_info($diskname) {
|
207
|
global $g, $fstype, $savemsg;
|
208
|
$disk = explode("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-list`);
|
209
|
$disks_array = array();
|
210
|
foreach($disk as $d) {
|
211
|
$disks_info = explode(":", $d);
|
212
|
$tmp_array = array();
|
213
|
if($disks_info[0] == $diskname) {
|
214
|
$disk_info = explode("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-info {$disks_info[0]}`);
|
215
|
$disk_info_split = explode("=", $disk_info);
|
216
|
foreach($disk_info as $di) {
|
217
|
$di_s = explode("=", $di);
|
218
|
if($di_s[0])
|
219
|
$tmp_array[$di_s[0]] = $di_s[1];
|
220
|
}
|
221
|
$tmp_array['size']--;
|
222
|
$tmp_array['disk'] = trim($disks_info[0]);
|
223
|
$tmp_array['desc'] = trim(htmlentities($disks_info[1]));
|
224
|
return $tmp_array;
|
225
|
}
|
226
|
}
|
227
|
}
|
228
|
|
229
|
// Return an array with all disks information.
|
230
|
function installer_find_all_disks() {
|
231
|
global $g, $fstype, $savemsg;
|
232
|
$disk = explode("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-list`);
|
233
|
$disks_array = array();
|
234
|
foreach($disk as $d) {
|
235
|
if(!$d)
|
236
|
continue;
|
237
|
$disks_info = explode(":", $d);
|
238
|
$tmp_array = array();
|
239
|
$disk_info = explode("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh disk-info {$disks_info[0]}`);
|
240
|
foreach($disk_info as $di) {
|
241
|
$di_s = explode("=", $di);
|
242
|
if($di_s[0])
|
243
|
$tmp_array[$di_s[0]] = $di_s[1];
|
244
|
}
|
245
|
$tmp_array['size']--;
|
246
|
$tmp_array['disk'] = trim($disks_info[0]);
|
247
|
$tmp_array['desc'] = trim(htmlentities($disks_info[1]));
|
248
|
$disks_array[] = $tmp_array;
|
249
|
}
|
250
|
return $disks_array;
|
251
|
}
|
252
|
|
253
|
function update_installer_status() {
|
254
|
global $g, $fstype, $savemsg;
|
255
|
// Ensure status files exist
|
256
|
if(!file_exists("/tmp/installer_installer_running"))
|
257
|
touch("/tmp/installer_installer_running");
|
258
|
$status = `cat /tmp/.pc-sysinstall/pc-sysinstall.log`;
|
259
|
$status = str_replace("\n", "\\n", $status);
|
260
|
$status = str_replace("\n", "\\r", $status);
|
261
|
$status = str_replace("'", "\\'", $status);
|
262
|
echo "document.forms[0].installeroutput.value='$status';\n";
|
263
|
echo "document.forms[0].installeroutput.scrollTop = document.forms[0].installeroutput.scrollHeight;\n";
|
264
|
// Find out installer progress
|
265
|
$progress = "5";
|
266
|
if(strstr($status, "Running: dd"))
|
267
|
$progress = "6";
|
268
|
if(strstr($status, "Running: gpart create -s GPT"))
|
269
|
$progress = "7";
|
270
|
if(strstr($status, "Running: gpart bootcode"))
|
271
|
$progress = "7";
|
272
|
if(strstr($status, "Running: newfs -U"))
|
273
|
$progress = "8";
|
274
|
if(strstr($status, "Running: sync"))
|
275
|
$progress = "9";
|
276
|
if(strstr($status, "/boot /mnt/boot"))
|
277
|
$progress = "10";
|
278
|
if(strstr($status, "/COPYRIGHT /mnt/COPYRIGHT"))
|
279
|
$progress = "11";
|
280
|
if(strstr($status, "/bin /mnt/bin"))
|
281
|
$progress = "12";
|
282
|
if(strstr($status, "/conf /mnt/conf"))
|
283
|
$progress = "15";
|
284
|
if(strstr($status, "/conf.default /mnt/conf.default"))
|
285
|
$progress = "20";
|
286
|
if(strstr($status, "/dev /mnt/dev"))
|
287
|
$progress = "25";
|
288
|
if(strstr($status, "/etc /mnt/etc"))
|
289
|
$progress = "30";
|
290
|
if(strstr($status, "/home /mnt/home"))
|
291
|
$progress = "35";
|
292
|
if(strstr($status, "/kernels /mnt/kernels"))
|
293
|
$progress = "40";
|
294
|
if(strstr($status, "/libexec /mnt/libexec"))
|
295
|
$progress = "50";
|
296
|
if(strstr($status, "/lib /mnt/lib"))
|
297
|
$progress = "60";
|
298
|
if(strstr($status, "/root /mnt/root"))
|
299
|
$progress = "70";
|
300
|
if(strstr($status, "/sbin /mnt/sbin"))
|
301
|
$progress = "75";
|
302
|
if(strstr($status, "/sys /mnt/sys"))
|
303
|
$progress = "80";
|
304
|
if(strstr($status, "/usr /mnt/usr"))
|
305
|
$progress = "95";
|
306
|
if(strstr($status, "/usr /mnt/usr"))
|
307
|
$progress = "90";
|
308
|
if(strstr($status, "/var /mnt/var"))
|
309
|
$progress = "95";
|
310
|
if(strstr($status, "cap_mkdb /etc/login.conf"))
|
311
|
$progress = "96";
|
312
|
if(strstr($status, "Setting hostname"))
|
313
|
$progress = "97";
|
314
|
if(strstr($status, "umount -f /mnt"))
|
315
|
$progress = "98";
|
316
|
if(strstr($status, "umount -f /mnt"))
|
317
|
$progress = "99";
|
318
|
if(strstr($status, "Installation finished"))
|
319
|
$progress = "100";
|
320
|
// Check for error and bail if we see one.
|
321
|
if(stristr($status, "error")) {
|
322
|
$error = true;
|
323
|
echo "\$('#installerrunning').html('<img class=\"infoboxnpimg\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\"> <font size=\"2\"><b>An error occurred. Aborting installation. <a href=\"/installer\">Back</a> to webInstaller'); ";
|
324
|
echo "\$('#progressbar').css('width','100%');\n";
|
325
|
unlink_if_exists("/tmp/install_complete");
|
326
|
return;
|
327
|
}
|
328
|
$running_old = trim(file_get_contents("/tmp/installer_installer_running"));
|
329
|
if($installer_running <> "running") {
|
330
|
$ps_running = exec("/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep 'sh /tmp/installer.sh'");
|
331
|
if($ps_running) {
|
332
|
$running = "\$('#installerrunning').html('<table><tr><td valign=\"middle\"><img src=\"/themes/{$g['theme']}/images/misc/loader.gif\"></td><td valign=\"middle\"> <font size=\"2\"><b>Installer running ({$progress}% completed)...</td></tr></table>'); ";
|
333
|
if($running_old <> $running) {
|
334
|
echo $running;
|
335
|
file_put_contents("/tmp/installer_installer_running", "$running");
|
336
|
}
|
337
|
}
|
338
|
}
|
339
|
if($progress)
|
340
|
echo "\$('#progressbar').css('width','{$progress}%');\n";
|
341
|
if(file_exists("/tmp/install_complete")) {
|
342
|
echo "\$('#installerrunning').html('<img class=\"infoboxnpimg\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\"> <font size=\"+1\">Installation completed. Please <a href=\"/reboot.php\">reboot</a> to continue');\n";
|
343
|
echo "\$('#pbdiv').fadeOut();\n";
|
344
|
unlink_if_exists("/tmp/installer.sh");
|
345
|
file_put_contents("/tmp/installer_installer_running", "finished");
|
346
|
}
|
347
|
}
|
348
|
|
349
|
function update_installer_status_win($status) {
|
350
|
global $g, $fstype, $savemsg;
|
351
|
echo "<script type=\"text/javascript\">\n";
|
352
|
echo " \$('#installeroutput').val('" . str_replace(htmlentities($status), "\n", "") . "');\n";
|
353
|
echo "</script>\n";
|
354
|
}
|
355
|
|
356
|
function begin_install() {
|
357
|
global $g, $savemsg;
|
358
|
if(file_exists("/tmp/install_complete"))
|
359
|
return;
|
360
|
unlink_if_exists("/tmp/install_complete");
|
361
|
update_installer_status_win(sprintf(gettext("Beginning installation on disk %s."),$disk));
|
362
|
start_installation();
|
363
|
}
|
364
|
|
365
|
function head_html() {
|
366
|
global $g, $fstype, $savemsg;
|
367
|
echo <<<EOF
|
368
|
<html>
|
369
|
<head>
|
370
|
<style type='text/css'>
|
371
|
hr {
|
372
|
border: 0;
|
373
|
color: #000000;
|
374
|
background-color: #000000;
|
375
|
height: 1px;
|
376
|
width: 100%;
|
377
|
text-align: left;
|
378
|
}
|
379
|
a:link {
|
380
|
color: #000000;
|
381
|
text-decoration:underline;
|
382
|
font-size:14;
|
383
|
}
|
384
|
a:visited {
|
385
|
color: #000000;
|
386
|
text-decoration:underline;
|
387
|
font-size:14;
|
388
|
}
|
389
|
a:hover {
|
390
|
color: #FFFF00;
|
391
|
text-decoration: none;
|
392
|
font-size:14;
|
393
|
}
|
394
|
a:active {
|
395
|
color: #FFFF00;
|
396
|
text-decoration:underline;
|
397
|
font-size:14;
|
398
|
}
|
399
|
</style>
|
400
|
</head>
|
401
|
EOF;
|
402
|
|
403
|
}
|
404
|
|
405
|
function body_html() {
|
406
|
global $g, $fstype, $savemsg;
|
407
|
$pgtitle = array("{$g['product_name']}", gettext("Installer"));
|
408
|
include("head.inc");
|
409
|
echo <<<EOF
|
410
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
411
|
<script type="text/javascript" src="/javascript/jquery.js"></script>
|
412
|
<script type="text/javascript" src="/javascript/jquery/jquery-ui.custom.min.js"></script>
|
413
|
<script type="text/javascript">
|
414
|
function getinstallerprogress() {
|
415
|
url = '/installer/installer.php';
|
416
|
pars = 'state=update_installer_status';
|
417
|
callajax(url, pars, installcallback);
|
418
|
}
|
419
|
function callajax(url, pars, activitycallback) {
|
420
|
jQuery.ajax(
|
421
|
url,
|
422
|
{
|
423
|
type: 'post',
|
424
|
data: pars,
|
425
|
complete: activitycallback
|
426
|
});
|
427
|
}
|
428
|
function installcallback(transport) {
|
429
|
setTimeout('getinstallerprogress()', 2000);
|
430
|
eval(transport.responseText);
|
431
|
}
|
432
|
</script>
|
433
|
EOF;
|
434
|
|
435
|
if($one_two)
|
436
|
echo "<p class=\"pgtitle\">{$pgtitle}</font></p>";
|
437
|
|
438
|
if ($savemsg) print_info_box($savemsg);
|
439
|
}
|
440
|
|
441
|
function end_html() {
|
442
|
global $g, $fstype, $savemsg;
|
443
|
echo "</form>";
|
444
|
echo "</body>";
|
445
|
echo "</html>";
|
446
|
}
|
447
|
|
448
|
function template() {
|
449
|
global $g, $fstype, $savemsg;
|
450
|
head_html();
|
451
|
body_html();
|
452
|
echo <<<EOF
|
453
|
<div id="mainlevel">
|
454
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
455
|
<tr>
|
456
|
<td>
|
457
|
<div id="mainarea">
|
458
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
459
|
<tr>
|
460
|
<td class="tabcont" >
|
461
|
<form action="installer.php" method="post">
|
462
|
<div id="pfsensetemplate">
|
463
|
|
464
|
|
465
|
</div>
|
466
|
</td>
|
467
|
</tr>
|
468
|
</table>
|
469
|
</div>
|
470
|
</td>
|
471
|
</tr>
|
472
|
</table>
|
473
|
</div>
|
474
|
EOF;
|
475
|
end_html();
|
476
|
}
|
477
|
|
478
|
function verify_before_install() {
|
479
|
global $g, $fstype, $savemsg;
|
480
|
$encrypted_root = false;
|
481
|
$non_encrypted_boot = false;
|
482
|
$non_encrypted_notice = false;
|
483
|
head_html();
|
484
|
body_html();
|
485
|
page_table_start($g['product_name'] . " installer - Verify final installation settings");
|
486
|
// If we are visiting this step from anything but the row editor / custom install
|
487
|
// then load the on disk layout contents if they are available.
|
488
|
if(!$_REQUEST['fstype0'] && file_exists("/tmp/webInstaller_disk_layout.txt")) {
|
489
|
$disks = unserialize(file_get_contents("/tmp/webInstaller_disk_layout.txt"));
|
490
|
$bootmanager = unserialize(file_get_contents("/tmp/webInstaller_disk_bootmanager.txt"));
|
491
|
$restored_layout_from_file = true;
|
492
|
$restored_layout_txt = "The previous disk layout was restored from disk";
|
493
|
} else {
|
494
|
$disks = array();
|
495
|
}
|
496
|
if(!$bootmanager)
|
497
|
$bootmanager = $_REQUEST['bootmanager'];
|
498
|
echo "\n<!--" . print_r($_REQUEST, true) . " -->\n";
|
499
|
$disk = pcsysinstall_get_disk_info(htmlspecialchars($_REQUEST['disk']));
|
500
|
$disksize = format_bytes($disk['size'] * 1048576);
|
501
|
// Loop through posted items and create an array
|
502
|
for($x=0; $x<99; $x++) { // XXX: Make this more optimal
|
503
|
if(!$_REQUEST['fstype' . $x])
|
504
|
continue;
|
505
|
$tmparray = array();
|
506
|
if($_REQUEST['fstype' . $x] <> "SWAP") {
|
507
|
$tmparray['mountpoint'] = $_REQUEST['mountpoint' . $x];
|
508
|
// Check for encrypted slice /
|
509
|
if(stristr($_REQUEST['fstype' . $x], ".eli")) {
|
510
|
if($tmparray['mountpoint'] == "/")
|
511
|
$encrypted_root = true;
|
512
|
}
|
513
|
// Check if we have a non-encrypted /boot
|
514
|
if($tmparray['mountpoint'] == "/boot") {
|
515
|
if(!stristr($_REQUEST['fstype' . $x], ".eli"))
|
516
|
$non_encrypted_boot = true;
|
517
|
}
|
518
|
if($tmparray['mountpoint'] == "/conf") {
|
519
|
$tmparray['mountpoint'] = "/conf{$x}";
|
520
|
$error_txt[] = "/conf is not an allowed mount point and has been renamed to /conf{$x}.";
|
521
|
}
|
522
|
} else {
|
523
|
$tmparray['mountpoint'] = "none";
|
524
|
}
|
525
|
// If we have an encrypted /root and lack a non encrypted /boot, throw an error/warning
|
526
|
if($encrypted_root && !$non_encrypted_boot && !$non_encrypted_notice) {
|
527
|
$error_txt[] = "A non-encrypted /boot slice is required when encrypting the / slice";
|
528
|
$non_encrypted_notice = true;
|
529
|
}
|
530
|
$tmparray['disk'] = $_REQUEST['disk' . $x];
|
531
|
$tmparray['fstype'] = $_REQUEST['fstype' . $x];
|
532
|
$tmparray['size'] = $_REQUEST['size' . $x];
|
533
|
$tmparray['encpass'] = $_REQUEST['encpass' . $x];
|
534
|
$disks[] = $tmparray;
|
535
|
}
|
536
|
echo "\n<!-- " . print_r($disks, true) . " --> \n";
|
537
|
$bootmanagerupper = strtoupper($bootmanager);
|
538
|
echo <<<EOFAMBAC
|
539
|
<form method="post" action="installer.php">
|
540
|
<input type="hidden" name="fstype" value="{$fstype_echo}">
|
541
|
<input type="hidden" name="disk" value="{$disk_echo}">
|
542
|
<input type="hidden" name="state" value="begin_install">
|
543
|
<input type="hidden" name="swapsize" value="{$swapsize}">
|
544
|
<input type="hidden" name="encpass" value="{$encpass}">
|
545
|
<input type="hidden" name="bootmanager" value="{$bootmanager}">
|
546
|
<div id="mainlevel">
|
547
|
<table width="800" border="0" cellpadding="0" cellspacing="0">
|
548
|
<tr>
|
549
|
<td>
|
550
|
<div id="mainarea">
|
551
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
552
|
<tr>
|
553
|
<td >
|
554
|
<div>
|
555
|
<center>
|
556
|
<div id="pfsensetemplate">
|
557
|
<table width='100%'>
|
558
|
EOFAMBAC;
|
559
|
// If errors are found, throw the big red box.
|
560
|
if ($error_txt) {
|
561
|
echo "<tr><td colspan=\"5\"> </td>";
|
562
|
echo "<tr><td colspan=\"5\">";
|
563
|
print_input_errors($error_txt);
|
564
|
echo "</td></tr>";
|
565
|
} else
|
566
|
echo "<tr><td> </td></tr>";
|
567
|
|
568
|
echo <<<EOFAMBACBAF
|
569
|
|
570
|
<tr><td colspan='5' align="center"><b>Boot manager: {$bootmanagerupper}</td></tr>
|
571
|
<tr><td> </td></tr>
|
572
|
<tr>
|
573
|
<td align='left'>
|
574
|
<b>Mount point</b>
|
575
|
</td>
|
576
|
<td align='left'>
|
577
|
<b>Filesysytem type</b>
|
578
|
</td>
|
579
|
<td align='left'>
|
580
|
<b>Disk</b>
|
581
|
</td>
|
582
|
<td align='left'>
|
583
|
<b>Size</b>
|
584
|
</td>
|
585
|
<td align='left'>
|
586
|
<b>Encryption password</b>
|
587
|
</td>
|
588
|
</tr>
|
589
|
<tr><td colspan='5'><hr></td></tr>
|
590
|
|
591
|
EOFAMBACBAF;
|
592
|
|
593
|
foreach($disks as $disk) {
|
594
|
$desc = pcsysinstall_get_disk_info($disk['disk']);
|
595
|
echo "<tr>";
|
596
|
echo "<td> {$disk['mountpoint']}</td>";
|
597
|
echo "<td>{$disk['fstype']}</td>";
|
598
|
echo "<td>{$disk['disk']} {$desc['desc']}</td>";
|
599
|
echo "<td>{$disk['size']}</td>";
|
600
|
echo "<td>{$disk['encpass']}</td>";
|
601
|
echo "</tr>";
|
602
|
}
|
603
|
|
604
|
echo <<<EOFAMB
|
605
|
<tr><td colspan="5"><hr></td></tr>
|
606
|
</table>
|
607
|
</div>
|
608
|
</center>
|
609
|
</div>
|
610
|
</td>
|
611
|
</tr>
|
612
|
</table>
|
613
|
</div>
|
614
|
<center>
|
615
|
<p/>
|
616
|
<input type="button" value="Cancel" onClick="javascript:document.location='installer.php?state=custominstall';">
|
617
|
EOFAMB;
|
618
|
if(!$error_txt)
|
619
|
echo "<input type=\"submit\" value=\"Begin installation\"> <br /> ";
|
620
|
echo <<<EOFAMBASDF
|
621
|
|
622
|
</center>
|
623
|
</td>
|
624
|
</tr>
|
625
|
</table>
|
626
|
</div>
|
627
|
EOFAMBASDF;
|
628
|
|
629
|
|
630
|
page_table_end();
|
631
|
end_html();
|
632
|
write_out_pc_sysinstaller_config($disks, $bootmanager);
|
633
|
// Serialize layout to disk so it can be read in later.
|
634
|
file_put_contents("/tmp/webInstaller_disk_layout.txt", serialize($disks));
|
635
|
file_put_contents("/tmp/webInstaller_disk_bootmanager.txt", serialize($bootmanager));
|
636
|
}
|
637
|
|
638
|
function installing_gui() {
|
639
|
global $g, $fstype, $savemsg;
|
640
|
head_html();
|
641
|
body_html();
|
642
|
echo "<form action=\"installer.php\" method=\"post\" state=\"step1_post\">";
|
643
|
page_table_start();
|
644
|
echo <<<EOF
|
645
|
<center>
|
646
|
<table width="100%">
|
647
|
<tr><td>
|
648
|
<div id="mainlevel">
|
649
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
650
|
<tr>
|
651
|
<td>
|
652
|
<div id="mainarea">
|
653
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
654
|
<tr>
|
655
|
<td>
|
656
|
<div id="pfsenseinstaller" width="100%">
|
657
|
<div id='installerrunning' width='100%' style="padding:8px; border:1px dashed #000000">
|
658
|
<table>
|
659
|
<tr>
|
660
|
<td valign="middle">
|
661
|
<img src="/themes/{$g['theme']}/images/misc/loader.gif">
|
662
|
</td>
|
663
|
<td valign="middle">
|
664
|
<font size="2"><b>Starting Installer... Please wait...
|
665
|
</td>
|
666
|
</tr>
|
667
|
</table>
|
668
|
</div>
|
669
|
<div id='pbdiv'>
|
670
|
<br />
|
671
|
<center>
|
672
|
<table id='pbtable' height='15' width='640' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
|
673
|
<tr>
|
674
|
<td background="/themes/{$g['theme']}/images/misc/bar_left.gif" height='15' width='5'>
|
675
|
</td>
|
676
|
<td>
|
677
|
<table id="progholder" name="progholder" height='15' width='630' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
|
678
|
<td background="/themes/{$g['theme']}/images/misc/bar_gray.gif" valign="top" align="left">
|
679
|
<img src='/themes/{$g['theme']}/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
|
680
|
</td>
|
681
|
</table>
|
682
|
</td>
|
683
|
<td background="/themes/{$g['theme']}/images/misc/bar_right.gif" height='15' width='5'>
|
684
|
</td>
|
685
|
</tr>
|
686
|
</table>
|
687
|
<br />
|
688
|
</div>
|
689
|
<textarea name='installeroutput' id='installeroutput' rows="31" cols="90">
|
690
|
</textarea>
|
691
|
</div>
|
692
|
</td>
|
693
|
</tr>
|
694
|
</table>
|
695
|
</div>
|
696
|
</td>
|
697
|
</tr>
|
698
|
</table>
|
699
|
</div>
|
700
|
</td></tr>
|
701
|
</table>
|
702
|
</center>
|
703
|
<script type="text/javascript">setTimeout('getinstallerprogress()', 250);</script>
|
704
|
|
705
|
EOF;
|
706
|
page_table_end();
|
707
|
end_html();
|
708
|
}
|
709
|
|
710
|
function page_table_start($pgtitle = "") {
|
711
|
global $g, $fstype, $savemsg;
|
712
|
if($pgtitle == "")
|
713
|
$pgtitle = "{$g['product_name']} installer";
|
714
|
echo <<<EOF
|
715
|
<center>
|
716
|
<img border="0" src="/themes/{$g['theme']}/images/logo.gif"></a><br />
|
717
|
<table cellpadding="6" cellspacing="0" width="550" style="border:1px solid #000000">
|
718
|
<tr height="10" bgcolor="#990000">
|
719
|
<td style="border-bottom:1px solid #000000">
|
720
|
<font color='white'>
|
721
|
<b>
|
722
|
{$pgtitle}
|
723
|
</b>
|
724
|
</font>
|
725
|
</td>
|
726
|
</tr>
|
727
|
<tr>
|
728
|
<td>
|
729
|
|
730
|
EOF;
|
731
|
|
732
|
}
|
733
|
|
734
|
function page_table_end() {
|
735
|
global $g, $fstype, $savemsg;
|
736
|
echo <<<EOF
|
737
|
</td>
|
738
|
</tr>
|
739
|
</table>
|
740
|
</center>
|
741
|
|
742
|
EOF;
|
743
|
|
744
|
}
|
745
|
|
746
|
function installer_custom() {
|
747
|
global $g, $fstype, $savemsg;
|
748
|
global $select_txt, $custom_disks;
|
749
|
if(file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log"))
|
750
|
unlink("/tmp/.pc-sysinstall/pc-sysinstall.log");
|
751
|
$disks = installer_find_all_disks();
|
752
|
// Pass size of disks down to javascript.
|
753
|
$disk_sizes_js_txt = "var disk_sizes = new Array();\n";
|
754
|
foreach($disks as $disk)
|
755
|
$disk_sizes_js_txt .= "disk_sizes['{$disk['disk']}'] = '{$disk['size']}';\n";
|
756
|
head_html();
|
757
|
body_html();
|
758
|
page_table_start($g['product_name'] . " installer - Customize disk(s) layout");
|
759
|
echo <<<EOF
|
760
|
<script type="text/javascript">
|
761
|
Array.prototype.in_array = function(p_val) {
|
762
|
for(var i = 0, l = this.length; i < l; i++) {
|
763
|
if(this[i] == p_val) {
|
764
|
return true;
|
765
|
}
|
766
|
}
|
767
|
return false;
|
768
|
}
|
769
|
function row_helper_dynamic_custom() {
|
770
|
var totalsize = 0;
|
771
|
{$disk_sizes_js_txt}
|
772
|
// Run through all rows and process data
|
773
|
for(var x = 0; x<99; x++) { //optimize me better
|
774
|
if(\$('#fstype' + x).length) {
|
775
|
if(\$('#size' + x).val() == '')
|
776
|
\$('#size' + x).val(disk_sizes[\$('disk' + x).value]);
|
777
|
var fstype = \$('#fstype' + x).val();
|
778
|
if(fstype.substring(fstype.length - 4) == ".eli") {
|
779
|
\$('#encpass' + x).prop('disabled',false);
|
780
|
if(!encryption_warning_shown) {
|
781
|
alert('NOTE: If you define a disk encryption password you will need to enter it on *EVERY* bootup!');
|
782
|
encryption_warning_shown = true;
|
783
|
}
|
784
|
} else {
|
785
|
\$('#encpass' + x).prop('disabled',true);
|
786
|
}
|
787
|
}
|
788
|
// Calculate size allocations
|
789
|
if(\$('#size' + x).length) {
|
790
|
if(parseInt($('#size' + x).val()) > 0)
|
791
|
totalsize += parseInt($('#size' + x).val());
|
792
|
}
|
793
|
}
|
794
|
// If the totalsize element exists, set it and disable
|
795
|
if(\$('#totalsize').length) {
|
796
|
if(\$('#totalsize').val() != totalsize) {
|
797
|
// When size allocation changes, draw attention.
|
798
|
jQuery('#totalsize').effect('highlight');
|
799
|
\$('#totalsize').val(totalsize);
|
800
|
}
|
801
|
\$('#totalsize').prop('disabled',true);
|
802
|
}
|
803
|
if(\$('#disktotals').length) {
|
804
|
var disks_seen = new Array();
|
805
|
var tmp_sizedisks = 0;
|
806
|
var disksseen = 0;
|
807
|
for(var xx = 0; xx<99; xx++) {
|
808
|
if(\$('#disk' + xx).length) {
|
809
|
if(!disks_seen.in_array(\$('#disk' + xx).val())) {
|
810
|
tmp_sizedisks += parseInt(disk_sizes[\$('#disk' + xx).val()]);
|
811
|
disks_seen[disksseen] = \$('#disk' + xx).val();
|
812
|
disksseen++;
|
813
|
}
|
814
|
}
|
815
|
\$('#disktotals').val(tmp_sizedisks);
|
816
|
\$('#disktotals').prop('disabled',true);
|
817
|
\$('#disktotals').css('color','#000000');
|
818
|
var remaining = parseInt(\$('#disktotals').val()) - parseInt(\$('#totalsize').val());
|
819
|
if(remaining == 0) {
|
820
|
if(\$('#totalsize').length)
|
821
|
\$('#totalsize').css({
|
822
|
'background':'#00FF00',
|
823
|
'color':'#000000'
|
824
|
});
|
825
|
} else {
|
826
|
if(\$('#totalsize').length)
|
827
|
\$('#totalsize').css({
|
828
|
'background':'#FFFFFF',
|
829
|
'color':'#000000'
|
830
|
});
|
831
|
}
|
832
|
if(parseInt(\$('#totalsize').val()) > parseInt(\$('#disktotals').val())) {
|
833
|
if(\$('#totalsize'))
|
834
|
\$('#totalsize').css({
|
835
|
'background':'#FF0000',
|
836
|
'color':'#000000'
|
837
|
});
|
838
|
}
|
839
|
if(\$('#availalloc').length) {
|
840
|
\$('#availalloc').prop('disabled',true);
|
841
|
\$('#availalloc').val(remaining);
|
842
|
\$('#availalloc').css({
|
843
|
'background':'#FFFFFF',
|
844
|
'color':'#000000'
|
845
|
});
|
846
|
}
|
847
|
}
|
848
|
}
|
849
|
}
|
850
|
</script>
|
851
|
<script type="text/javascript" src="/javascript/row_helper_dynamic.js"></script>
|
852
|
<script type="text/javascript">
|
853
|
// Setup rowhelper data types
|
854
|
rowname[0] = "mountpoint";
|
855
|
rowtype[0] = "textbox";
|
856
|
rowsize[0] = "8";
|
857
|
rowname[1] = "fstype";
|
858
|
rowtype[1] = "select";
|
859
|
rowsize[1] = "1";
|
860
|
rowname[2] = "disk";
|
861
|
rowtype[2] = "select";
|
862
|
rowsize[2] = "1";
|
863
|
rowname[3] = "size";
|
864
|
rowtype[3] = "textbox";
|
865
|
rowsize[3] = "8";
|
866
|
rowname[4] = "encpass";
|
867
|
rowtype[4] = "textbox";
|
868
|
rowsize[4] = "8";
|
869
|
field_counter_js = 5;
|
870
|
rows = 1;
|
871
|
totalrows = 1;
|
872
|
loaded = 1;
|
873
|
rowhelper_onChange = " onChange='javascript:row_helper_dynamic_custom()' ";
|
874
|
rowhelper_onDelete = "row_helper_dynamic_custom(); ";
|
875
|
rowhelper_onAdd = "row_helper_dynamic_custom();";
|
876
|
</script>
|
877
|
<form action="installer.php" method="post">
|
878
|
<input type="hidden" name="state" value="verify_before_install">
|
879
|
<div id="mainlevel">
|
880
|
<center>
|
881
|
<table width="100%" border="0" cellpadding="5" cellspacing="0">
|
882
|
<tr>
|
883
|
<td>
|
884
|
<center>
|
885
|
<div id="mainarea">
|
886
|
<center>
|
887
|
<table width="100%" border="0" cellpadding="5" cellspacing="5">
|
888
|
<tr>
|
889
|
<td>
|
890
|
<div id="pfsenseinstaller">
|
891
|
<center>
|
892
|
<div id='loadingdiv'>
|
893
|
<table>
|
894
|
<tr>
|
895
|
<td valign="center">
|
896
|
<img src="/themes/{$g['theme']}/images/misc/loader.gif">
|
897
|
</td>
|
898
|
<td valign="center">
|
899
|
Probing disks, please wait...
|
900
|
</td>
|
901
|
</tr>
|
902
|
</table>
|
903
|
</div>
|
904
|
EOF;
|
905
|
ob_flush();
|
906
|
// Read bootmanager setting from disk if found
|
907
|
if(file_exists("/tmp/webInstaller_disk_bootmanager.txt"))
|
908
|
$bootmanager = unserialize(file_get_contents("/tmp/webInstaller_disk_bootmanager.txt"));
|
909
|
if($bootmanager == "none")
|
910
|
$noneselected = " SELECTED";
|
911
|
if($bootmanager == "bsd")
|
912
|
$bsdeselected = " SELECTED";
|
913
|
if(!$disks) {
|
914
|
$custom_txt = gettext("ERROR: Could not find any suitable disks for installation.");
|
915
|
} else {
|
916
|
// Prepare disk selection dropdown
|
917
|
$custom_txt = <<<EOF
|
918
|
<center>
|
919
|
<table>
|
920
|
<tr>
|
921
|
<td align='right'>
|
922
|
Boot manager:
|
923
|
</td>
|
924
|
<td>
|
925
|
<select name='bootmanager'>
|
926
|
<option value='none' $noneselected>
|
927
|
None
|
928
|
</option>
|
929
|
<option value='bsd' $bsdeselected>
|
930
|
BSD
|
931
|
</option>
|
932
|
</select>
|
933
|
</td>
|
934
|
</tr>
|
935
|
</table>
|
936
|
<hr>
|
937
|
<table id='maintable'><tbody>
|
938
|
<tr>
|
939
|
<td align="middle">
|
940
|
<b>Mount</b>
|
941
|
</td>
|
942
|
<td align='middle'>
|
943
|
<b>Filesysytem</b>
|
944
|
</td>
|
945
|
<td align="middle">
|
946
|
<b>Disk</b>
|
947
|
</td>
|
948
|
<td align="middle">
|
949
|
<b>Size</b>
|
950
|
</td>
|
951
|
<td align="middle">
|
952
|
<b>Encryption password</b>
|
953
|
</td>
|
954
|
<td>
|
955
|
|
956
|
</td>
|
957
|
</tr>
|
958
|
<tr>
|
959
|
|
960
|
EOF;
|
961
|
|
962
|
// Calculate swap disk sizes
|
963
|
$memory = get_memory();
|
964
|
$swap_size = $memory[0] * 2;
|
965
|
$first_disk = trim(installer_find_first_disk());
|
966
|
$disk_info = pcsysinstall_get_disk_info($first_disk);
|
967
|
$size = $disk_info['size'];
|
968
|
$first_disk_size = $size - $swap_size;
|
969
|
|
970
|
// Debugging
|
971
|
echo "\n\n<!-- $first_disk - " . print_r($disk_info, true) . " - $size - $first_disk_size -->\n\n";
|
972
|
|
973
|
// Check to see if a on disk layout exists
|
974
|
if(file_exists("/tmp/webInstaller_disk_layout.txt")) {
|
975
|
$disks_restored = unserialize(file_get_contents("/tmp/webInstaller_disk_layout.txt"));
|
976
|
$restored_layout_from_file = true;
|
977
|
$restored_layout_txt = "<br />* The previous disk layout was restored from a previous session";
|
978
|
}
|
979
|
|
980
|
// If we restored disk layout(s) from a file then build the rows
|
981
|
if($restored_layout_from_file == true) {
|
982
|
$diskcounter = 0;
|
983
|
foreach($disks_restored as $dr) {
|
984
|
$custom_txt .= return_rowhelper_row("$diskcounter", $dr['mountpoint'], $dr['fstype'], $dr['disk'], $dr['size'], $dr['encpass']);
|
985
|
$diskcounter++;
|
986
|
}
|
987
|
} else {
|
988
|
// Construct the default rows that outline the disks configuration.
|
989
|
$custom_txt .= return_rowhelper_row("0", "/", "UFS+S", $first_disk, "{$first_disk_size}", "");
|
990
|
$custom_txt .= return_rowhelper_row("1", "none", "SWAP", $first_disk, "$swap_size", "");
|
991
|
}
|
992
|
|
993
|
// tfoot and tbody are used by rowhelper
|
994
|
$custom_txt .= "</tr>";
|
995
|
$custom_txt .= "<tfoot></tfoot></tbody>";
|
996
|
// Total allocation box
|
997
|
$custom_txt .= "<tr><td></td><td></td><td align='right'>Total allocated:</td><td><input style='border:0px; background-color: #FFFFFF;' size='8' id='totalsize' name='totalsize'></td>";
|
998
|
// Add row button
|
999
|
$custom_txt .= "</td><td> </td><td>";
|
1000
|
$custom_txt .= "<div id=\"addrowbutton\">";
|
1001
|
$custom_txt .= "<a onclick=\"javascript:addRowTo('maintable', 'formfldalias'); return false;\" href=\"#\">";
|
1002
|
$custom_txt .= "<img border=\"0\" src=\"/themes/{$g['theme']}/images/icons/icon_plus.gif\" alt=\"\" title=\"add another entry\" /></a>";
|
1003
|
$custom_txt .= "</div>";
|
1004
|
$custom_txt .= "</td></tr>";
|
1005
|
// Disk capacity box
|
1006
|
$custom_txt .= "<tr><td></td><td></td><td align='right'>Disk(s) capacity total:</td><td><input style='border:0px; background-color: #FFFFFF;' size='8' id='disktotals' name='disktotals'></td></tr>";
|
1007
|
// Remaining allocation box
|
1008
|
$custom_txt .= "<tr><td></td><td></td><td align='right'>Available space for allocation:</td><td><input style='border:0px; background-color: #FFFFFF;' size='8' id='availalloc' name='availalloc'></td></tr>";
|
1009
|
$custom_txt .= "</table>";
|
1010
|
$custom_txt .= "<script type=\"text/javascript\">row_helper_dynamic_custom();</script>";
|
1011
|
}
|
1012
|
echo <<<EOF
|
1013
|
|
1014
|
<tr>
|
1015
|
<td colspan='4'>
|
1016
|
<script type="text/javascript">
|
1017
|
\$('#loadingdiv').css('visibility','hidden');
|
1018
|
</script>
|
1019
|
<div id='contentdiv' style="display:none;">
|
1020
|
<p/>
|
1021
|
{$custom_txt}<p/>
|
1022
|
<hr><p/>
|
1023
|
<input type="button" value="Cancel" onClick="javascript:document.location='/installer/installer.php';">  
|
1024
|
<input type="submit" value="Next">
|
1025
|
</div>
|
1026
|
<script type="text/javascript">
|
1027
|
var encryption_warning_shown = false;
|
1028
|
\$('#contentdiv').fadeIn();
|
1029
|
row_helper_dynamic_custom();
|
1030
|
</script>
|
1031
|
</center>
|
1032
|
</td></tr>
|
1033
|
</table>
|
1034
|
</div>
|
1035
|
</td>
|
1036
|
</tr>
|
1037
|
</table>
|
1038
|
</center>
|
1039
|
<span class="vexpl">
|
1040
|
<span class="red">
|
1041
|
<strong>
|
1042
|
NOTES:
|
1043
|
</strong>
|
1044
|
</span>
|
1045
|
<br />* Sizes are in megabytes.
|
1046
|
<br />* Mount points named /conf are not allowed. Use /cf if you want to make a configuration slice/mount.
|
1047
|
{$restored_layout_txt}
|
1048
|
</span>
|
1049
|
</strong>
|
1050
|
</div>
|
1051
|
</td>
|
1052
|
</tr>
|
1053
|
</table>
|
1054
|
</div>
|
1055
|
</center>
|
1056
|
<script type="text/javascript">
|
1057
|
<!--
|
1058
|
newrow[1] = "{$select_txt}";
|
1059
|
newrow[2] = "{$custom_disks}";
|
1060
|
-->
|
1061
|
</script>
|
1062
|
|
1063
|
|
1064
|
EOF;
|
1065
|
page_table_end();
|
1066
|
end_html();
|
1067
|
}
|
1068
|
|
1069
|
function installer_main() {
|
1070
|
global $g, $fstype, $savemsg;
|
1071
|
if(file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log"))
|
1072
|
unlink("/tmp/.pc-sysinstall/pc-sysinstall.log");
|
1073
|
head_html();
|
1074
|
body_html();
|
1075
|
$disk = installer_find_first_disk();
|
1076
|
// Only enable ZFS if this exists. The install will fail otherwise.
|
1077
|
if(file_exists("/boot/gptzfsboot"))
|
1078
|
$zfs_enabled = "<tr bgcolor=\"#9A9A9A\"><td align=\"center\"><a href=\"installer.php?state=easy_install_zfs\">Easy installation of {$g['product_name']} using the ZFS filesystem on disk {$disk}</a></td></tr>";
|
1079
|
page_table_start();
|
1080
|
echo <<<EOF
|
1081
|
<form action="installer.php" method="post" state="step1_post">
|
1082
|
<div id="mainlevel">
|
1083
|
<center>
|
1084
|
<b><font face="arial" size="+2">Welcome to the {$g['product_name']} webInstaller!</b></font><p/>
|
1085
|
<font face="arial" size="+1">This utility will install {$g['product_name']} to a hard disk, flash drive, etc.</font>
|
1086
|
<table width="100%" border="0" cellpadding="5" cellspacing="0">
|
1087
|
<tr>
|
1088
|
<td>
|
1089
|
<center>
|
1090
|
<div id="mainarea">
|
1091
|
<br />
|
1092
|
<center>
|
1093
|
Please select an installer option to begin:
|
1094
|
<p/>
|
1095
|
<table width="100%" border="0" cellpadding="5" cellspacing="5">
|
1096
|
<tr>
|
1097
|
<td>
|
1098
|
<div id="pfsenseinstaller">
|
1099
|
<center>
|
1100
|
EOF;
|
1101
|
if(!$disk) {
|
1102
|
echo gettext("ERROR: Could not find any suitable disks for installation.");
|
1103
|
echo "</div></td></tr></table></div></table></div>";
|
1104
|
end_html();
|
1105
|
exit;
|
1106
|
}
|
1107
|
echo <<<EOF
|
1108
|
|
1109
|
<table cellspacing="5" cellpadding="5" style="border: 1px dashed;">
|
1110
|
<tr bgcolor="#CECECE"><td align="center">
|
1111
|
<a href="installer.php?state=easy_install_ufs">Easy installation of {$g['product_name']} using the UFS filesystem on disk {$disk}</a>
|
1112
|
</td></tr>
|
1113
|
{$zfs_enabled}
|
1114
|
<tr bgcolor="#AAAAAA"><td align="center">
|
1115
|
<a href="installer.php?state=custominstall">Custom installation of {$g['product_name']}</a>
|
1116
|
</td></tr>
|
1117
|
<tr bgcolor="#CECECE"><td align="center">
|
1118
|
<a href='/'>Cancel and return to Dashboard</a>
|
1119
|
</td></tr>
|
1120
|
</table>
|
1121
|
</center>
|
1122
|
</div>
|
1123
|
</td>
|
1124
|
</tr>
|
1125
|
</table>
|
1126
|
</div>
|
1127
|
</td>
|
1128
|
</tr>
|
1129
|
</table>
|
1130
|
</div>
|
1131
|
EOF;
|
1132
|
page_table_end();
|
1133
|
end_html();
|
1134
|
}
|
1135
|
|
1136
|
function return_rowhelper_row($rownum, $mountpoint, $fstype, $disk, $size, $encpass) {
|
1137
|
global $g, $select_txt, $custom_disks, $savemsg;
|
1138
|
$release = php_uname("r");
|
1139
|
$release = trim($release[0]);
|
1140
|
|
1141
|
// Mount point
|
1142
|
$disks = installer_find_all_disks();
|
1143
|
$custom_txt .= "<tr>";
|
1144
|
$custom_txt .= "<td><input size='8' id='mountpoint{$rownum}' name='mountpoint{$rownum}' value='{$mountpoint}'></td>";
|
1145
|
|
1146
|
// Filesystem type array
|
1147
|
$types = array(
|
1148
|
'UFS' => 'UFS',
|
1149
|
'UFS+S' => 'UFS + Softupdates',
|
1150
|
'UFS.eli' => 'Encrypted UFS',
|
1151
|
'UFS+S.eli' => 'Encrypted UFS + Softupdates',
|
1152
|
'SWAP' => 'SWAP'
|
1153
|
);
|
1154
|
|
1155
|
// UFS + Journaling was introduced in 9.0
|
1156
|
if($release == "9") {
|
1157
|
$types['UFS+J'] = "UFS + Journaling";
|
1158
|
$types['UFS+J.eli'] = "Encrypted UFS + Journaling";
|
1159
|
}
|
1160
|
|
1161
|
// Add ZFS Boot loader if it exists
|
1162
|
if(file_exists("/boot/gptzfsboot")) {
|
1163
|
$types['ZFS'] = "Zetabyte Filesystem";
|
1164
|
$types['ZFS.eli'] = "Encrypted Zetabyte Filesystem";
|
1165
|
}
|
1166
|
|
1167
|
// fstype form field
|
1168
|
$custom_txt .= "<td><select onChange='javascript:row_helper_dynamic_custom()' id='fstype{$rownum}' name='fstype{$rownum}'>";
|
1169
|
$select_txt = "";
|
1170
|
foreach($types as $type => $desc) {
|
1171
|
if($type == $fstype)
|
1172
|
$SELECTED="SELECTED";
|
1173
|
else
|
1174
|
$SELECTED="";
|
1175
|
$select_txt .= "<option value='$type' $SELECTED>$desc</option>";
|
1176
|
}
|
1177
|
$custom_txt .= "{$select_txt}</select>\n";
|
1178
|
$custom_txt .= "</td>";
|
1179
|
|
1180
|
// Disk selection form field
|
1181
|
$custom_txt .= "<td><select id='disk{$rownum}' name='disk{$rownum}'>\n";
|
1182
|
$custom_disks = "";
|
1183
|
foreach($disks as $dsk) {
|
1184
|
$disksize_bytes = format_bytes($dsk['size'] * 1048576);
|
1185
|
$disksize = $dsk['size'];
|
1186
|
if($disk == $dsk['disk'])
|
1187
|
$SELECTED="SELECTED";
|
1188
|
else
|
1189
|
$SELECTED="";
|
1190
|
$custom_disks .= "<option value='{$dsk['disk']}' $SELECTED>{$dsk['disk']} - {$dsk['desc']} - {$disksize}MB ({$disksize_bytes})</option>";
|
1191
|
}
|
1192
|
$custom_txt .= "{$custom_disks}</select></td>\n";
|
1193
|
|
1194
|
// Slice size
|
1195
|
$custom_txt .= "<td><input onChange='javascript:row_helper_dynamic_custom();' name='size{$rownum}' id='size{$rownum}' size='8' type='text' value='{$size}'></td>";
|
1196
|
|
1197
|
// Encryption password
|
1198
|
$custom_txt .= "<td>";
|
1199
|
$custom_txt .= "<input id='encpass{$rownum}' name='encpass{$rownum}' size='8' value='{$encpass}'>";
|
1200
|
$custom_txt .= "</td>";
|
1201
|
|
1202
|
// Add Rowhelper + button
|
1203
|
if($rownum > 0)
|
1204
|
$custom_txt .= "<td><a onclick=\"removeRow(this); return false;\" href=\"#\"><img border=\"0\" src=\"/themes/{$g['theme']}/images/icons/icon_x.gif\" alt=\"\" title=\"remove this entry\"/></a></td>";
|
1205
|
|
1206
|
$custom_txt .= "</tr>";
|
1207
|
return $custom_txt;
|
1208
|
}
|
1209
|
|
1210
|
?>
|