Revision 8af6efa6
Added by Scott Ullrich almost 15 years ago
usr/local/www/installer.php | ||
---|---|---|
27 | 27 |
POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
*/ |
29 | 29 |
|
30 |
require("globals.inc"); |
|
30 | 31 |
require("guiconfig.inc"); |
31 | 32 |
|
32 | 33 |
if($g['platform'] == "pfSense" or $g['platform'] == "nanobsd") { |
... | ... | |
91 | 92 |
} |
92 | 93 |
|
93 | 94 |
function start_installation() { |
95 |
global $g; |
|
94 | 96 |
$ps_running = exec("ps awwwux | grep -v grep | grep 'sh /tmp/installer.sh'"); |
95 | 97 |
if($ps_running) |
96 | 98 |
return; |
... | ... | |
106 | 108 |
} |
107 | 109 |
|
108 | 110 |
function installer_find_first_disk() { |
111 |
global $g; |
|
109 | 112 |
$disk = `/PCBSD/pc-sysinstall/pc-sysinstall disk-list | head -n1 | cut -d':' -f1`; |
110 | 113 |
return $disk; |
111 | 114 |
} |
112 | 115 |
|
113 | 116 |
function update_installer_status() { |
117 |
global $g; |
|
114 | 118 |
if(!file_exists("/tmp/.pc-sysinstall/pc-sysinstall.log")) |
115 | 119 |
return; |
116 |
echo `tail -n20 /tmp/.pc-sysinstall/pc-sysinstall.log`; |
|
120 |
// Ensure status files exist |
|
121 |
if(!file_exists("/tmp/installer_installer_running")) |
|
122 |
touch("/tmp/installer_installer_running"); |
|
123 |
if(!file_exists("/tmp/installer_last_progress")) |
|
124 |
touch("/tmp/installer_last_progress"); |
|
125 |
$status = `tail -n20 /tmp/.pc-sysinstall/pc-sysinstall.log`; |
|
126 |
echo "this.document.forms[0].installeroutput.value='$status';\n"; |
|
127 |
$installer_running = trim(file_get_contents("/tmp/installer_installer_running")); |
|
128 |
if($installer_running <> "running") { |
|
129 |
$ps_running = exec("ps awwwux | grep -v grep | grep 'sh /tmp/installer.sh'"); |
|
130 |
if($ps_running) |
|
131 |
echo "\$('installerrunning').innerHTML='<img src=\"/themes/{$g['theme']}/images/misc/loader.gif\"> Installer running...';\n"; |
|
132 |
file_put_contents("/tmp/installer_installer_running", "running"); |
|
133 |
} |
|
134 |
// Find out installer progress |
|
135 |
if(strstr($status, "/boot /mnt/boot")) |
|
136 |
$progress = "1"; |
|
137 |
if(strstr($status, "/COPYRIGHT /mnt/COPYRIGHT")) |
|
138 |
$progress = "2"; |
|
139 |
if(strstr($status, "/bin /mnt/bin")) |
|
140 |
$progress = "5"; |
|
141 |
if(strstr($status, "/conf /mnt/conf")) |
|
142 |
$progress = "10"; |
|
143 |
if(strstr($status, "/conf.default /mnt/conf.default")) |
|
144 |
$progress = "15"; |
|
145 |
if(strstr($status, "/dev /mnt/dev")) |
|
146 |
$progress = "20"; |
|
147 |
if(strstr($status, "/etc /mnt/etc")) |
|
148 |
$progress = "25"; |
|
149 |
if(strstr($status, "/home /mnt/home")) |
|
150 |
$progress = "30"; |
|
151 |
if(strstr($status, "/kernels /mnt/kernels")) |
|
152 |
$progress = "35"; |
|
153 |
if(strstr($status, "/libexec /mnt/libexec")) |
|
154 |
$progress = "40"; |
|
155 |
if(strstr($status, "/lib /mnt/lib")) |
|
156 |
$progress = "45"; |
|
157 |
if(strstr($status, "/root /mnt/root")) |
|
158 |
$progress = "50"; |
|
159 |
if(strstr($status, "/sbin /mnt/sbin")) |
|
160 |
$progress = "55"; |
|
161 |
if(strstr($status, "/sys /mnt/sys")) |
|
162 |
$progress = "60"; |
|
163 |
if(strstr($status, "/usr /mnt/usr")) |
|
164 |
$progress = "70"; |
|
165 |
if(strstr($status, "/usr /mnt/usr")) |
|
166 |
$progress = "80"; |
|
167 |
if(strstr($status, "/var /mnt/var")) |
|
168 |
$progress = "90"; |
|
169 |
if(strstr($status, "Installation finished")) |
|
170 |
$progress = "100"; |
|
171 |
$last_progress = trim(file_get_contents("/tmp/installer_last_progress")); |
|
172 |
if($last_progress <> $progress) |
|
173 |
echo "\ndocument.progressbar.style.width='{$progress}%';\n"; |
|
174 |
file_put_contents("/tmp/installer_last_progress", trim($progress)); |
|
117 | 175 |
if(file_exists("/tmp/install_complete")) { |
118 |
echo "Installation completed.";
|
|
176 |
echo "\$('installerrunning').innerHTML='Installation completed. Please <a href=\"reboot.php\">reboot</a> to continue';\n";
|
|
119 | 177 |
unlink_if_exists("/tmp/installer.sh"); |
178 |
file_put_contents("/tmp/installer_installer_running", "finished"); |
|
120 | 179 |
} |
121 | 180 |
} |
122 | 181 |
|
123 | 182 |
function update_installer_status_win($status) { |
124 |
$ps_running = exec("ps awwwux | grep -v grep | grep 'sh /tmp/installer.sh'");
|
|
183 |
global $g;
|
|
125 | 184 |
echo "<script type=\"text/javascript\">\n"; |
126 |
if($ps_running) |
|
127 |
echo "\$('installerrunning').innerHTML='Installer running...';\n"; |
|
128 |
else |
|
129 |
echo "\$('installerrunning').innerHTML='Installer finished.';\n"; |
|
130 | 185 |
echo "\$('installeroutput').value = '" . str_replace(htmlentities($status), "\n", "") . "';\n"; |
131 | 186 |
echo "installeroutput.scroll = installeroutput.maxScroll;\n"; |
132 | 187 |
echo "</script>"; |
133 | 188 |
} |
134 | 189 |
|
135 | 190 |
function begin_quick_easy_install() { |
191 |
global $g; |
|
136 | 192 |
unlink_if_exists("/tmp/install_complete"); |
137 | 193 |
$disk = installer_find_first_disk(); |
138 | 194 |
if(!$disk) { |
... | ... | |
147 | 203 |
} |
148 | 204 |
|
149 | 205 |
function body_html() { |
206 |
global $g; |
|
150 | 207 |
$pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); |
151 | 208 |
if(strstr($pfSversion, "1.2")) |
152 | 209 |
$one_two = true; |
... | ... | |
171 | 228 |
}); |
172 | 229 |
} |
173 | 230 |
function installcallback(transport) { |
174 |
this.document.forms[0].installeroutput.value=transport.responseText;
|
|
231 |
eval(transport.responseText);
|
|
175 | 232 |
setTimeout('getinstallerprogress()', 1000); |
176 | 233 |
} |
177 | 234 |
</script> |
178 | 235 |
EOF; |
179 |
include("fbegin.inc"); |
|
180 | 236 |
|
181 | 237 |
if($one_two) |
182 | 238 |
echo "<p class=\"pgtitle\">{$pgtitle}</font></p>"; |
... | ... | |
185 | 241 |
} |
186 | 242 |
|
187 | 243 |
function end_html() { |
244 |
global $g; |
|
188 | 245 |
echo "</form>"; |
189 |
include("fend.inc"); |
|
190 | 246 |
echo "</body>"; |
191 | 247 |
echo "</html>"; |
192 | 248 |
} |
193 | 249 |
|
194 | 250 |
function template() { |
251 |
global $g; |
|
195 | 252 |
body_html(); |
196 | 253 |
echo <<<EOF |
197 | 254 |
<div id="mainlevel"> |
... | ... | |
220 | 277 |
} |
221 | 278 |
|
222 | 279 |
function quickeasyinstall_gui() { |
280 |
global $g; |
|
223 | 281 |
body_html(); |
282 |
page_table_start(); |
|
224 | 283 |
echo <<<EOF |
225 |
<div id="mainlevel"> |
|
226 |
<table width="100%" border="0" cellpadding="0" cellspacing="0"> |
|
227 |
<tr> |
|
228 |
<td> |
|
229 |
<div id="mainarea"> |
|
230 |
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> |
|
231 |
<tr> |
|
232 |
<td class="tabcont" > |
|
233 |
<form action="installer.php" method="post" state="step1_post"> |
|
234 |
<div id="pfsenseinstaller"> |
|
235 |
<div id='installerrunning'> |
|
236 |
Starting Installer... Please wait...<p/> |
|
237 |
</div> |
|
238 |
{{ Insert progressbar here }}<p/> |
|
239 |
<textarea name='installeroutput' id='installeroutput' rows="30" cols="80"> |
|
240 |
</textarea> |
|
241 |
</div> |
|
242 |
</td> |
|
243 |
</tr> |
|
244 |
</table> |
|
245 |
</div> |
|
246 |
</td> |
|
247 |
</tr> |
|
284 |
<form action="installer.php" method="post" state="step1_post"> |
|
285 |
<center> |
|
286 |
<table width="100%"> |
|
287 |
<tr><td> |
|
288 |
<div id="mainlevel"> |
|
289 |
<table width="100%" border="0" cellpadding="0" cellspacing="0"> |
|
290 |
<tr> |
|
291 |
<td> |
|
292 |
<div id="mainarea"> |
|
293 |
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> |
|
294 |
<tr> |
|
295 |
<td class="tabcont" > |
|
296 |
<div id="pfsenseinstaller" width="100%"> |
|
297 |
<div id='installerrunning' width='100%' style="padding:2em; border:1px solid #000000"> |
|
298 |
<img src="/themes/{$g['theme']}/images/misc/loader.gif"> Starting Installer... Please wait...<p/> |
|
299 |
</div> |
|
300 |
<br/> |
|
301 |
<table width="100%" height="15" colspacing="0" cellpadding="0" cellspacing="0" border="0" align="top" nowrap> |
|
302 |
<tr> |
|
303 |
<td width="5" height="15" background="./themes/{$g['theme']}/images/misc/bar_left.gif" align="top"> |
|
304 |
</td> |
|
305 |
<td> |
|
306 |
<table WIDTH="100%" height="15" colspacing="0" cellpadding="0" cellspacing="0" border="0" align="top" nowrap> |
|
307 |
<tr> |
|
308 |
<td background="./themes/{$g['theme']}/images/misc/bar_gray.gif"> |
|
309 |
<img src='./themes/{$g['theme']}/images/misc/bar_blue.gif' height='15' WIDTH='1%'> |
|
310 |
</td> |
|
311 |
</tr> |
|
312 |
</table> |
|
313 |
</td> |
|
314 |
<td width="5" height="15" background="./themes/{$g['theme']}/images/misc/bar_right.gif" align="top"> |
|
315 |
</td> |
|
316 |
</tr> |
|
317 |
</table> |
|
318 |
<br/> |
|
319 |
<textarea name='installeroutput' id='installeroutput' rows="30" cols="80"> |
|
320 |
</textarea> |
|
321 |
</div> |
|
322 |
</td> |
|
323 |
</tr> |
|
324 |
</table> |
|
325 |
</div> |
|
326 |
</td> |
|
327 |
</tr> |
|
328 |
</table> |
|
329 |
</div> |
|
330 |
</td></tr> |
|
248 | 331 |
</table> |
249 |
</div>
|
|
332 |
</center>
|
|
250 | 333 |
<script type="text/javascript">setTimeout('getinstallerprogress()', 250);</script> |
334 |
|
|
251 | 335 |
EOF; |
336 |
page_table_end(); |
|
252 | 337 |
end_html(); |
253 | 338 |
begin_quick_easy_install(); |
254 | 339 |
} |
255 | 340 |
|
341 |
function page_table_start() { |
|
342 |
global $g; |
|
343 |
echo <<<EOF |
|
344 |
<center> |
|
345 |
<img border="0" src="./themes/{$g['theme']}/images/logo.gif"></a> |
|
346 |
<table cellpadding="5" cellspacing="0" width="640" height="480" style="border:1px solid #000000"> |
|
347 |
<tr height="10" bgcolor="#990000"> |
|
348 |
<td style="border-bottom:1px solid #000000"> |
|
349 |
<font color='white'> |
|
350 |
<b> |
|
351 |
pfSense installer |
|
352 |
</b> |
|
353 |
</font> |
|
354 |
</td> |
|
355 |
</tr> |
|
356 |
<tr> |
|
357 |
<td> |
|
358 |
|
|
359 |
EOF; |
|
360 |
|
|
361 |
} |
|
362 |
|
|
363 |
function page_table_end() { |
|
364 |
global $g; |
|
365 |
echo <<<EOF |
|
366 |
</td> |
|
367 |
</tr> |
|
368 |
</table> |
|
369 |
</center> |
|
370 |
|
|
371 |
EOF; |
|
372 |
|
|
373 |
} |
|
374 |
|
|
256 | 375 |
function installer_main() { |
376 |
global $g; |
|
257 | 377 |
body_html(); |
258 | 378 |
$disk = installer_find_first_disk(); |
259 | 379 |
if(!$disk) |
260 | 380 |
echo "WARNING: Could not find any suitable disks for installation."; |
381 |
page_table_start(); |
|
261 | 382 |
echo <<<EOF |
262 |
<div id="mainlevel"> |
|
263 |
This utility will install pfSense to a hard disk, flash drive, etc. |
|
264 |
<table width="100%" border="0" cellpadding="5" cellspacing="0"> |
|
265 |
<tr> |
|
266 |
<td> |
|
267 |
<div id="mainarea"> |
|
268 |
<br/> |
|
269 |
Please select an installer option to begin: |
|
270 |
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0"> |
|
271 |
<tr> |
|
272 |
<td class="tabcont" > |
|
273 |
<form action="installer.php" method="post" state="step1_post"> |
|
274 |
<div id="pfsenseinstaller"> |
|
275 |
<a onClick="return confirm('Are you sure you want to install pfSense to $disk?');" href='installer.php?state=quickeasyinstall'>Quick/Easy installation</a> |
|
276 |
</p> |
|
277 |
</div> |
|
278 |
</td> |
|
279 |
</tr> |
|
280 |
</table> |
|
281 |
</div> |
|
282 |
</td> |
|
283 |
</tr> |
|
284 |
</table> |
|
285 |
</div> |
|
383 |
<div id="mainlevel">
|
|
384 |
This utility will install pfSense to a hard disk, flash drive, etc.
|
|
385 |
<table width="100%" border="0" cellpadding="5" cellspacing="0">
|
|
386 |
<tr>
|
|
387 |
<td>
|
|
388 |
<div id="mainarea">
|
|
389 |
<br/>
|
|
390 |
Please select an installer option to begin:
|
|
391 |
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
|
392 |
<tr>
|
|
393 |
<td class="tabcont" >
|
|
394 |
<form action="installer.php" method="post" state="step1_post">
|
|
395 |
<div id="pfsenseinstaller">
|
|
396 |
<a onClick="return confirm('Are you sure you want to install pfSense to $disk?');" href='installer.php?state=quickeasyinstall'>Quick/Easy installation</a>
|
|
397 |
</p>
|
|
398 |
</div>
|
|
399 |
</td>
|
|
400 |
</tr>
|
|
401 |
</table>
|
|
402 |
</div>
|
|
403 |
</td>
|
|
404 |
</tr>
|
|
405 |
</table>
|
|
406 |
</div>
|
|
286 | 407 |
EOF; |
408 |
page_table_end(); |
|
287 | 409 |
end_html(); |
288 | 410 |
} |
289 | 411 |
|
Also available in: Unified diff
Make installer html look more like an installer, add progress bar. Output javascript.