Project

General

Profile

Download (21.2 KB) Statistics
| Branch: | Tag: | Revision:
1 58fdcb9c Scott Ullrich
<?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 8af6efa6 Scott Ullrich
require("globals.inc");
31 58fdcb9c Scott Ullrich
require("guiconfig.inc");
32
33 dd4be2d0 Scott Ullrich
define('PC_SYSINSTALL', '/PCBSD/pc-sysinstall/pc-sysinstall');
34
35 6bd7a614 Scott Ullrich
if($g['platform'] == "pfSense" or $g['platform'] == "nanobsd") {
36
	Header("Location: /index.php");
37
	exit;
38
}
39
40 5d4f96c6 Scott Ullrich
// Main switch dispatcher
41
switch ($_REQUEST['state']) {
42
	case "update_installer_status":
43
		update_installer_status();
44
		exit;
45 f988d2d9 Scott Ullrich
	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 5d4f96c6 Scott Ullrich
	default:
56
		installer_main();	
57
}
58
59 18a4c6c5 Scott Ullrich
function write_out_pc_sysinstaller_config($disk, $fstype = "UFS+S") {
60 58fdcb9c Scott Ullrich
	$fd = fopen("/PCBSD/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 0a680367 Scott Ullrich
disk0-part={$fstype} 0 / 
83 58fdcb9c Scott Ullrich
# 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 9c6421ee Scott Ullrich
# runExtCommand=chmod a+rx /usr/local/bin/after_installation_routines.sh && cd / && /usr/local/bin/after_installation_routines.sh
95 58fdcb9c Scott Ullrich
EOF;
96
	fwrite($fd, $config);
97
	fclose($fd);
98
	return;
99
}
100
101
function start_installation() {
102 a33cb07c Scott Ullrich
	global $g, $fstype;
103 dcf479cf Scott Ullrich
	if(file_exists("/tmp/install_complete"))
104
		return;
105 1810b771 Scott Ullrich
	$ps_running = exec("ps awwwux | grep -v grep | grep 'sh /tmp/installer.sh'");
106
	if($ps_running)	
107
		return;
108 58fdcb9c Scott Ullrich
	$fd = fopen("/tmp/installer.sh", "w");
109 5d4f96c6 Scott Ullrich
	if(!$fd) {
110 65effce3 Rafael Lucas
		die(gettext("Could not open /tmp/installer.sh for writing"));
111 5d4f96c6 Scott Ullrich
		exit;
112 691f8475 Scott Ullrich
	}
113 4ec765b7 Scott Ullrich
	fwrite($fd, "rm /tmp/.pc-sysinstall/pc-sysinstall.log 2>/dev/null\n");
114 9c6421ee Scott Ullrich
	fwrite($fd, "/PCBSD/pc-sysinstall/pc-sysinstall -c /PCBSD/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 1a99877d Scott Ullrich
	fwrite($fd, "mkdir /mnt/tmp\n");
118 f5fb2034 Scott Ullrich
	fwrite($fd, "umount /mnt\n");
119 9c6421ee Scott Ullrich
	fwrite($fd, "touch /tmp/install_complete\n");
120 58fdcb9c Scott Ullrich
	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 a33cb07c Scott Ullrich
	global $g, $fstype;
127 58fdcb9c Scott Ullrich
	$disk = `/PCBSD/pc-sysinstall/pc-sysinstall disk-list | head -n1 | cut -d':' -f1`;
128
	return $disk;
129
}
130
131 5576ea3e Scott Ullrich
function get_disk_info($diskname) {
132
	global $g, $fstype;
133
	$disk = split("\n", `/PCBSD/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", `/PCBSD/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 dd4be2d0 Scott Ullrich
// Return an array with all disks information.
155
function installer_find_all_disks() {
156
	global $g, $fstype;
157
	$disk = split("\n", `/PCBSD/pc-sysinstall/pc-sysinstall disk-list`);
158
	$disks_array = array();
159
	foreach($disk as $d) {
160 5cdb4299 Scott Ullrich
		if(!$d) 
161
			continue;
162 dd4be2d0 Scott Ullrich
		$disks_info = split(":", $d);
163
		$tmp_array = array();
164
		$disk_info = split("\n", `/PCBSD/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 58fdcb9c Scott Ullrich
function update_installer_status() {
178 38405d27 Scott Ullrich
	global $g, $fstype;
179 8af6efa6 Scott Ullrich
	// Ensure status files exist
180
	if(!file_exists("/tmp/installer_installer_running"))
181
		touch("/tmp/installer_installer_running");
182 429650ed Scott Ullrich
	$status = `cat /tmp/.pc-sysinstall/pc-sysinstall.log`;
183 73531eb1 Scott Ullrich
	$status = str_replace("\n", "\\n", $status);
184
	$status = str_replace("\n", "\\r", $status);
185 8af6efa6 Scott Ullrich
	echo "this.document.forms[0].installeroutput.value='$status';\n";
186 429650ed Scott Ullrich
	echo "this.document.forms[0].installeroutput.scrollTop = this.document.forms[0].installeroutput.scrollHeight;\n";	
187 8af6efa6 Scott Ullrich
	// Find out installer progress
188 8a4cf948 Scott Ullrich
	$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 8af6efa6 Scott Ullrich
	if(strstr($status, "/boot /mnt/boot")) 
200 73531eb1 Scott Ullrich
		$progress = "10";
201 8af6efa6 Scott Ullrich
	if(strstr($status, "/COPYRIGHT /mnt/COPYRIGHT"))
202 9c6421ee Scott Ullrich
		$progress = "11";
203 8af6efa6 Scott Ullrich
	if(strstr($status, "/bin /mnt/bin"))
204 9c6421ee Scott Ullrich
		$progress = "12";
205 8af6efa6 Scott Ullrich
	if(strstr($status, "/conf /mnt/conf"))
206 9c6421ee Scott Ullrich
		$progress = "15";
207 8af6efa6 Scott Ullrich
	if(strstr($status, "/conf.default /mnt/conf.default"))
208 9c6421ee Scott Ullrich
		$progress = "20";
209 8af6efa6 Scott Ullrich
	if(strstr($status, "/dev /mnt/dev"))
210 9c6421ee Scott Ullrich
		$progress = "25";
211 8af6efa6 Scott Ullrich
	if(strstr($status, "/etc /mnt/etc"))
212 9c6421ee Scott Ullrich
		$progress = "30";
213 8af6efa6 Scott Ullrich
	if(strstr($status, "/home /mnt/home"))
214 9c6421ee Scott Ullrich
		$progress = "35";
215 8af6efa6 Scott Ullrich
	if(strstr($status, "/kernels /mnt/kernels"))
216 9c6421ee Scott Ullrich
		$progress = "40";
217 8af6efa6 Scott Ullrich
	if(strstr($status, "/libexec /mnt/libexec"))
218 9c6421ee Scott Ullrich
		$progress = "50";
219 8af6efa6 Scott Ullrich
	if(strstr($status, "/lib /mnt/lib"))
220 9c6421ee Scott Ullrich
		$progress = "60";
221 8af6efa6 Scott Ullrich
	if(strstr($status, "/root /mnt/root"))
222 73531eb1 Scott Ullrich
		$progress = "70";
223 8af6efa6 Scott Ullrich
	if(strstr($status, "/sbin /mnt/sbin"))
224 73531eb1 Scott Ullrich
		$progress = "75";
225 8af6efa6 Scott Ullrich
	if(strstr($status, "/sys /mnt/sys"))
226 73531eb1 Scott Ullrich
		$progress = "80";
227 8af6efa6 Scott Ullrich
	if(strstr($status, "/usr /mnt/usr"))
228 73531eb1 Scott Ullrich
		$progress = "95";
229 8af6efa6 Scott Ullrich
	if(strstr($status, "/usr /mnt/usr"))
230
		$progress = "90";
231 73531eb1 Scott Ullrich
	if(strstr($status, "/var /mnt/var"))
232
		$progress = "95";
233 8a4cf948 Scott Ullrich
	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 8af6efa6 Scott Ullrich
	if(strstr($status, "Installation finished"))
242
		$progress = "100";
243 38405d27 Scott Ullrich
	// Check for error and bail if we see one.
244
	if(stristr($status, "error")) {
245
		$error = true;
246 b12cc599 Scott Ullrich
		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 38405d27 Scott Ullrich
		echo "\$('progressbar').style.width='100%';\n";
248 50d44909 Scott Ullrich
		unlink("/tmp/install_complete");
249 58fdcb9c Scott Ullrich
		return;
250 38405d27 Scott Ullrich
	}
251 73531eb1 Scott Ullrich
	$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 a33cb07c Scott Ullrich
			$running = "\$('installerrunning').innerHTML='<table><tr><td valign=\"middle\"><img src=\"/themes/{$g['theme']}/images/misc/loader.gif\"></td><td valign=\"middle\">&nbsp;<font size=\"2\"><b>Installer running ({$progress}% completed)...</td></tr></table>'; ";
256 73531eb1 Scott Ullrich
			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 58fdcb9c Scott Ullrich
	if(file_exists("/tmp/install_complete")) {
265 b12cc599 Scott Ullrich
		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 f988d2d9 Scott Ullrich
		echo "\$('pbdiv').fade();\n";
267 58fdcb9c Scott Ullrich
		unlink_if_exists("/tmp/installer.sh");
268 8af6efa6 Scott Ullrich
		file_put_contents("/tmp/installer_installer_running", "finished");
269 58fdcb9c Scott Ullrich
	}
270
}
271
272
function update_installer_status_win($status) {
273 a33cb07c Scott Ullrich
	global $g, $fstype;
274 58fdcb9c Scott Ullrich
	echo "<script type=\"text/javascript\">\n";
275 73531eb1 Scott Ullrich
	echo "	\$('installeroutput').value = '" . str_replace(htmlentities($status), "\n", "") . "';\n";
276 58fdcb9c Scott Ullrich
	echo "</script>";
277
}
278
279 f988d2d9 Scott Ullrich
function begin_install() {
280
	global $g;
281 b5cff707 Scott Ullrich
	if(file_exists("/tmp/install_complete"))
282
		return;
283 58fdcb9c Scott Ullrich
	unlink_if_exists("/tmp/install_complete");
284 f988d2d9 Scott Ullrich
	if($_REQUEST['disk'])
285
		$disk = $_REQUEST['disk'];
286
	else 
287
		$disk = installer_find_first_disk();
288 58fdcb9c Scott Ullrich
	if(!$disk) {
289 f988d2d9 Scott Ullrich
		echo "<script type=\"text/javascript\">";
290
		echo "\$('pbdiv').fade();\n";
291
		echo "</script>";
292 65effce3 Rafael Lucas
		$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 58fdcb9c Scott Ullrich
		return;
295
	}
296 f988d2d9 Scott Ullrich
	// 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 65effce3 Rafael Lucas
	update_installer_status_win(sprintf(gettext("Beginning installation on disk %s."),$disk));
303 58fdcb9c Scott Ullrich
	start_installation();
304
}
305
306 38405d27 Scott Ullrich
function head_html() {
307 a33cb07c Scott Ullrich
	global $g, $fstype;
308 38405d27 Scott Ullrich
	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 5d4f96c6 Scott Ullrich
function body_html() {
339 a33cb07c Scott Ullrich
	global $g, $fstype;
340 5d4f96c6 Scott Ullrich
	$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
341
	if(strstr($pfSversion, "1.2"))
342
		$one_two = true;
343 97fc7767 Vinicius Coque
	$pgtitle = "{$g['product_name']}: " . gettext("Installer");
344 5d4f96c6 Scott Ullrich
	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 73531eb1 Scott Ullrich
	<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 5d4f96c6 Scott Ullrich
	</script>
368
EOF;
369 58fdcb9c Scott Ullrich
370 309b3a20 Scott Ullrich
	if($one_two)
371 5d4f96c6 Scott Ullrich
		echo "<p class=\"pgtitle\">{$pgtitle}</font></p>";
372 58fdcb9c Scott Ullrich
373 5d4f96c6 Scott Ullrich
	if ($savemsg) print_info_box($savemsg); 
374 58fdcb9c Scott Ullrich
}
375
376 5d4f96c6 Scott Ullrich
function end_html() {
377 a33cb07c Scott Ullrich
	global $g, $fstype;
378 5d4f96c6 Scott Ullrich
	echo "</form>";
379
	echo "</body>";
380
	echo "</html>";
381 58fdcb9c Scott Ullrich
}
382
383
function template() {
384 a33cb07c Scott Ullrich
	global $g, $fstype;
385 38405d27 Scott Ullrich
	head_html();
386 5d4f96c6 Scott Ullrich
	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 58fdcb9c Scott Ullrich
EOF;
410 5d4f96c6 Scott Ullrich
	end_html();
411 58fdcb9c Scott Ullrich
}
412
413 f988d2d9 Scott Ullrich
function verify_before_install() {
414
	global $g, $fstype;
415
	head_html();
416
	body_html();
417
	page_table_start();
418 5576ea3e Scott Ullrich
	$disk = get_disk_info($_REQUEST['disk']);
419
	$disksize = format_bytes($disk['size'] * 1048576);
420 f988d2d9 Scott Ullrich
	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 class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
431
							<tr>
432
	     						<td class="tabcont" >
433
									<div>
434
										<center>
435
											<div id="pfsensetemplate">
436 5576ea3e Scott Ullrich
												<table bgcolor="FFFF00" width="380" height="50" cellpadding="5" style="border:1px dashed;">
437
													<tr>
438
														<td>
439
															<center><b>Please verify that the following is correct:</b></center>
440
														</td>
441
													</tr>
442 f988d2d9 Scott Ullrich
												</table>
443
												<p/>
444 5576ea3e Scott Ullrich
												<table>
445 846631ac Scott Ullrich
													<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 5576ea3e Scott Ullrich
												</table>
450 f988d2d9 Scott Ullrich
											</div>
451
										</center>
452
									</div>
453
	     						</td>
454
							</tr>
455
						</table>
456
					</div>
457 5576ea3e Scott Ullrich
					<center>
458
						<p/>
459
						<input type="button" value="Cancel" onClick="javascript:document.location='/';">  
460
						<input type="submit" value="Begin installation"> 
461
					</center>
462 f988d2d9 Scott Ullrich
				</td>
463
			</tr>
464
		</table>
465
	</div>
466
EOF;
467
	page_table_end();
468
	end_html();
469
}
470
471
function installing_gui() {
472 a33cb07c Scott Ullrich
	global $g, $fstype;
473 38405d27 Scott Ullrich
	head_html();
474 5d4f96c6 Scott Ullrich
	body_html();
475 73531eb1 Scott Ullrich
	echo "<form action=\"installer.php\" method=\"post\" state=\"step1_post\">";
476 8af6efa6 Scott Ullrich
	page_table_start();
477 58fdcb9c Scott Ullrich
	echo <<<EOF
478 8af6efa6 Scott Ullrich
	<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 824f539d Scott Ullrich
								<table width="100%" border="0" cellpadding="0" cellspacing="0">
487 8af6efa6 Scott Ullrich
									<tr>
488 824f539d Scott Ullrich
			     						<td>
489 8af6efa6 Scott Ullrich
											<div id="pfsenseinstaller" width="100%">
490 50d44909 Scott Ullrich
												<div id='installerrunning' width='100%' style="padding:8px; border:1px dashed #000000">
491 73531eb1 Scott Ullrich
													<table>
492
														<tr>
493
															<td valign="middle">
494
																<img src="/themes/{$g['theme']}/images/misc/loader.gif">
495
															</td>
496
															<td valign="middle">
497
																&nbsp;<font size="2"><b>Starting Installer...  Please wait...
498
															</td>
499
														</tr>
500
													</table>
501 8af6efa6 Scott Ullrich
												</div>
502 f988d2d9 Scott Ullrich
												<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 691f8475 Scott Ullrich
												<textarea name='installeroutput' id='installeroutput' rows="31" cols="90">
523 8af6efa6 Scott Ullrich
												</textarea>
524
											</div>
525
			     						</td>
526
									</tr>
527
								</table>
528
							</div>
529
						</td>
530
					</tr>
531
				</table>
532
			</div>
533
		</td></tr>
534 5d4f96c6 Scott Ullrich
		</table>
535 8af6efa6 Scott Ullrich
	</center>
536 5d4f96c6 Scott Ullrich
	<script type="text/javascript">setTimeout('getinstallerprogress()', 250);</script>
537 8af6efa6 Scott Ullrich
538 58fdcb9c Scott Ullrich
EOF;
539 8af6efa6 Scott Ullrich
	page_table_end();
540 5d4f96c6 Scott Ullrich
	end_html();
541 58fdcb9c Scott Ullrich
}
542
543 8af6efa6 Scott Ullrich
function page_table_start() {
544 a33cb07c Scott Ullrich
	global $g, $fstype;
545 c9418f04 Scott Ullrich
	echo <<<EOF
546 8af6efa6 Scott Ullrich
	<center>
547 50d44909 Scott Ullrich
		<img border="0" src="./themes/{$g['theme']}/images/logo.gif"></a><br/>
548
		<table cellpadding="6" cellspacing="0" width="640" height="480" style="border:1px solid #000000">
549 8af6efa6 Scott Ullrich
		<tr height="10" bgcolor="#990000">
550
			<td style="border-bottom:1px solid #000000">
551
				<font color='white'>
552
					<b>
553 50d44909 Scott Ullrich
						{$g['product_name']} installer
554 8af6efa6 Scott Ullrich
					</b>
555
				</font>
556
			</td>
557
		</tr>
558
		<tr>
559
			<td>
560
561
EOF;
562
563
}
564
565
function page_table_end() {
566 a33cb07c Scott Ullrich
	global $g, $fstype;
567 8af6efa6 Scott Ullrich
	echo <<<EOF
568
			</td>
569
		</tr>
570
		</table>
571
	</center>
572
573
EOF;
574
	
575 58fdcb9c Scott Ullrich
}
576
577 dd4be2d0 Scott Ullrich
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 f988d2d9 Scott Ullrich
		<form action="installer.php" method="post">
586
			<input type="hidden" name="state" value="verify_before_install">
587 dd4be2d0 Scott Ullrich
			<div id="mainlevel">
588
				<center>
589
				<b><font face="arial" size="+2">Welcome to the {$g['product_name']} PCSysInstaller!</b></font><p/>
590
				<font face="arial" size="+1">This utility will install {$g['product_name']} to a hard disk, flash drive, etc.</font>
591
				<table width="100%" border="0" cellpadding="5" cellspacing="0">
592
			 		<tr>
593
			    		<td>
594
							<center>
595
							<div id="mainarea">
596
								<br/>
597
								<center>
598
								<table width="100%" border="0" cellpadding="5" cellspacing="5">
599
									<tr>
600
			     						<td>
601
											<div id="pfsenseinstaller">
602
												<center>
603 f988d2d9 Scott Ullrich
												<div id='loadingdiv'>
604
													<img src="/themes/{$g['theme']}/images/misc/loader.gif"> Probing disks, please wait...
605
												</div>
606
EOF;
607
	$disks = installer_find_all_disks();
608
	if(!$disks)  {
609
		$custom_txt = gettext("WARNING: Could not find any suitable disks for installation.");
610
	} else {
611
		// Prepare disk selection dropdown
612
		$custom_txt = "Disk: <select name='disk'>\n";
613 5576ea3e Scott Ullrich
		foreach($disks as $disk) {
614
			$disksize = format_bytes($disk['size'] * 1048576);
615
			$custom_txt .= "<option value='{$disk['disk']}'>{$disk['disk']} - {$disksize} - {$disk['desc']}</option>\n";
616
		}
617 f988d2d9 Scott Ullrich
		$custom_txt .= "</select><p/>\n";
618 c2185286 Scott Ullrich
		// XXX: Convert to rowhelper.  Add Ajax callbacks to verify sizes, etc.
619 f988d2d9 Scott Ullrich
		// Prepare disk types
620
		$custom_txt .=  "Filesystem type: <select name='fstype'>\n";
621 18a4c6c5 Scott Ullrich
		$custom_txt .=  "<option value='UFS'>UFS</option>\n";
622
		$custom_txt .=  "<option value='UFS+S'>UFS + Softupdates</option>\n";
623 779476f6 Scott Ullrich
		$release = trim(`uname -r | cut -d'.' -f1`);
624
		if($release == "9")
625
			$custom_txt .=  "<option value='UFS+J'>UFS + Journaling</option>\n";
626 f988d2d9 Scott Ullrich
		if(file_exists("/boot/gptzfsboot")) 
627 18a4c6c5 Scott Ullrich
			$custom_txt .= "<option value='ZFS'>ZFS</option>\n";
628 f988d2d9 Scott Ullrich
		$custom_txt .= "</select>\n";
629
	}
630
	echo <<<EOF
631
													<script type="text/javascript">
632
														\$('loadingdiv').fade();
633
													</script>
634
													<div id='contentdiv' style="display:none;">
635
														{$custom_txt}<p/>
636
														<input type="submit" value="Next >"
637
													</div>
638
													<script type="text/javascript">
639
														\$('contentdiv').appear();
640
													</script>
641
												</center>
642 dd4be2d0 Scott Ullrich
											</div>
643
			     						</td>
644
									</tr>
645
								</table>
646
							</div>
647
						</td>
648
					</tr>
649
				</table>
650
			</div>
651
EOF;
652
	page_table_end();
653
	end_html();
654
}
655
656 58fdcb9c Scott Ullrich
function installer_main() {
657 a33cb07c Scott Ullrich
	global $g, $fstype;
658 8a4cf948 Scott Ullrich
	if(file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log")) 
659
		unlink("/tmp/.pc-sysinstall/pc-sysinstall.log");
660 38405d27 Scott Ullrich
	head_html();
661 5d4f96c6 Scott Ullrich
	body_html();
662 a33cb07c Scott Ullrich
	// Only enable ZFS if this exists.  The install will fail otherwise.
663
	if(file_exists("/boot/gptzfsboot")) 
664 f988d2d9 Scott Ullrich
		$zfs_enabled = "<a href=\"installer.php?state=verify_before_install&fstype=ZFS\">Easy installation of {$g['product_name']} using the ZFS filesystem</a><p/>";
665 5d4f96c6 Scott Ullrich
	$disk = installer_find_first_disk();
666
	if(!$disk) 
667 65effce3 Rafael Lucas
		echo gettext("WARNING: Could not find any suitable disks for installation.");
668 8af6efa6 Scott Ullrich
	page_table_start();
669 5d4f96c6 Scott Ullrich
	echo <<<EOF
670 8a4cf948 Scott Ullrich
		<form action="installer.php" method="post" state="step1_post">
671 8af6efa6 Scott Ullrich
			<div id="mainlevel">
672 8a4cf948 Scott Ullrich
				<center>
673 50d44909 Scott Ullrich
				<b><font face="arial" size="+2">Welcome to the {$g['product_name']} PCSysInstaller!</b></font><p/>
674
				<font face="arial" size="+1">This utility will install {$g['product_name']} to a hard disk, flash drive, etc.</font>
675 8af6efa6 Scott Ullrich
				<table width="100%" border="0" cellpadding="5" cellspacing="0">
676
			 		<tr>
677
			    		<td>
678 8a4cf948 Scott Ullrich
							<center>
679 8af6efa6 Scott Ullrich
							<div id="mainarea">
680
								<br/>
681 8a4cf948 Scott Ullrich
								<center>
682 8af6efa6 Scott Ullrich
								Please select an installer option to begin:
683 524b7a41 Scott Ullrich
								<table width="100%" border="0" cellpadding="5" cellspacing="5">
684 8af6efa6 Scott Ullrich
									<tr>
685 524b7a41 Scott Ullrich
			     						<td>
686 8af6efa6 Scott Ullrich
											<div id="pfsenseinstaller">
687 8a4cf948 Scott Ullrich
												<center>
688 f988d2d9 Scott Ullrich
													Rescue config.xml<p/>
689 846631ac Scott Ullrich
													<a href="installer.php?state=verify_before_install&disk={$disk}&fstype=UFS">Easy installation of {$g['product_name']} using the UFS filesystem</a><p/>
690 f988d2d9 Scott Ullrich
												 	{$zfs_enabled}
691
													<a href="installer.php?state=custominstall">Custom installation of {$g['product_name']}</a>
692
												</center>
693 8af6efa6 Scott Ullrich
											</div>
694
			     						</td>
695
									</tr>
696
								</table>
697
							</div>
698
						</td>
699
					</tr>
700
				</table>
701
			</div>
702 58fdcb9c Scott Ullrich
EOF;
703 8af6efa6 Scott Ullrich
	page_table_end();
704 5d4f96c6 Scott Ullrich
	end_html();
705 58fdcb9c Scott Ullrich
}
706
707 63d7c442 Scott Ullrich
?>