summaryrefslogtreecommitdiffstats
path: root/usr/local/www
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2004-12-12 21:15:20 +0000
committerScott Ullrich <sullrich@pfsense.org>2004-12-12 21:15:20 +0000
commitb4ff3ccd3b34441747000ac42f5c266aefe4106c (patch)
tree291cc9924c1be2982998f9437073eab008b9d544 /usr/local/www
parent48e8d40dccb8b53b7205a7c34e473bf15e1f1369 (diff)
downloadpfsense-b4ff3ccd3b34441747000ac42f5c266aefe4106c.zip
pfsense-b4ff3ccd3b34441747000ac42f5c266aefe4106c.tar.gz
* Added progress bar. Needs to be converted from green -> pfSense red
Diffstat (limited to 'usr/local/www')
-rwxr-xr-xusr/local/www/pkg_mgr_install.php73
1 files changed, 69 insertions, 4 deletions
diff --git a/usr/local/www/pkg_mgr_install.php b/usr/local/www/pkg_mgr_install.php
index c8fd24e..8924e7e 100755
--- a/usr/local/www/pkg_mgr_install.php
+++ b/usr/local/www/pkg_mgr_install.php
@@ -30,6 +30,8 @@
require("guiconfig.inc");
require("xmlparse_pkg.inc");
+$pb_percent = 1;
+
/*
* open logging facility
*/
@@ -96,7 +98,9 @@ function exec_command_and_return_text($command) {
* exec_command_and_return_text: execute command and update output window dynamically
*/
function execute_command_return_output($command) {
- global $fd_log;
+ global $fd_log, $pb_percent;
+ if($pb_percent > 100) $pb_percent = 1;
+ update_progress_bar($pb_percent);
$fd = popen($command . " 2>&1 ", "r");
echo "\n<script language=\"JavaScript\">this.document.forms[0].output.value = \"\";</script>";
$counter = 0;
@@ -127,9 +131,17 @@ function execute_command_return_output($command) {
$counter2++;
echo "\n<script language=\"JavaScript\">this.document.forms[0].output.value = this.document.forms[0].output.value + \"" . $text . $extrabreak . "\"; f('output'); </script>";
}
+ $pb_percent++;
fclose($fd);
}
+function update_progress_bar($percent) {
+ if($percent > 100) $percent = 1;
+ echo "\n<script type=\"text/javascript\" language=\"javascript\">";
+ echo "\ndocument.progressbar.style.width='" . $percent . "%';";
+ echo "\n</script>";
+}
+
$a_out = &$pkg_config['packages'];
?>
@@ -183,8 +195,15 @@ if(!$pkg_config['packages']) {
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td>
- <textarea cols="100%" rows="1" name="status" id="status" wrap="hard">One moment please... This will take a while!</textarea>
- <textarea cols="100%" rows="25" name="output" id="output" wrap="hard"></textarea>
+ <!-- progress bar -->
+ <center>
+ <table id="progholder" name="progholder" height='20' border='1' bordercolor='black' width='420' bordercolordark='#000000' bordercolorlight='#000000' style='border-collapse: collapse' colspacing='2' cellpadding='2' cellspacing='2'><tr><td><img border='0' src='progress_bar.gif' width='280' height='23' name='progressbar' id='progressbar'></td></tr></table>
+ <br>
+ <!-- status box -->
+ <textarea cols="60" rows="1" name="status" id="status" wrap="hard">One moment please... This will take a while!</textarea>
+ <!-- command output box -->
+ <textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
+ </center>
</td>
</tr>
</table>
@@ -196,7 +215,10 @@ if(!$pkg_config['packages']) {
</body>
</html>
-<?
+<?php
+
+update_progress_bar($pb_percent);
+$pb_percent += 10;
/* install the package */
@@ -208,6 +230,9 @@ mwexec("mkdir /usr/local/www/ext/Firewall >/dev/null 2>&1");
mwexec("mkdir /usr/local/www/ext/VPN >/dev/null 2>&1");
mwexec("mkdir /usr/local/www/ext/Status >/dev/null 2>&1");
+update_progress_bar($pb_percent);
+$pb_percent += 10;
+
$a_out = &$pkg_config['packages']['package'];
$pkgent = array();
$pkgent['name'] = $pkg_config['packages']['package'][$id]['name'];
@@ -220,6 +245,9 @@ $pkgent['pfsense_package_base'] = $a_out[$id]['pfsense_package_base'];
$pkgent['configurationfile'] = $a_out[$id]['configurationfile'];
$a_out = &$config['packages']['package'];
+update_progress_bar($pb_percent);
+$pb_percent += 10;
+
fwrite($fd_log, "ls /var/db/pkg | grep " . $pkgent['name'] . "\n" . $status);
if($status <> "") {
// package is already installed!?
@@ -229,10 +257,16 @@ if($status <> "") {
update_status("Downloading and installing " . $pkgent['name'] . " - " . $pkgent['pfsense_package'] . " and its dependencies ... This could take a moment ...");
fwrite($fd_log, "Downloading and installing " . $pkgent['name'] . " ... \n");
+update_progress_bar($pb_percent);
+$pb_percent += 10;
+
$text = exec_command_and_return_text("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base'] . "/" . $pkgent['pfsense_package']);
update_output_window($text);
fwrite($fd_log, "Executing: cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base'] . "/" . $pkgent['pfsense_package'] . "\n" . $text);
+update_progress_bar($pb_percent);
+$pb_percent += 10;
+
if ($pkgent['pfsense_package_base']) {
update_status("Downloading and installing " . $pkgent['name'] . " - " . $pkgent['depends_on_package_base'] . " and its dependencies ... This could take a moment ...");
$text = exec_command_and_return_text("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base'] . "/" . $pkgent['depends_on_package']);
@@ -240,8 +274,14 @@ if ($pkgent['pfsense_package_base']) {
fwrite($fd_log, "cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base'] . "/" . $pkgent['depends_on_package'] . "\n" . $text);;
}
+update_progress_bar($pb_percent);
+$pb_percent += 10;
+
$config = parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']);
+update_progress_bar($pb_percent);
+$pb_percent += 10;
+
$config['installedpackages']['package'][] = $pkgent;
if (isset($id) && $a_out[$id])
@@ -249,14 +289,25 @@ if (isset($id) && $a_out[$id])
else
$a_out[] = $pkgent;
+update_progress_bar($pb_percent);
+$pb_percent += 10;
+
write_config();
+update_progress_bar($pb_percent);
+$pb_percent += 10;
+
$name = $pkgent['name'];
+update_progress_bar($pb_percent);
+$pb_percent++;
+
// parse the config file for this package and install neededtext items.
if(file_exists("/usr/local/pkg/" . $pkgent['name'] . ".xml")) {
$config = parse_xml_config("/usr/local/pkg/" . $pkgent['name'] . ".xml", "packagegui");
foreach ($config['modify_system']['item'] as $ms) {
+ update_progress_bar($pb_percent);
+ $pb_percent += 10;
if($ms['textneeded']) {
fwrite($fd_log, "Adding needed text items:\n");
$filecontents = exec_command_and_return_text("cat " . $ms['modifyfilename']);
@@ -279,11 +330,17 @@ if(file_exists("/usr/local/pkg/" . $pkgent['name'] . ".xml")) {
}
fwrite($fd_log, "End of Package Manager installation session.\n");
+update_progress_bar($pb_percent);
+$pb_percent += 10;
+
// return dependency list to output later.
$command = "TODELETE=`ls /var/db/pkg | grep " . $name . "` && /usr/sbin/pkg_info -r \$TODELETE | grep Dependency: | cut -d\" \" -f2";
$dependencies = exec_command_and_return_text($command);
fwrite($fd_log, "Installed " . $name . " and the following dependencies:\n" . $dependencies);
+update_progress_bar($pb_percent);
+$pb_percent += 10;
+
$status = exec_command_and_return_text("ls /var/db/pkg | grep " . $pkgent['name']);
fwrite($fd_log, "ls /var/db/pkg | grep " . $pkgent['name'] . "\n" . $status);
if($status <> "") {
@@ -294,6 +351,9 @@ if($status <> "") {
fwrite($fd_log, "Package WAS NOT installed properly.\n");
}
+update_progress_bar($pb_percent);
+$pb_percent += 10;
+
// close log
fclose($fd_log);
@@ -307,6 +367,11 @@ fclose($fd_log);
$log = ereg_replace("\n", "\\n", $tmp);
echo "\n<script language=\"JavaScript\">this.document.forms[0].output.value = \"" . $log . "\";</script>";
+update_progress_bar(100);
+
+echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>";
+echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>";
+
?>
OpenPOWER on IntegriCloud