Project

General

Profile

Download (17.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 0a680367 Scott Ullrich
// Handle other type of file systems
36
if($_REQUEST['fstype']) 
37
	$fstype = strtoupper($_REQUEST['fstype']);
38
else 
39
	$fstype = "UFS+S";
40
41 6bd7a614 Scott Ullrich
if($g['platform'] == "pfSense" or $g['platform'] == "nanobsd") {
42
	Header("Location: /index.php");
43
	exit;
44
}
45
46 5d4f96c6 Scott Ullrich
// Main switch dispatcher
47
switch ($_REQUEST['state']) {
48
	case "quickeasyinstall":
49
		quickeasyinstall_gui();
50
		break;
51
	case "update_installer_status":
52
		update_installer_status();
53
		exit;
54
	default:
55
		installer_main();	
56
}
57
58 58fdcb9c Scott Ullrich
function write_out_pc_sysinstaller_config($disk) {
59 0a680367 Scott Ullrich
	global $fstype;
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 dd4be2d0 Scott Ullrich
// Return an array with all disks information.
132
function installer_find_all_disks() {
133
	global $g, $fstype;
134
	$disk = split("\n", `/PCBSD/pc-sysinstall/pc-sysinstall disk-list`);
135
	$disks_array = array();
136
	foreach($disk as $d) {
137
		$disks_info = split(":", $d);
138
		$tmp_array = array();
139
		$disk_info = split("\n", `/PCBSD/pc-sysinstall/pc-sysinstall disk-info {$disks_info[0]}`);
140
		foreach($disk_info as $di) { 
141
			$di_s = split("=", $di);
142
			if($di_s[0])
143
				$tmp_array[$di_s[0]] = $di_s[1];
144
		}
145
		$tmp_array['disk'] = trim($disks_info[0]);
146
		$tmp_array['desc'] = trim(htmlentities($disks_info[1]));
147
		$disks_array[] = $tmp_array;
148
	}
149
	return $disks_array;
150
}
151
152 58fdcb9c Scott Ullrich
function update_installer_status() {
153 38405d27 Scott Ullrich
	global $g, $fstype;
154 8af6efa6 Scott Ullrich
	// Ensure status files exist
155
	if(!file_exists("/tmp/installer_installer_running"))
156
		touch("/tmp/installer_installer_running");
157 429650ed Scott Ullrich
	$status = `cat /tmp/.pc-sysinstall/pc-sysinstall.log`;
158 73531eb1 Scott Ullrich
	$status = str_replace("\n", "\\n", $status);
159
	$status = str_replace("\n", "\\r", $status);
160 8af6efa6 Scott Ullrich
	echo "this.document.forms[0].installeroutput.value='$status';\n";
161 429650ed Scott Ullrich
	echo "this.document.forms[0].installeroutput.scrollTop = this.document.forms[0].installeroutput.scrollHeight;\n";	
162 8af6efa6 Scott Ullrich
	// Find out installer progress
163 8a4cf948 Scott Ullrich
	$progress = "5";
164
	if(strstr($status, "Running: dd")) 
165
		$progress = "6";
166
	if(strstr($status, "Running: gpart create -s GPT")) 
167
		$progress = "7";
168
	if(strstr($status, "Running: gpart bootcode")) 
169
		$progress = "7";
170
	if(strstr($status, "Running: newfs -U")) 
171
		$progress = "8";
172
	if(strstr($status, "Running: sync")) 
173
		$progress = "9";
174 8af6efa6 Scott Ullrich
	if(strstr($status, "/boot /mnt/boot")) 
175 73531eb1 Scott Ullrich
		$progress = "10";
176 8af6efa6 Scott Ullrich
	if(strstr($status, "/COPYRIGHT /mnt/COPYRIGHT"))
177 9c6421ee Scott Ullrich
		$progress = "11";
178 8af6efa6 Scott Ullrich
	if(strstr($status, "/bin /mnt/bin"))
179 9c6421ee Scott Ullrich
		$progress = "12";
180 8af6efa6 Scott Ullrich
	if(strstr($status, "/conf /mnt/conf"))
181 9c6421ee Scott Ullrich
		$progress = "15";
182 8af6efa6 Scott Ullrich
	if(strstr($status, "/conf.default /mnt/conf.default"))
183 9c6421ee Scott Ullrich
		$progress = "20";
184 8af6efa6 Scott Ullrich
	if(strstr($status, "/dev /mnt/dev"))
185 9c6421ee Scott Ullrich
		$progress = "25";
186 8af6efa6 Scott Ullrich
	if(strstr($status, "/etc /mnt/etc"))
187 9c6421ee Scott Ullrich
		$progress = "30";
188 8af6efa6 Scott Ullrich
	if(strstr($status, "/home /mnt/home"))
189 9c6421ee Scott Ullrich
		$progress = "35";
190 8af6efa6 Scott Ullrich
	if(strstr($status, "/kernels /mnt/kernels"))
191 9c6421ee Scott Ullrich
		$progress = "40";
192 8af6efa6 Scott Ullrich
	if(strstr($status, "/libexec /mnt/libexec"))
193 9c6421ee Scott Ullrich
		$progress = "50";
194 8af6efa6 Scott Ullrich
	if(strstr($status, "/lib /mnt/lib"))
195 9c6421ee Scott Ullrich
		$progress = "60";
196 8af6efa6 Scott Ullrich
	if(strstr($status, "/root /mnt/root"))
197 73531eb1 Scott Ullrich
		$progress = "70";
198 8af6efa6 Scott Ullrich
	if(strstr($status, "/sbin /mnt/sbin"))
199 73531eb1 Scott Ullrich
		$progress = "75";
200 8af6efa6 Scott Ullrich
	if(strstr($status, "/sys /mnt/sys"))
201 73531eb1 Scott Ullrich
		$progress = "80";
202 8af6efa6 Scott Ullrich
	if(strstr($status, "/usr /mnt/usr"))
203 73531eb1 Scott Ullrich
		$progress = "95";
204 8af6efa6 Scott Ullrich
	if(strstr($status, "/usr /mnt/usr"))
205
		$progress = "90";
206 73531eb1 Scott Ullrich
	if(strstr($status, "/var /mnt/var"))
207
		$progress = "95";
208 8a4cf948 Scott Ullrich
	if(strstr($status, "cap_mkdb /etc/login.conf"))
209
		$progress = "96";
210
	if(strstr($status, "Setting hostname"))
211
		$progress = "97";
212
	if(strstr($status, "umount -f /mnt"))
213
		$progress = "98";
214
	if(strstr($status, "umount -f /mnt"))
215
		$progress = "99";
216 8af6efa6 Scott Ullrich
	if(strstr($status, "Installation finished"))
217
		$progress = "100";
218 38405d27 Scott Ullrich
	// Check for error and bail if we see one.
219
	if(stristr($status, "error")) {
220
		$error = true;
221 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.'; ";
222 38405d27 Scott Ullrich
		echo "\$('progressbar').style.width='100%';\n";
223 50d44909 Scott Ullrich
		unlink("/tmp/install_complete");
224 58fdcb9c Scott Ullrich
		return;
225 38405d27 Scott Ullrich
	}
226 73531eb1 Scott Ullrich
	$running_old = trim(file_get_contents("/tmp/installer_installer_running"));
227
	if($installer_running <> "running") {
228
		$ps_running = exec("ps awwwux | grep -v grep | grep 'sh /tmp/installer.sh'");
229
		if($ps_running)	{
230 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>'; ";
231 73531eb1 Scott Ullrich
			if($running_old <> $running) {
232
				echo $running;
233
				file_put_contents("/tmp/installer_installer_running", "$running");			
234
			}
235
		}
236
	}
237
	if($progress) 
238
		echo "\$('progressbar').style.width='{$progress}%';\n";
239 58fdcb9c Scott Ullrich
	if(file_exists("/tmp/install_complete")) {
240 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";
241 58fdcb9c Scott Ullrich
		unlink_if_exists("/tmp/installer.sh");
242 8af6efa6 Scott Ullrich
		file_put_contents("/tmp/installer_installer_running", "finished");
243 58fdcb9c Scott Ullrich
	}
244
}
245
246
function update_installer_status_win($status) {
247 a33cb07c Scott Ullrich
	global $g, $fstype;
248 58fdcb9c Scott Ullrich
	echo "<script type=\"text/javascript\">\n";
249 73531eb1 Scott Ullrich
	echo "	\$('installeroutput').value = '" . str_replace(htmlentities($status), "\n", "") . "';\n";
250 58fdcb9c Scott Ullrich
	echo "</script>";
251
}
252
253
function begin_quick_easy_install() {
254 a33cb07c Scott Ullrich
	global $g, $fstype;
255 b5cff707 Scott Ullrich
	if(file_exists("/tmp/install_complete"))
256
		return;
257 58fdcb9c Scott Ullrich
	unlink_if_exists("/tmp/install_complete");
258
	$disk = installer_find_first_disk();
259
	if(!$disk) {
260
		// XXX: hide progress bar
261 65effce3 Rafael Lucas
		$savemsg = gettext("Could not find a suitable disk for installation");
262
		update_installer_status_win(gettext("Could not find a suitable disk for installation."));
263 58fdcb9c Scott Ullrich
		return;
264
	}
265
	write_out_pc_sysinstaller_config($disk);
266 65effce3 Rafael Lucas
	update_installer_status_win(sprintf(gettext("Beginning installation on disk %s."),$disk));
267 58fdcb9c Scott Ullrich
	start_installation();
268
}
269
270 38405d27 Scott Ullrich
function head_html() {
271 a33cb07c Scott Ullrich
	global $g, $fstype;
272 38405d27 Scott Ullrich
	echo <<<EOF
273
<html>
274
	<head>
275
		<style type='text/css'>
276
			a:link { 
277
				color: #000000;
278
				text-decoration:underline;
279
				font-size:14;
280
			}
281
			a:visited { 
282
				color: #000000;
283
				text-decoration:underline;
284
				font-size:14;
285
			}
286
			a:hover { 
287
				color: #FFFF00;
288
				text-decoration: none;
289
				font-size:14;
290
			}
291
			a:active { 
292
				color: #FFFF00;
293
				text-decoration:underline;
294
				font-size:14;
295
			}
296
		</style>
297
	</head>
298
EOF;
299
300
}
301
302 5d4f96c6 Scott Ullrich
function body_html() {
303 a33cb07c Scott Ullrich
	global $g, $fstype;
304 5d4f96c6 Scott Ullrich
	$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
305
	if(strstr($pfSversion, "1.2"))
306
		$one_two = true;
307 97fc7767 Vinicius Coque
	$pgtitle = "{$g['product_name']}: " . gettext("Installer");
308 5d4f96c6 Scott Ullrich
	include("head.inc");
309
	echo <<<EOF
310
	<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
311
	<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
312 73531eb1 Scott Ullrich
	<script type="text/javascript">
313
		function getinstallerprogress() {
314
			url = 'installer.php';
315
			pars = 'state=update_installer_status';
316
			callajax(url, pars, installcallback);
317
		}
318
		function callajax(url, pars, activitycallback) {
319
			var myAjax = new Ajax.Request(
320
				url,
321
				{
322
					method: 'post',
323
					parameters: pars,
324
					onComplete: activitycallback
325
				});
326
		}
327
		function installcallback(transport) {
328
			setTimeout('getinstallerprogress()', 2000);
329
			eval(transport.responseText);
330
		}
331 5d4f96c6 Scott Ullrich
	</script>
332
EOF;
333 58fdcb9c Scott Ullrich
334 309b3a20 Scott Ullrich
	if($one_two)
335 5d4f96c6 Scott Ullrich
		echo "<p class=\"pgtitle\">{$pgtitle}</font></p>";
336 58fdcb9c Scott Ullrich
337 5d4f96c6 Scott Ullrich
	if ($savemsg) print_info_box($savemsg); 
338 58fdcb9c Scott Ullrich
}
339
340 5d4f96c6 Scott Ullrich
function end_html() {
341 a33cb07c Scott Ullrich
	global $g, $fstype;
342 5d4f96c6 Scott Ullrich
	echo "</form>";
343
	echo "</body>";
344
	echo "</html>";
345 58fdcb9c Scott Ullrich
}
346
347
function template() {
348 a33cb07c Scott Ullrich
	global $g, $fstype;
349 38405d27 Scott Ullrich
	head_html();
350 5d4f96c6 Scott Ullrich
	body_html();
351
	echo <<<EOF
352
	<div id="mainlevel">
353
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
354
	 		<tr>
355
	    		<td>
356
					<div id="mainarea">
357
						<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
358
							<tr>
359
	     						<td class="tabcont" >
360
	      							<form action="installer.php" method="post">
361
									<div id="pfsensetemplate">
362
363
364
									</div>
365
	     						</td>
366
							</tr>
367
						</table>
368
					</div>
369
				</td>
370
			</tr>
371
		</table>
372
	</div>
373 58fdcb9c Scott Ullrich
EOF;
374 5d4f96c6 Scott Ullrich
	end_html();
375 58fdcb9c Scott Ullrich
}
376
377
function quickeasyinstall_gui() {
378 a33cb07c Scott Ullrich
	global $g, $fstype;
379 38405d27 Scott Ullrich
	head_html();
380 5d4f96c6 Scott Ullrich
	body_html();
381 73531eb1 Scott Ullrich
	echo "<form action=\"installer.php\" method=\"post\" state=\"step1_post\">";
382 8af6efa6 Scott Ullrich
	page_table_start();
383 58fdcb9c Scott Ullrich
	echo <<<EOF
384 8af6efa6 Scott Ullrich
	<center>
385
		<table width="100%">
386
		<tr><td>
387
			<div id="mainlevel">
388
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
389
			 		<tr>
390
			    		<td>
391
							<div id="mainarea">
392 824f539d Scott Ullrich
								<table width="100%" border="0" cellpadding="0" cellspacing="0">
393 8af6efa6 Scott Ullrich
									<tr>
394 824f539d Scott Ullrich
			     						<td>
395 8af6efa6 Scott Ullrich
											<div id="pfsenseinstaller" width="100%">
396 50d44909 Scott Ullrich
												<div id='installerrunning' width='100%' style="padding:8px; border:1px dashed #000000">
397 73531eb1 Scott Ullrich
													<table>
398
														<tr>
399
															<td valign="middle">
400
																<img src="/themes/{$g['theme']}/images/misc/loader.gif">
401
															</td>
402
															<td valign="middle">
403
																&nbsp;<font size="2"><b>Starting Installer...  Please wait...
404
															</td>
405
														</tr>
406
													</table>
407 8af6efa6 Scott Ullrich
												</div>
408
												<br/>
409 0a680367 Scott Ullrich
												<center>
410 73531eb1 Scott Ullrich
												<table height='15' width='640' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
411 8af6efa6 Scott Ullrich
													<tr>
412 73531eb1 Scott Ullrich
														<td background="./themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
413 8af6efa6 Scott Ullrich
														</td>
414
														<td>
415 73531eb1 Scott Ullrich
															<table id="progholder" name="progholder" height='15' width='630' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
416
																<td background="./themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
417
																	<img src='./themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
418
																</td>
419 8af6efa6 Scott Ullrich
															</table>
420
														</td>
421 73531eb1 Scott Ullrich
														<td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
422 8af6efa6 Scott Ullrich
														</td>
423
													</tr>
424
												</table>
425
												<br/>
426 691f8475 Scott Ullrich
												<textarea name='installeroutput' id='installeroutput' rows="31" cols="90">
427 8af6efa6 Scott Ullrich
												</textarea>
428
											</div>
429
			     						</td>
430
									</tr>
431
								</table>
432
							</div>
433
						</td>
434
					</tr>
435
				</table>
436
			</div>
437
		</td></tr>
438 5d4f96c6 Scott Ullrich
		</table>
439 8af6efa6 Scott Ullrich
	</center>
440 5d4f96c6 Scott Ullrich
	<script type="text/javascript">setTimeout('getinstallerprogress()', 250);</script>
441 8af6efa6 Scott Ullrich
442 58fdcb9c Scott Ullrich
EOF;
443 8af6efa6 Scott Ullrich
	page_table_end();
444 5d4f96c6 Scott Ullrich
	end_html();
445 1810b771 Scott Ullrich
	begin_quick_easy_install();
446 58fdcb9c Scott Ullrich
}
447
448 8af6efa6 Scott Ullrich
function page_table_start() {
449 a33cb07c Scott Ullrich
	global $g, $fstype;
450 c9418f04 Scott Ullrich
	echo <<<EOF
451 8af6efa6 Scott Ullrich
	<center>
452 50d44909 Scott Ullrich
		<img border="0" src="./themes/{$g['theme']}/images/logo.gif"></a><br/>
453
		<table cellpadding="6" cellspacing="0" width="640" height="480" style="border:1px solid #000000">
454 8af6efa6 Scott Ullrich
		<tr height="10" bgcolor="#990000">
455
			<td style="border-bottom:1px solid #000000">
456
				<font color='white'>
457
					<b>
458 50d44909 Scott Ullrich
						{$g['product_name']} installer
459 8af6efa6 Scott Ullrich
					</b>
460
				</font>
461
			</td>
462
		</tr>
463
		<tr>
464
			<td>
465
466
EOF;
467
468
}
469
470
function page_table_end() {
471 a33cb07c Scott Ullrich
	global $g, $fstype;
472 8af6efa6 Scott Ullrich
	echo <<<EOF
473
			</td>
474
		</tr>
475
		</table>
476
	</center>
477
478
EOF;
479
	
480 58fdcb9c Scott Ullrich
}
481
482 dd4be2d0 Scott Ullrich
function installer_custom() {
483
	global $g, $fstype;
484
	if(file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log")) 
485
		unlink("/tmp/.pc-sysinstall/pc-sysinstall.log");
486
	head_html();
487
	body_html();
488
	// Only enable ZFS if this exists.  The install will fail otherwise.
489
	if(file_exists("/boot/gptzfsboot")) 
490
		$zfs_enabled = "or <a href=\"installer.php?state=quickeasyinstall&fstype=ZFS\">ZFS</a> ";
491
	$disk = installer_find_first_disk();
492
	if(!$disk) 
493
		echo gettext("WARNING: Could not find any suitable disks for installation.");
494
	page_table_start();
495
	echo <<<EOF
496
		<form action="installer.php" method="post" state="step1_post">
497
			<div id="mainlevel">
498
				<center>
499
				<b><font face="arial" size="+2">Welcome to the {$g['product_name']} PCSysInstaller!</b></font><p/>
500
				<font face="arial" size="+1">This utility will install {$g['product_name']} to a hard disk, flash drive, etc.</font>
501
				<table width="100%" border="0" cellpadding="5" cellspacing="0">
502
			 		<tr>
503
			    		<td>
504
							<center>
505
							<div id="mainarea">
506
								<br/>
507
								<center>
508
								Please select an installer option to begin:
509
								<table width="100%" border="0" cellpadding="5" cellspacing="5">
510
									<tr>
511
			     						<td>
512
											<div id="pfsenseinstaller">
513
												<center>
514
												Rescue config.xml<p/>
515
												Install {$g['product_name']} using the <a href="installer.php?state=quickeasyinstall">UFS</a>
516
												 {$zfs_enabled}
517
												filesystem.
518
												</p>
519
											</div>
520
			     						</td>
521
									</tr>
522
								</table>
523
							</div>
524
						</td>
525
					</tr>
526
				</table>
527
			</div>
528
EOF;
529
	page_table_end();
530
	end_html();
531
}
532
533 58fdcb9c Scott Ullrich
function installer_main() {
534 a33cb07c Scott Ullrich
	global $g, $fstype;
535 8a4cf948 Scott Ullrich
	if(file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log")) 
536
		unlink("/tmp/.pc-sysinstall/pc-sysinstall.log");
537 38405d27 Scott Ullrich
	head_html();
538 5d4f96c6 Scott Ullrich
	body_html();
539 a33cb07c Scott Ullrich
	// Only enable ZFS if this exists.  The install will fail otherwise.
540
	if(file_exists("/boot/gptzfsboot")) 
541
		$zfs_enabled = "or <a href=\"installer.php?state=quickeasyinstall&fstype=ZFS\">ZFS</a> ";
542 5d4f96c6 Scott Ullrich
	$disk = installer_find_first_disk();
543
	if(!$disk) 
544 65effce3 Rafael Lucas
		echo gettext("WARNING: Could not find any suitable disks for installation.");
545 8af6efa6 Scott Ullrich
	page_table_start();
546 5d4f96c6 Scott Ullrich
	echo <<<EOF
547 8a4cf948 Scott Ullrich
		<form action="installer.php" method="post" state="step1_post">
548 8af6efa6 Scott Ullrich
			<div id="mainlevel">
549 8a4cf948 Scott Ullrich
				<center>
550 50d44909 Scott Ullrich
				<b><font face="arial" size="+2">Welcome to the {$g['product_name']} PCSysInstaller!</b></font><p/>
551
				<font face="arial" size="+1">This utility will install {$g['product_name']} to a hard disk, flash drive, etc.</font>
552 8af6efa6 Scott Ullrich
				<table width="100%" border="0" cellpadding="5" cellspacing="0">
553
			 		<tr>
554
			    		<td>
555 8a4cf948 Scott Ullrich
							<center>
556 8af6efa6 Scott Ullrich
							<div id="mainarea">
557
								<br/>
558 8a4cf948 Scott Ullrich
								<center>
559 8af6efa6 Scott Ullrich
								Please select an installer option to begin:
560 524b7a41 Scott Ullrich
								<table width="100%" border="0" cellpadding="5" cellspacing="5">
561 8af6efa6 Scott Ullrich
									<tr>
562 524b7a41 Scott Ullrich
			     						<td>
563 8af6efa6 Scott Ullrich
											<div id="pfsenseinstaller">
564 8a4cf948 Scott Ullrich
												<center>
565 38405d27 Scott Ullrich
												Rescue config.xml<p/>
566 50d44909 Scott Ullrich
												Install {$g['product_name']} using the <a href="installer.php?state=quickeasyinstall">UFS</a>
567 a33cb07c Scott Ullrich
												 {$zfs_enabled}
568 0a680367 Scott Ullrich
												filesystem.
569 8af6efa6 Scott Ullrich
												</p>
570
											</div>
571
			     						</td>
572
									</tr>
573
								</table>
574
							</div>
575
						</td>
576
					</tr>
577
				</table>
578
			</div>
579 58fdcb9c Scott Ullrich
EOF;
580 8af6efa6 Scott Ullrich
	page_table_end();
581 5d4f96c6 Scott Ullrich
	end_html();
582 58fdcb9c Scott Ullrich
}
583
584 dd4be2d0 Scott Ullrich
echo "<pre>";
585
print_r(installer_find_all_disks());
586
echo "</pre>";
587
588 65effce3 Rafael Lucas
?>