1
|
<?php
|
2
|
/*
|
3
|
installer.php
|
4
|
part of pfSense (http://www.pfsense.com/)
|
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
|
require("globals.inc");
|
31
|
require("guiconfig.inc");
|
32
|
|
33
|
define('PC_SYSINSTALL', '/usr/sbin/pc-sysinstall/pc-sysinstall');
|
34
|
|
35
|
if($g['platform'] == "pfSense" or $g['platform'] == "nanobsd") {
|
36
|
Header("Location: /index.php");
|
37
|
exit;
|
38
|
}
|
39
|
|
40
|
// Main switch dispatcher
|
41
|
switch ($_REQUEST['state']) {
|
42
|
case "update_installer_status":
|
43
|
update_installer_status();
|
44
|
exit;
|
45
|
case "custominstall":
|
46
|
installer_custom();
|
47
|
exit;
|
48
|
case "begin_install":
|
49
|
installing_gui();
|
50
|
begin_install();
|
51
|
exit;
|
52
|
case "verify_before_install":
|
53
|
verify_before_install();
|
54
|
exit;
|
55
|
default:
|
56
|
installer_main();
|
57
|
}
|
58
|
|
59
|
function write_out_pc_sysinstaller_config($disk, $fstype = "UFS+S") {
|
60
|
$fd = fopen("/usr/sbin/pc-sysinstall/examples/pfSense-install.cfg", "w");
|
61
|
if(!$fd) {
|
62
|
return true;
|
63
|
}
|
64
|
$config = <<<EOF
|
65
|
# Sample configuration file for an installation using pc-sysinstall
|
66
|
|
67
|
installMode=fresh
|
68
|
installInteractive=yes
|
69
|
installType=FreeBSD
|
70
|
installMedium=LiveCD
|
71
|
|
72
|
# Set the disk parameters
|
73
|
disk0={$disk}
|
74
|
partition=all
|
75
|
bootManager=bsd
|
76
|
commitDiskPart
|
77
|
|
78
|
# Setup the disk label
|
79
|
# All sizes are expressed in MB
|
80
|
# Avail FS Types, UFS, UFS+S, UFS+J, ZFS, SWAP
|
81
|
# Size 0 means use the rest of the slice size
|
82
|
disk0-part={$fstype} 0 /
|
83
|
# Do it now!
|
84
|
commitDiskLabel
|
85
|
|
86
|
# Set if we are installing via optical, USB, or FTP
|
87
|
installType=FreeBSD
|
88
|
|
89
|
packageType=cpdup
|
90
|
|
91
|
# Optional Components
|
92
|
cpdupPaths=boot,COPYRIGHT,bin,conf,conf.default,dev,etc,home,kernels,libexec,lib,root,sbin,sys,usr,var
|
93
|
|
94
|
# runExtCommand=chmod a+rx /usr/local/bin/after_installation_routines.sh ; cd / ; /usr/local/bin/after_installation_routines.sh
|
95
|
EOF;
|
96
|
fwrite($fd, $config);
|
97
|
fclose($fd);
|
98
|
return;
|
99
|
}
|
100
|
|
101
|
function start_installation() {
|
102
|
global $g, $fstype;
|
103
|
if(file_exists("/tmp/install_complete"))
|
104
|
return;
|
105
|
$ps_running = exec("ps awwwux | grep -v grep | grep 'sh /tmp/installer.sh'");
|
106
|
if($ps_running)
|
107
|
return;
|
108
|
$fd = fopen("/tmp/installer.sh", "w");
|
109
|
if(!$fd) {
|
110
|
die(gettext("Could not open /tmp/installer.sh for writing"));
|
111
|
exit;
|
112
|
}
|
113
|
fwrite($fd, "rm /tmp/.pc-sysinstall/pc-sysinstall.log 2>/dev/null\n");
|
114
|
fwrite($fd, "/usr/sbin/pc-sysinstall/pc-sysinstall -c /usr/sbin/pc-sysinstall/examples/pfSense-install.cfg \n");
|
115
|
fwrite($fd, "chmod a+rx /usr/local/bin/after_installation_routines.sh\n");
|
116
|
fwrite($fd, "cd / && /usr/local/bin/after_installation_routines.sh\n");
|
117
|
fwrite($fd, "mkdir /mnt/tmp\n");
|
118
|
// fwrite($fd, "umount /mnt\n");
|
119
|
fwrite($fd, "touch /tmp/install_complete\n");
|
120
|
fclose($fd);
|
121
|
exec("chmod a+rx /tmp/installer.sh");
|
122
|
mwexec_bg("sh /tmp/installer.sh");
|
123
|
}
|
124
|
|
125
|
function installer_find_first_disk() {
|
126
|
global $g, $fstype;
|
127
|
$disk = `/usr/sbin/pc-sysinstall/pc-sysinstall disk-list | head -n1 | cut -d':' -f1`;
|
128
|
return $disk;
|
129
|
}
|
130
|
|
131
|
function pcsysinstall_get_disk_info($diskname) {
|
132
|
global $g, $fstype;
|
133
|
$disk = split("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall disk-list`);
|
134
|
$disks_array = array();
|
135
|
foreach($disk as $d) {
|
136
|
if(!$d)
|
137
|
continue;
|
138
|
$disks_info = split(":", $d);
|
139
|
$tmp_array = array();
|
140
|
if($disks_info[0] == $diskname) {
|
141
|
$disk_info = split("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall disk-info {$disks_info[0]}`);
|
142
|
foreach($disk_info as $di) {
|
143
|
$di_s = split("=", $di);
|
144
|
if($di_s[0])
|
145
|
$tmp_array[$di_s[0]] = $di_s[1];
|
146
|
}
|
147
|
$tmp_array['disk'] = trim($disks_info[0]);
|
148
|
$tmp_array['desc'] = trim(htmlentities($disks_info[1]));
|
149
|
return $tmp_array;
|
150
|
}
|
151
|
}
|
152
|
}
|
153
|
|
154
|
// Return an array with all disks information.
|
155
|
function installer_find_all_disks() {
|
156
|
global $g, $fstype;
|
157
|
$disk = split("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall disk-list`);
|
158
|
$disks_array = array();
|
159
|
foreach($disk as $d) {
|
160
|
if(!$d)
|
161
|
continue;
|
162
|
$disks_info = split(":", $d);
|
163
|
$tmp_array = array();
|
164
|
$disk_info = split("\n", `/usr/sbin/pc-sysinstall/pc-sysinstall disk-info {$disks_info[0]}`);
|
165
|
foreach($disk_info as $di) {
|
166
|
$di_s = split("=", $di);
|
167
|
if($di_s[0])
|
168
|
$tmp_array[$di_s[0]] = $di_s[1];
|
169
|
}
|
170
|
$tmp_array['disk'] = trim($disks_info[0]);
|
171
|
$tmp_array['desc'] = trim(htmlentities($disks_info[1]));
|
172
|
$disks_array[] = $tmp_array;
|
173
|
}
|
174
|
return $disks_array;
|
175
|
}
|
176
|
|
177
|
function update_installer_status() {
|
178
|
global $g, $fstype;
|
179
|
// Ensure status files exist
|
180
|
if(!file_exists("/tmp/installer_installer_running"))
|
181
|
touch("/tmp/installer_installer_running");
|
182
|
$status = `cat /tmp/.pc-sysinstall/pc-sysinstall.log`;
|
183
|
$status = str_replace("\n", "\\n", $status);
|
184
|
$status = str_replace("\n", "\\r", $status);
|
185
|
echo "this.document.forms[0].installeroutput.value='$status';\n";
|
186
|
echo "this.document.forms[0].installeroutput.scrollTop = this.document.forms[0].installeroutput.scrollHeight;\n";
|
187
|
// Find out installer progress
|
188
|
$progress = "5";
|
189
|
if(strstr($status, "Running: dd"))
|
190
|
$progress = "6";
|
191
|
if(strstr($status, "Running: gpart create -s GPT"))
|
192
|
$progress = "7";
|
193
|
if(strstr($status, "Running: gpart bootcode"))
|
194
|
$progress = "7";
|
195
|
if(strstr($status, "Running: newfs -U"))
|
196
|
$progress = "8";
|
197
|
if(strstr($status, "Running: sync"))
|
198
|
$progress = "9";
|
199
|
if(strstr($status, "/boot /mnt/boot"))
|
200
|
$progress = "10";
|
201
|
if(strstr($status, "/COPYRIGHT /mnt/COPYRIGHT"))
|
202
|
$progress = "11";
|
203
|
if(strstr($status, "/bin /mnt/bin"))
|
204
|
$progress = "12";
|
205
|
if(strstr($status, "/conf /mnt/conf"))
|
206
|
$progress = "15";
|
207
|
if(strstr($status, "/conf.default /mnt/conf.default"))
|
208
|
$progress = "20";
|
209
|
if(strstr($status, "/dev /mnt/dev"))
|
210
|
$progress = "25";
|
211
|
if(strstr($status, "/etc /mnt/etc"))
|
212
|
$progress = "30";
|
213
|
if(strstr($status, "/home /mnt/home"))
|
214
|
$progress = "35";
|
215
|
if(strstr($status, "/kernels /mnt/kernels"))
|
216
|
$progress = "40";
|
217
|
if(strstr($status, "/libexec /mnt/libexec"))
|
218
|
$progress = "50";
|
219
|
if(strstr($status, "/lib /mnt/lib"))
|
220
|
$progress = "60";
|
221
|
if(strstr($status, "/root /mnt/root"))
|
222
|
$progress = "70";
|
223
|
if(strstr($status, "/sbin /mnt/sbin"))
|
224
|
$progress = "75";
|
225
|
if(strstr($status, "/sys /mnt/sys"))
|
226
|
$progress = "80";
|
227
|
if(strstr($status, "/usr /mnt/usr"))
|
228
|
$progress = "95";
|
229
|
if(strstr($status, "/usr /mnt/usr"))
|
230
|
$progress = "90";
|
231
|
if(strstr($status, "/var /mnt/var"))
|
232
|
$progress = "95";
|
233
|
if(strstr($status, "cap_mkdb /etc/login.conf"))
|
234
|
$progress = "96";
|
235
|
if(strstr($status, "Setting hostname"))
|
236
|
$progress = "97";
|
237
|
if(strstr($status, "umount -f /mnt"))
|
238
|
$progress = "98";
|
239
|
if(strstr($status, "umount -f /mnt"))
|
240
|
$progress = "99";
|
241
|
if(strstr($status, "Installation finished"))
|
242
|
$progress = "100";
|
243
|
// Check for error and bail if we see one.
|
244
|
if(stristr($status, "error")) {
|
245
|
$error = true;
|
246
|
echo "\$('installerrunning').innerHTML='<img class=\"infoboxnpimg\" src=\"/themes/{$g['theme']}/images/icons/icon_exclam.gif\"> <font size=\"2\"><b>An error occurred. Aborting installation.'; ";
|
247
|
echo "\$('progressbar').style.width='100%';\n";
|
248
|
unlink("/tmp/install_complete");
|
249
|
return;
|
250
|
}
|
251
|
$running_old = trim(file_get_contents("/tmp/installer_installer_running"));
|
252
|
if($installer_running <> "running") {
|
253
|
$ps_running = exec("ps awwwux | grep -v grep | grep 'sh /tmp/installer.sh'");
|
254
|
if($ps_running) {
|
255
|
$running = "\$('installerrunning').innerHTML='<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>'; ";
|
256
|
if($running_old <> $running) {
|
257
|
echo $running;
|
258
|
file_put_contents("/tmp/installer_installer_running", "$running");
|
259
|
}
|
260
|
}
|
261
|
}
|
262
|
if($progress)
|
263
|
echo "\$('progressbar').style.width='{$progress}%';\n";
|
264
|
if(file_exists("/tmp/install_complete")) {
|
265
|
echo "\$('installerrunning').innerHTML='<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";
|
266
|
echo "\$('pbdiv').Fade();\n";
|
267
|
unlink_if_exists("/tmp/installer.sh");
|
268
|
file_put_contents("/tmp/installer_installer_running", "finished");
|
269
|
}
|
270
|
}
|
271
|
|
272
|
function update_installer_status_win($status) {
|
273
|
global $g, $fstype;
|
274
|
echo "<script type=\"text/javascript\">\n";
|
275
|
echo " \$('installeroutput').value = '" . str_replace(htmlentities($status), "\n", "") . "';\n";
|
276
|
echo "</script>";
|
277
|
}
|
278
|
|
279
|
function begin_install() {
|
280
|
global $g;
|
281
|
if(file_exists("/tmp/install_complete"))
|
282
|
return;
|
283
|
unlink_if_exists("/tmp/install_complete");
|
284
|
if($_REQUEST['disk'])
|
285
|
$disk = $_REQUEST['disk'];
|
286
|
else
|
287
|
$disk = installer_find_first_disk();
|
288
|
if(!$disk) {
|
289
|
echo "<script type=\"text/javascript\">";
|
290
|
echo "\$('pbdiv').Fade();\n";
|
291
|
echo "</script>";
|
292
|
$savemsg = gettext("Could not find a suitable disk for installation");
|
293
|
update_installer_status_win(gettext("Could not find a suitable disk for installation."));
|
294
|
return;
|
295
|
}
|
296
|
// Handle other type of file systems
|
297
|
if($_REQUEST['fstype'])
|
298
|
$fstype = strtoupper($_REQUEST['fstype']);
|
299
|
else
|
300
|
$fstype = "UFS+S";
|
301
|
write_out_pc_sysinstaller_config($disk, $fstype);
|
302
|
update_installer_status_win(sprintf(gettext("Beginning installation on disk %s."),$disk));
|
303
|
start_installation();
|
304
|
}
|
305
|
|
306
|
function head_html() {
|
307
|
global $g, $fstype;
|
308
|
echo <<<EOF
|
309
|
<html>
|
310
|
<head>
|
311
|
<style type='text/css'>
|
312
|
a:link {
|
313
|
color: #000000;
|
314
|
text-decoration:underline;
|
315
|
font-size:14;
|
316
|
}
|
317
|
a:visited {
|
318
|
color: #000000;
|
319
|
text-decoration:underline;
|
320
|
font-size:14;
|
321
|
}
|
322
|
a:hover {
|
323
|
color: #FFFF00;
|
324
|
text-decoration: none;
|
325
|
font-size:14;
|
326
|
}
|
327
|
a:active {
|
328
|
color: #FFFF00;
|
329
|
text-decoration:underline;
|
330
|
font-size:14;
|
331
|
}
|
332
|
</style>
|
333
|
</head>
|
334
|
EOF;
|
335
|
|
336
|
}
|
337
|
|
338
|
function body_html() {
|
339
|
global $g, $fstype;
|
340
|
$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
|
341
|
if(strstr($pfSversion, "1.2"))
|
342
|
$one_two = true;
|
343
|
$pgtitle = "{$g['product_name']}: " . gettext("Installer");
|
344
|
include("head.inc");
|
345
|
echo <<<EOF
|
346
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
347
|
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
|
348
|
<script type="text/javascript">
|
349
|
function getinstallerprogress() {
|
350
|
url = 'installer.php';
|
351
|
pars = 'state=update_installer_status';
|
352
|
callajax(url, pars, installcallback);
|
353
|
}
|
354
|
function callajax(url, pars, activitycallback) {
|
355
|
var myAjax = new Ajax.Request(
|
356
|
url,
|
357
|
{
|
358
|
method: 'post',
|
359
|
parameters: pars,
|
360
|
onComplete: activitycallback
|
361
|
});
|
362
|
}
|
363
|
function installcallback(transport) {
|
364
|
setTimeout('getinstallerprogress()', 2000);
|
365
|
eval(transport.responseText);
|
366
|
}
|
367
|
</script>
|
368
|
EOF;
|
369
|
|
370
|
if($one_two)
|
371
|
echo "<p class=\"pgtitle\">{$pgtitle}</font></p>";
|
372
|
|
373
|
if ($savemsg) print_info_box($savemsg);
|
374
|
}
|
375
|
|
376
|
function end_html() {
|
377
|
global $g, $fstype;
|
378
|
echo "</form>";
|
379
|
echo "</body>";
|
380
|
echo "</html>";
|
381
|
}
|
382
|
|
383
|
function template() {
|
384
|
global $g, $fstype;
|
385
|
head_html();
|
386
|
body_html();
|
387
|
echo <<<EOF
|
388
|
<div id="mainlevel">
|
389
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
390
|
<tr>
|
391
|
<td>
|
392
|
<div id="mainarea">
|
393
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
394
|
<tr>
|
395
|
<td class="tabcont" >
|
396
|
<form action="installer.php" method="post">
|
397
|
<div id="pfsensetemplate">
|
398
|
|
399
|
|
400
|
</div>
|
401
|
</td>
|
402
|
</tr>
|
403
|
</table>
|
404
|
</div>
|
405
|
</td>
|
406
|
</tr>
|
407
|
</table>
|
408
|
</div>
|
409
|
EOF;
|
410
|
end_html();
|
411
|
}
|
412
|
|
413
|
function verify_before_install() {
|
414
|
global $g, $fstype;
|
415
|
head_html();
|
416
|
body_html();
|
417
|
page_table_start();
|
418
|
$disk = pcsysinstall_get_disk_info($_REQUEST['disk']);
|
419
|
$disksize = format_bytes($disk['size'] * 1048576);
|
420
|
echo <<<EOF
|
421
|
<form method="post" action="installer.php">
|
422
|
<input type="hidden" name="fstype" value="{$_REQUEST['fstype']}">
|
423
|
<input type="hidden" name="disk" value="{$_REQUEST['disk']}">
|
424
|
<input type="hidden" name="state" value="begin_install">
|
425
|
<div id="mainlevel">
|
426
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
427
|
<tr>
|
428
|
<td>
|
429
|
<div id="mainarea">
|
430
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
431
|
<tr>
|
432
|
<td >
|
433
|
<div>
|
434
|
<center>
|
435
|
<div id="pfsensetemplate">
|
436
|
<table bgcolor="FFFF00" width="400" height="30" cellpadding="2" style="border:1px dashed;">
|
437
|
<tr valign="middle">
|
438
|
<td>
|
439
|
<center><b>Please verify that the following is correct:</b></center>
|
440
|
</td>
|
441
|
</tr>
|
442
|
</table>
|
443
|
<p/>
|
444
|
<table>
|
445
|
<tr><td align="right"><b>Disk:</td><td>{$_REQUEST['disk']}</td></tr>
|
446
|
<tr><td align="right"><b>Description:</td><td>{$disk['desc']}</td></tr>
|
447
|
<tr><td align="right"><b>Size:</td><td>{$disksize}</td></tr>
|
448
|
<tr><td align="right"><b>Filesystem:</td><td>{$_REQUEST['fstype']}</td></tr>
|
449
|
</table>
|
450
|
</div>
|
451
|
</center>
|
452
|
</div>
|
453
|
</td>
|
454
|
</tr>
|
455
|
</table>
|
456
|
</div>
|
457
|
<center>
|
458
|
<p/>
|
459
|
<input type="button" value="Cancel" onClick="javascript:document.location='/installer.php';">
|
460
|
<input type="submit" value="Begin installation">
|
461
|
</center>
|
462
|
</td>
|
463
|
</tr>
|
464
|
</table>
|
465
|
</div>
|
466
|
EOF;
|
467
|
page_table_end();
|
468
|
end_html();
|
469
|
}
|
470
|
|
471
|
function installing_gui() {
|
472
|
global $g, $fstype;
|
473
|
head_html();
|
474
|
body_html();
|
475
|
echo "<form action=\"installer.php\" method=\"post\" state=\"step1_post\">";
|
476
|
page_table_start();
|
477
|
echo <<<EOF
|
478
|
<center>
|
479
|
<table width="100%">
|
480
|
<tr><td>
|
481
|
<div id="mainlevel">
|
482
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
483
|
<tr>
|
484
|
<td>
|
485
|
<div id="mainarea">
|
486
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
487
|
<tr>
|
488
|
<td>
|
489
|
<div id="pfsenseinstaller" width="100%">
|
490
|
<div id='installerrunning' width='100%' style="padding:8px; border:1px dashed #000000">
|
491
|
<table>
|
492
|
<tr>
|
493
|
<td valign="middle">
|
494
|
<img src="/themes/{$g['theme']}/images/misc/loader.gif">
|
495
|
</td>
|
496
|
<td valign="middle">
|
497
|
<font size="2"><b>Starting Installer... Please wait...
|
498
|
</td>
|
499
|
</tr>
|
500
|
</table>
|
501
|
</div>
|
502
|
<div id='pbdiv'>
|
503
|
<br/>
|
504
|
<center>
|
505
|
<table id='pbtable' height='15' width='640' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
|
506
|
<tr>
|
507
|
<td background="./themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
|
508
|
</td>
|
509
|
<td>
|
510
|
<table id="progholder" name="progholder" height='15' width='630' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
|
511
|
<td background="./themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
|
512
|
<img src='./themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
|
513
|
</td>
|
514
|
</table>
|
515
|
</td>
|
516
|
<td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
|
517
|
</td>
|
518
|
</tr>
|
519
|
</table>
|
520
|
<br/>
|
521
|
</div>
|
522
|
<textarea name='installeroutput' id='installeroutput' rows="31" cols="90">
|
523
|
</textarea>
|
524
|
</div>
|
525
|
</td>
|
526
|
</tr>
|
527
|
</table>
|
528
|
</div>
|
529
|
</td>
|
530
|
</tr>
|
531
|
</table>
|
532
|
</div>
|
533
|
</td></tr>
|
534
|
</table>
|
535
|
</center>
|
536
|
<script type="text/javascript">setTimeout('getinstallerprogress()', 250);</script>
|
537
|
|
538
|
EOF;
|
539
|
page_table_end();
|
540
|
end_html();
|
541
|
}
|
542
|
|
543
|
function page_table_start() {
|
544
|
global $g, $fstype;
|
545
|
echo <<<EOF
|
546
|
<center>
|
547
|
<img border="0" src="./themes/{$g['theme']}/images/logo.gif"></a><br/>
|
548
|
<table cellpadding="6" cellspacing="0" width="550" height="380" style="border:1px solid #000000">
|
549
|
<tr height="10" bgcolor="#990000">
|
550
|
<td style="border-bottom:1px solid #000000">
|
551
|
<font color='white'>
|
552
|
<b>
|
553
|
{$g['product_name']} installer
|
554
|
</b>
|
555
|
</font>
|
556
|
</td>
|
557
|
</tr>
|
558
|
<tr>
|
559
|
<td>
|
560
|
|
561
|
EOF;
|
562
|
|
563
|
}
|
564
|
|
565
|
function page_table_end() {
|
566
|
global $g, $fstype;
|
567
|
echo <<<EOF
|
568
|
</td>
|
569
|
</tr>
|
570
|
</table>
|
571
|
</center>
|
572
|
|
573
|
EOF;
|
574
|
|
575
|
}
|
576
|
|
577
|
function installer_custom() {
|
578
|
global $g, $fstype;
|
579
|
if(file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log"))
|
580
|
unlink("/tmp/.pc-sysinstall/pc-sysinstall.log");
|
581
|
head_html();
|
582
|
body_html();
|
583
|
page_table_start();
|
584
|
echo <<<EOF
|
585
|
<form action="installer.php" method="post">
|
586
|
<input type="hidden" name="state" value="verify_before_install">
|
587
|
<div id="mainlevel">
|
588
|
<center>
|
589
|
<table width="100%" border="0" cellpadding="5" cellspacing="0">
|
590
|
<tr>
|
591
|
<td>
|
592
|
<center>
|
593
|
<div id="mainarea">
|
594
|
<br/>
|
595
|
<center>
|
596
|
<table width="100%" border="0" cellpadding="5" cellspacing="5">
|
597
|
<tr>
|
598
|
<td>
|
599
|
<div id="pfsenseinstaller">
|
600
|
<center>
|
601
|
<div id='loadingdiv'>
|
602
|
<img src="/themes/{$g['theme']}/images/misc/loader.gif"> Probing disks, please wait...
|
603
|
</div>
|
604
|
EOF;
|
605
|
ob_flush();
|
606
|
$disks = installer_find_all_disks();
|
607
|
if(!$disks) {
|
608
|
$custom_txt = gettext("ERROR: Could not find any suitable disks for installation.");
|
609
|
} else {
|
610
|
// Prepare disk selection dropdown
|
611
|
$custom_txt = <<<EOF
|
612
|
<table bgcolor="FFFF00" width="400" height="30" cellpadding="2" style="border:1px dashed;">
|
613
|
<tr valign="middle">
|
614
|
<td>
|
615
|
<center><b>Select the installation parameters for {$g['product_name']}:</b></center>
|
616
|
</td>
|
617
|
</tr>
|
618
|
</table><p/>
|
619
|
<table>
|
620
|
EOF;
|
621
|
$custom_txt .= "<tr><td align='right'><b>Disk:</td><td><select name='disk'>\n";
|
622
|
foreach($disks as $disk) {
|
623
|
$disksize = format_bytes($disk['size'] * 1048576);
|
624
|
$custom_txt .= "<option value='{$disk['disk']}'>{$disk['disk']} - {$disksize} - {$disk['desc']}</option>\n";
|
625
|
}
|
626
|
$custom_txt .= "</select></td></tr>\n";
|
627
|
// XXX: Convert to rowhelper. Add Ajax callbacks to verify sizes, etc.
|
628
|
// Prepare disk types
|
629
|
$custom_txt .= "<tr><td align='right'><b>Filesystem type:</td><td><select name='fstype'>\n";
|
630
|
$custom_txt .= "<option value='UFS'>UFS</option>\n";
|
631
|
$custom_txt .= "<option value='UFS+S'>UFS + Softupdates</option>\n";
|
632
|
$release = trim(`uname -r | cut -d'.' -f1`);
|
633
|
if($release == "9")
|
634
|
$custom_txt .= "<option value='UFS+J'>UFS + Journaling</option>\n";
|
635
|
if(file_exists("/boot/gptzfsboot"))
|
636
|
$custom_txt .= "<option value='ZFS'>ZFS</option>\n";
|
637
|
$custom_txt .= "</select>\n</td></tr></table><p/>";
|
638
|
}
|
639
|
echo <<<EOF
|
640
|
<script type="text/javascript">
|
641
|
\$('loadingdiv').style.visibility='hidden';
|
642
|
</script>
|
643
|
<div id='contentdiv' style="display:none;">
|
644
|
{$custom_txt}<p/>
|
645
|
<input type="button" value="Cancel" onClick="javascript:document.location='/installer.php';">  
|
646
|
<input type="submit" value="Next">
|
647
|
</div>
|
648
|
<script type="text/javascript">
|
649
|
\$('contentdiv').appear();
|
650
|
</script>
|
651
|
</center>
|
652
|
</td></tr>
|
653
|
</table>
|
654
|
</div>
|
655
|
</td>
|
656
|
</tr>
|
657
|
</table>
|
658
|
</div>
|
659
|
</td>
|
660
|
</tr>
|
661
|
</table>
|
662
|
</div>
|
663
|
|
664
|
EOF;
|
665
|
page_table_end();
|
666
|
end_html();
|
667
|
}
|
668
|
|
669
|
function installer_main() {
|
670
|
global $g, $fstype;
|
671
|
if(file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log"))
|
672
|
unlink("/tmp/.pc-sysinstall/pc-sysinstall.log");
|
673
|
head_html();
|
674
|
body_html();
|
675
|
// Only enable ZFS if this exists. The install will fail otherwise.
|
676
|
if(file_exists("/boot/gptzfsboot"))
|
677
|
$zfs_enabled = "<tr bgcolor=\"#9A9A9A\"><td align=\"center\"><a href=\"installer.php?state=verify_before_install&fstype=ZFS\">Easy installation of {$g['product_name']} using the ZFS filesystem on disk {$disk}</a></td></tr>";
|
678
|
$disk = installer_find_first_disk();
|
679
|
page_table_start();
|
680
|
echo <<<EOF
|
681
|
<form action="installer.php" method="post" state="step1_post">
|
682
|
<div id="mainlevel">
|
683
|
<center>
|
684
|
<b><font face="arial" size="+2">Welcome to the {$g['product_name']} PCSysInstaller!</b></font><p/>
|
685
|
<font face="arial" size="+1">This utility will install {$g['product_name']} to a hard disk, flash drive, etc.</font>
|
686
|
<table width="100%" border="0" cellpadding="5" cellspacing="0">
|
687
|
<tr>
|
688
|
<td>
|
689
|
<center>
|
690
|
<div id="mainarea">
|
691
|
<br/>
|
692
|
<center>
|
693
|
Please select an installer option to begin:
|
694
|
<p/>
|
695
|
<table width="100%" border="0" cellpadding="5" cellspacing="5">
|
696
|
<tr>
|
697
|
<td>
|
698
|
<div id="pfsenseinstaller">
|
699
|
<center>
|
700
|
EOF;
|
701
|
if(!$disk) {
|
702
|
echo gettext("ERROR: Could not find any suitable disks for installation.");
|
703
|
echo "</div></td></tr></table></div></table></div>";
|
704
|
end_html();
|
705
|
exit;
|
706
|
}
|
707
|
echo <<<EOF
|
708
|
|
709
|
<table cellspacing="5" cellpadding="5" style="border: 1px dashed;">
|
710
|
<tr bgcolor="#CECECE"><td align="center">
|
711
|
<a href="installer.php?state=verify_before_install&disk={$disk}&fstype=UFS">Easy installation of {$g['product_name']} using the UFS filesystem on disk {$disk}</a>
|
712
|
</td></tr>
|
713
|
{$zfs_enabled}
|
714
|
<tr bgcolor="#AAAAAA"><td align="center">
|
715
|
<a href="installer.php?state=custominstall">Custom installation of {$g['product_name']}</a>
|
716
|
</td></tr>
|
717
|
<tr bgcolor="#CECECE"><td align="center">
|
718
|
<a href='/'>Cancel and return to Dashboard</a>
|
719
|
</td></tr>
|
720
|
</table>
|
721
|
</center>
|
722
|
</div>
|
723
|
</td>
|
724
|
</tr>
|
725
|
</table>
|
726
|
</div>
|
727
|
</td>
|
728
|
</tr>
|
729
|
</table>
|
730
|
</div>
|
731
|
EOF;
|
732
|
page_table_end();
|
733
|
end_html();
|
734
|
}
|
735
|
|
736
|
?>
|