summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2008-05-24 04:56:57 +0000
committerScott Ullrich <sullrich@pfsense.org>2008-05-24 04:56:57 +0000
commitda55e467dde94534c6ac83cee329d9800b07467c (patch)
tree9169eb8675891d24ef96a5fe6265f515a9eb6a03 /usr
parentffb90d9dfbc86f16a9d73bbc3089c850bd9e3c4f (diff)
downloadpfsense-da55e467dde94534c6ac83cee329d9800b07467c.zip
pfsense-da55e467dde94534c6ac83cee329d9800b07467c.tar.gz
Just because elvis is dead, does not mean our auto updating system
needs to be. Bring it back from the dead and make it match the new world order. Add a custom URL firmware update page which will have snapshot support shortly.
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/system_firmware.php9
-rwxr-xr-xusr/local/www/system_firmware_auto.php240
-rwxr-xr-xusr/local/www/system_firmware_check.php326
-rwxr-xr-xusr/local/www/system_firmware_settings.php72
4 files changed, 282 insertions, 365 deletions
diff --git a/usr/local/www/system_firmware.php b/usr/local/www/system_firmware.php
index b6270ba..ea25156 100755
--- a/usr/local/www/system_firmware.php
+++ b/usr/local/www/system_firmware.php
@@ -31,6 +31,10 @@
$d_isfwfile = 1;
require_once("guiconfig.inc");
+
+$curcfg = $config['system']['firmware'];
+
+
require_once("xmlrpc_client.inc");
/* Allow additional execution time 0 = no limit. */
@@ -135,6 +139,7 @@ if ($_POST && !file_exists($d_firmwarelock_path)) {
}
}
+$pgtitle = array("Diagnostics","Firmware");
include("head.inc");
?>
@@ -165,8 +170,8 @@ print_info_box($sig_warning);
<?php
$tab_array = array();
$tab_array[0] = array("Manual Update", true, "system_firmware.php");
- //$tab_array[1] = array("Auto Update", false, "system_firmware_check.php");
- //$tab_array[2] = array("Updater Settings", false, "system_firmware_settings.php");
+ $tab_array[1] = array("Auto Update", false, "system_firmware_check.php");
+ $tab_array[2] = array("Updater Settings", false, "system_firmware_settings.php");
display_top_tabs($tab_array);
?>
</td>
diff --git a/usr/local/www/system_firmware_auto.php b/usr/local/www/system_firmware_auto.php
index 7a4b339..285eed2 100755
--- a/usr/local/www/system_firmware_auto.php
+++ b/usr/local/www/system_firmware_auto.php
@@ -1,11 +1,12 @@
+#!/usr/local/bin/php
<?php
/* $Id$ */
/*
system_firmware_auto.php
- part of pfSense (http://www.pfsense.com)
-
- Copyright (C) 2005 Scott Ullrich and Colin Smith
+ Copyright (C) 2005 Scott Ullrich
+ Based originally on system_firmware.php
+ (C)2003-2004 Manuel Kasper
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -28,60 +29,76 @@
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
- TODO:
- * modify pfSense.com XMLRPC server to return md5 hashes of firmware updates.
*/
-Header("Location: system_firmware.php");
-exit;
+require("guiconfig.inc");
+
+$curcfg = $config['system']['firmware'];
-require_once("guiconfig.inc");
-require_once("xmlrpc.inc");
+if(isset($curcfg['alturl']['enable'])
+ $updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
-$pgtitle = array("System","Firmware","Auto Update");
+$pgtitle = array("Diagnostics","Firmware","Auto Update");
include("head.inc");
?>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link href="gui.css" rel="stylesheet" type="text/css">
+</head>
+
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+
<?php include("fbegin.inc"); ?>
<form action="system_firmware_auto.php" method="post">
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td>
+<table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td>
<?php
$tab_array = array();
- $tab_array[0] = array("Manual Update", false, "system_firmware.php");
- $tab_array[1] = array("Auto Update", true, "system_firmware_check.php");
+ $tab_array[0] = array("Manual Update", true, "system_firmware.php");
+ $tab_array[1] = array("Auto Update", false, "system_firmware_check.php");
$tab_array[2] = array("Updater Settings", false, "system_firmware_settings.php");
display_top_tabs($tab_array);
?>
- </td>
- </tr>
+ </td>
+ </tr>
<tr>
- <td>
- <div id="mainarea">
- <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td>
- <!-- 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='./themes/<?= $g['theme']; ?>/images/misc/progress_bar.gif' width='280' height='23' name='progressbar' id='progressbar'></td></tr></table>
- <br>
- <!-- status box -->
- <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols="60" rows="1" name="status" id="status" wrap="hard">
- Beginning system autoupdate...
- </textarea>
- <!-- command output box -->
- <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols="60" rows="25" name="output" id="output" wrap="hard">
- </textarea>
- </center>
- </td>
- </tr>
+ <td class="tabcont">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td class="tabcont">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td>
+ <center>
+ <table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
+
+ <tr>
+ <td background="./themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
+ </td>
+ <td>
+ <table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
+ <td background="./themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
+ <img src='./themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
+ </td>
+ </table>
+ </td>
+ <td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
+ </td>
+ </tr>
+ </table>
+ <br>
+ <!-- status box -->
+ <textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
+ <!-- command output box -->
+ <textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
+ </center>
+ </td>
+ </tr>
</table>
- </div>
+ </table>
</td>
</tr>
</table>
@@ -92,72 +109,107 @@ include("head.inc");
<?php
-/* Define necessary variables. */
-$update_types = array('full', 'diff');
-$didupdate = false;
+update_status("Downloading current version information...");
+$latest_version = download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
+
+$current_installed_pfsense_version = str_replace("\n", "", file_get_contents("/etc/version"));
+$latest_version = str_replace("\n", "", file_get_contents("/tmp/{$g['product_name']}_version"));
+
+if($current_installed_pfsense_version <> $latest_version)
+ $needs_system_upgrade = true;
-if($_GET['category'] == 'full') {
- $tocheck = 'all';
- $categories = array('firmware', 'kernel', 'base');
+if($needs_system_upgrade == true) {
+ update_status("Downloading updates ...");
+ $status = download_file_with_progress_bar("{$updater_url}/latest.tgz", "/tmp/latest.tgz");
+ $status = download_file_with_progress_bar("{$updater_url}/latest.tgz.sha256", "/tmp/latest.tgz.sha256");
+ update_output_window("{$g['product_name']} download complete.");
+}
+
+/* launch external upgrade helper */
+$external_upgrade_helper_text = "/etc/rc.firmware pfSenseupgrade ";
+if($needs_system_upgrade == true)
+ $external_upgrade_helper_text .= "/tmp/latest.tgz";
+
+$downloaded_latest_tgz_sha256 = str_replace("\n", "", `sha256 /tmp/latest.tgz | awk '{ print $4 }'`);
+$upgrade_latest_tgz_sha256 = str_replace("\n", "", `cat /tmp/latest.tgz.sha256 | awk '{ print $4 }'`);
+
+if($downloaded_latest_tgz_sha256 <> $upgrade_latest_tgz_sha256) {
+ update_status("Downloading complete but sha256 does not match.");
+ update_output_window("Auto upgrade aborted. \n\nDownloaded SHA256: $downloaded_latest_tgz_sha256 \n\nNeeded SHA256: $upgrade_latest_tgz_sha256");
} else {
- $tocheck = array($_GET['category']);
- $categories = $tocheck;
+ update_status("Downloading complete.");
+ update_output_window("{$g['product_name']} is now upgrading.\\n\\nThe firewall will reboot once the operation is completed.");
+ echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';\n</script>";
+ exec_rc_script_async("{$external_upgrade_helper_text}");
}
-$static_output = "Downloading current version information... ";
-update_status($static_output);
-update_output_window($static_output);
+/*
+ Helper functions
+*/
-if(file_exists("/tmp/versioncheck.cache")) {
- $versions = unserialize("/tmp/versioncheck.cache");
- if(time() - $versions['cachetime'] > 300) { // Our cached data is stale, get a new copy.
- $versions = check_firmware_version($tocheck);
- } else { // Our cached data is relatively currently, remove the cachetime label.
- unset($versions['cachetime']);
+function download_file_with_progress_bar($url_file, $destination_file) {
+ global $ch, $fout, $file_size, $downloaded, $counter;
+ $file_size = 1;
+ $downloaded = 1;
+ /* open destination file */
+ $fout = fopen($destination_file, "wb");
+
+ /*
+ Originally by Author: Keyvan Minoukadeh
+ Modified by Scott Ullrich to return Content-Length size
+ */
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_URL, $url_file);
+ curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header');
+ curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'read_body');
+ curl_setopt($ch, CURLOPT_NOPROGRESS, '1');
+
+ curl_exec($ch);
+ fclose($fout);
+ return 1;
+
+ if ($error = curl_error($ch)) {
+ return -1;
}
}
-$static_output .= "done.\n";
-update_output_window($static_output);
-
-foreach($categories as $index => $key) {
- $bdiff_errors = array();
- if(is_array($versions[$key][0])) { // Make sure we really need to update this section.
- $didupdate = true;
- update_status("Found required " . $key . " updates. Downloading...");
- $static_output .= "Downloading " . $key . " updates... ";
- update_output_window($static_output);
- foreach($versions[$key] as $ver) { // Begin system updates.
- foreach($update_types as $type) if(in_array($type, array_keys($ver))) $url_type = $type;
- $tofetch = "pfSense-" . ucfirst($url_type) . "-" . ucfirst($key) . "-Update-" . $ver['version'] . ".tgz";
- $static_output_bak = $static_output;
- $static_output .= "\n\t" . $ver['version'] . "-" . $ver['name'] . " ";
- update_output_window($static_output);
- download_file_with_progress_bar("http://www.pfsense.com/updates/" . $tofetch, "/tmp/" . $tofetch);
- if($url_type == "binary") {
- exec("/etc/rc.firmware delta_update " . "/tmp/" . $tofetch, $bdiff_errors);
- if(is_string($bdiff_errors[0])) {
- unlink_if_exists("/tmp/" . $tofetch);
- $static_output .= "failed!\n";
- update_output_window($static_output);
- break;
- }
- } else {
- $tofetch = "pfSense-" . ucfirst($url_type) . "-Update-" . $ver['version'] . ".tgz";
- exec("/etc/rc.firmware pfSenseupgrade " . "/tmp/" . $tofetch);
- unlink_if_exists("/tmp/" . $tofetch);
- }
- $static_output = $static_output_bak . "done.\n";
- }
+function read_header($ch, $string) {
+ global $file_size, $ch, $fout;
+ $length = strlen($string);
+ ereg("(Content-Length:) (.*)", $string, $regs);
+ if($regs[2] <> "") {
+ $file_size = intval($regs[2]);
}
+ return $length;
}
-if($didupdate == true) {
- update_status("Update finished. Rebooting...");
- exec("/etc/rc.reboot");
-} else {
- update_status("No updates required.");
+function read_body($ch, $string) {
+ global $fout, $file_size, $downloaded, $counter, $version, $latest_version, $current_installed_pfsense_version;
+ $length = strlen($string);
+ $downloaded += intval($length);
+ $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0);
+ $downloadProgress = 100 - $downloadProgress;
+ $a = $file_size;
+ $b = $downloaded;
+ $c = $downloadProgress;
+ $text = " Auto Update Download Status\\n";
+ $text .= "---------------------------------\\n";
+ $text .= " Latest Version : {$latest_version}\\n";
+ $text .= " Current Version : {$current_installed_pfsense_version}\\n";
+ $text .= " File size : {$a}\\n";
+ $text .= " Downloaded : {$b}\\n";
+ $text .= " Percent : {$c}%\\n";
+ $text .= "---------------------------------\\n";
+ $counter++;
+ if($counter > 150) {
+ update_output_window($text);
+ update_progress_bar($downloadProgress);
+ $counter = 0;
+ }
+ fwrite($fout, $string);
+ echo "<script language='javascript'>'>document.progressbar.style.width=\"$c%\";</script>\n";
+ return $length;
}
-echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';\n</script>";
-?>
+?> \ No newline at end of file
diff --git a/usr/local/www/system_firmware_check.php b/usr/local/www/system_firmware_check.php
index e3fec38..4298991 100755
--- a/usr/local/www/system_firmware_check.php
+++ b/usr/local/www/system_firmware_check.php
@@ -1,232 +1,150 @@
<?php
/* $Id$ */
/*
- system_firmware.php
- Copyright (C) 2004, 2005 Scott Ullrich and Colin Smith
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
+ system_firmware.php
+ part of m0n0wall (http://m0n0.ch/wall)
+
+ Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
-Header("Location: system_firmware.php");
-exit;
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
-require_once("guiconfig.inc");
-require_once("xmlrpc.inc");
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+$d_isfwfile = 1;
+require("guiconfig.inc");
-if(isset($config['system']['disablefirmwarecheck']))
- Header("Location: system_firmware.php");
+$curcfg = $config['system']['firmware'];
-$versions = check_firmware_version();
-$pgtitle = array("System","Firmware","Auto Update");
include("head.inc");
?>
+
+<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link href="gui.css" rel="stylesheet" type="text/css">
+</head>
+
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+
<?php include("fbegin.inc"); ?>
- <SCRIPT>
- <!--
- function toggleTable (table, img) {
- var table = document.getElementById(table);
- var img = document.getElementById(img);
- if (table.rows[0].style.display == 'none') {
- for (var r = 0; r < table.rows.length; r++)
- table.rows[r].style.display = '';
- img.src = "./themes/<?= $g['theme']; ?>/images/misc/tri_o_black.gif";
- } else {
- for (var r = 0; r < table.rows.length; r++)
- table.rows[r].style.display = 'none';
- img.src = "./themes/<?= $g['theme']; ?>/images/misc/tri_c_black.gif";
- }
- }
- //-->
- </SCRIPT>
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td>
+<p class="pgtitle">System: Firmware: Auto Upgrade</p>
+
+<form action="system_firmware_auto.php" method="post">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td>
<?php
$tab_array = array();
$tab_array[0] = array("Manual Update", false, "system_firmware.php");
- $tab_array[1] = array("Auto Update", true, "system_firmware_check.php");
+ $tab_array[1] = array("Auto Update Check", true, "system_firmware_check.php");
$tab_array[2] = array("Updater Settings", false, "system_firmware_settings.php");
display_top_tabs($tab_array);
?>
- </td>
- </tr>
- <tr>
- <td>
-<?php
-if(is_array($versions)) {
-?>
- <div id="mainarea">
- <table align="center" width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont">
- <tr>
- <td width="10%" class="listhdrr">Act</td>
- <td width="30%" class="listhdrr">Category</td>
- <td width="30%" class="listhdrr">Installed</td>
- <td width="30%" class="listhdrr">Current<td>
- </tr>
-<?php
- $currentvers = $versions['current'];
- foreach($versions as $key => $version) {
- if($key == "current") continue;
- $currentver = array_shift(explode('-', $currentvers[$key]['version']));
- if($version == 1) {
- $img = "./themes/".$g['theme']."/images/icons/icon_pass.gif";
- $pastlatest = true;
- } elseif( strcmp($currentver , $version[count($version) - 1]['version']) ){
- $img = "./themes/".$g['theme']."/images/icons/icon_pass.gif";
- $pastlatest = true;
- } else {
- $allinstall = true;
- $img = "./themes/".$g['theme']."/images/icons/icon_block.gif";
- }
-?>
- <tr valign="top">
- <td class="listlr" nowrap align="middle"><img src="<?=$img;?>" width="11" height="11" align="absmiddle"></td>
- <td class="listlr"><?= ucfirst($key) ?></td>
- <td class="listlr"><?= $currentver ?></td>
-<?php
- if($version == 1) {
-?>
- <td class="listlr"><?= $currentver ?></td>
-<?php
- } elseif($pastlatest) {
- $newver = $version[count($version) - 1]['version'];
-?>
- <td class="listbggrey"><font color="#FFFFFF"><?= $newver ?></td>
-<?php
- } else {
- $newver = $version[count($version) - 1]['version'];
-?>
- <td class="listbg"><font color="#FFFFFF"><?= $newver ?></td>
-<?php
- }
- if(!$pastlatest) {
-?>
- <td valign="middle" class="list" nowrap>
- <a href="system_firmware_auto.php?category=<?=$key;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
- </td>
-<?php
- }
-?>
- </tr>
-<?php
- }
-?>
- </table>
-<?php
- if($allinstall) {
-?>
- <br>
- <br>
- <table align="center" width="80%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td align="center"><a href="javascript:toggleTable('updates', 'tri_updates')"><img src="./themes/<?= $g['theme']; ?>/images/misc/tri_c_black.gif" id="tri_updates" width="14" height="10" border="0"></a><strong><a href="javascript:toggleTable('updates', 'tri_updates')">Needed Updates</a></strong></td>
- </tr>
- <tr>
- <td>
- <br>
- <br>
- <table id="updates" align="center" width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td width="20%" class="listhdrr">Released</td>
- <td width="20%" class="listhdrr">Category</td>
- <td width="20%" class="listhdrr">Version</td>
- <td width="20%" class="listhdrr">Size</td>
- <td width="20%" class="listhdr">Type</td>
- </tr>
-<?php
- if(is_array($versions)) {
- foreach($versions as $key => $value) {
- if(($key == "current") or ($value == 1)) continue;
- if(is_array($value)) {
- foreach($value as $version) {
- if(!$version['time']) $version['time'] = "Unknown";
- if(!$version['size']) $version['size'] = "Unknown";
- if(!$version['type']) $version['type'] = "Unknown";
- $version['category'] = $key;
- $times[$version['time']][] = $version;
- }
- }
- }
- }
- asort($times);
- if(is_array($times)) {
- foreach($times as $time) {
- foreach($time as $version) {
-?>
- <tr>
- <td class="listlr">
-<?php
- if($version['time'] != "Unknown") {
- echo date("D M j G:i:s", $version['time']);
- } else {
- echo $version['time'];
- }
-?>
- </td>
- <td class="listlr"><?= ucfirst($version['category']) ?></td>
- <td class="listlr"><?= $version['version'] ?></td>
- <td class="listlr"><?= $version['size'] ?></td>
- <td class="listlr"><?= ucfirst($version['type']) ?></td>
- </tr>
-<?php
- }
- }
- }
-?>
+ </td>
+ </tr>
+ <tr>
+ <td class="tabcont">
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td>
+ <!-- progress bar -->
+ <center>
+ <table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
+
+ <tr>
+ <td background="./themes/the_wall/images/misc/bar_left.gif" height='15' width='5'>
+ </td>
+ <td>
+ <table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
+ <td background="./themes/the_wall/images/misc/bar_gray.gif" valign="top" align="left">
+ <img src='./themes/the_wall/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
+ </td>
</table>
- <br>
- <br>
- <script language="javascript">toggleTable('updates', 'tri_updates');</script>
</td>
- </tr>
- </table>
- <table align="center">
- <tr>
- <td>
- <form action="system_firmware_auto.php" method="post" enctype="multipart/form-data">
- <input name="full" type="submit" class="formbtn" value="Begin Full Update">
- </form>
+ <td background="./themes/the_wall/images/misc/bar_right.gif" height='15' width='5'>
</td>
</tr>
</table>
- </div>
+ <br>
+ <!-- command output box -->
+ <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols='60' rows='7' name='output' id='output' wrap='hard'>
+ </textarea>
+ </center>
+ <p>
+ <center><input id='invokeupgrade' style='visibility:hidden' type="submit" value="Invoke Auto Upgrade">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+
+<p>
+
<?php
- }
+
+/* Define necessary variables. */
+$firmware_version = trim(file_get_contents('/etc/version'));
+
+$static_text = "Downloading current version information... ";
+update_output_window($static_text);
+
+$static_text .= "done.\n";
+update_output_window($static_text);
+
+if(isset($curcfg['alturl']['enable']))
+ $updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
+
+update_status("Downloading current version information...");
+$latest_version = download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
+
+$current_installed_pfsense_version = str_replace("\n", "", file_get_contents("/etc/version"));
+$latest_version = str_replace("\n", "", file_get_contents("/tmp/{$g['product_name']}_version"));
+
+$needs_system_upgrade = false;
+if($current_installed_pfsense_version <> $latest_version)
+ $needs_system_upgrade = true;
+
+if(!$latest_version) {
+ if(isset($curcfg['alturl']['enable']))
+ update_output_window("Could not contact custom update server.");
+ else
+ update_output_window("Could not contact {$g['product_name']} update server.");
} else {
- print_info_box("Unable to receive version information.");
+ if($needs_system_upgrade) {
+ echo "\n<script language=\"JavaScript\">$('invokeupgrade').style.visibility = 'visible';</script>";
+ update_output_window("A new version is now available. \n\nNew version: {$latest_version}");
+ } else {
+ update_output_window("You are on the latest version.");
+ }
}
?>
- </td>
- </tr>
- </table>
-<?php
-include("fend.inc");
-$versions['cachetime'] = time();
-$fout = fopen("/tmp/versioncheck.cache", "w");
-fwrite($fout, serialize($versions));
-fclose($fout);
-?>
- </body>
+
+</form>
+<?php include("fend.inc"); ?>
+</body>
</html>
+
+
+</body>
+</html> \ No newline at end of file
diff --git a/usr/local/www/system_firmware_settings.php b/usr/local/www/system_firmware_settings.php
index 165a995..a620fcd 100755
--- a/usr/local/www/system_firmware_settings.php
+++ b/usr/local/www/system_firmware_settings.php
@@ -27,27 +27,16 @@
POSSIBILITY OF SUCH DAMAGE.
*/
-Header("Location: system_firmware.php");
-exit;
-
require("guiconfig.inc");
if ($_POST) {
- /* input validation */
- if($_POST['firmwareurl'] && !is_string($_POST['firmwareurl'])) {
- $input_errors[] = "The base XMLRPC URL must be a string.";
- }
- if($_POST['firmwarepath'] && !is_string($_POST['firmwarepath'])) {
- $input_errors[] = "The XMLRPC path must be a string.";
- }
if (!$input_errors) {
- $config['system']['firmware']['branch'] = $_POST['branch'];
if($_POST['alturlenable'] == "yes") {
- $config['system']['firmware']['alturl']['enable'] = "";
+ $config['system']['firmware']['alturl']['enable'] = true;
$config['system']['firmware']['alturl']['firmwareurl'] = $_POST['firmwareurl'];
- $config['system']['firmware']['alturl']['firmwarepath'] = $_POST['firmwarepath'];
} else {
unset($config['system']['firmware']['alturl']['enable']);
+ unset($config['system']['firmware']['alturl']['firmwareurl']);
}
write_config();
}
@@ -62,27 +51,13 @@ include("head.inc");
<script language="JavaScript">
<!--
-var systemdescs=new Array(4);
-systemdescs[0]="This patch system uses a combination of unified and binary diffs. This system requires the least bandwidth, but is less forgiving of errors.";
-systemdescs[1]="This patch system uses tar files to update the system. This requires the most bandwidth, but is more reliable.";
-systemdescs[2]="This patch system uses tar files for the kernel and base system, and unified diffs for other components.";
-var branchinfo=new Array(4);
-branchinfo[0]="The stable branch contains only those updates believed to be stable by the developers.";
-branchinfo[1]="This branch contains both stable updates as well as those believed to be fairly stable.";
-branchinfo[2]="This branch contains all released updates, regardless of stability.";
-
-function update_description(itemnum) {
- document.forms[0].branchinfo.value=branchinfo[itemnum];
-}
function enable_altfirmwareurl(enable_over) {
if (document.iform.alturlenable.checked || enable_over) {
document.iform.firmwareurl.disabled = 0;
- document.iform.firmwarepath.disabled = 0;
} else {
document.iform.firmwareurl.disabled = 1;
- document.iform.firmwarepath.disabled = 1;
}
}
@@ -111,50 +86,17 @@ function enable_altfirmwareurl(enable_over) {
<tr>
<td colspan="2" valign="top" class="listtopic">Firmware Branch</td>
</tr>
+
<tr>
- <td valign="top" class="vncell">Firmware Branch</td>
- <td class="vtable">
- <select onChange="update_description(this.selectedIndex);" name="branch" id="branch">
- <option value="stable"<?php if($curcfg['branch']=="stable") echo " SELECTED"; ?>>Stable</option>
- <option value="beta"<?php if($curcfg['branch']=="beta") echo " SELECTED"; ?>>Beta</option>
- <option value="alpha"<?php if($curcfg['branch']=="alpha") echo " SELECTED"; ?>>Alpha</option>
- </select>
- <br>
- <textarea cols="60" rows="2" id="branchinfo" name="branchinfo"style="padding:5px; border:1px dashed #990000; background-color: #ffffff; color: #000000; font-size: 8pt;">
- </textarea>
- <script language="javascript">
- update_description(document.forms[0].branch.selectedIndex);
- </script>
- <br><span class="vexpl">Select the update branch you would like this system to track.</td>
- </tr>
- <tr>
- <td valign="top" class="vncell">Firmware XMLRPC URL</td>
+ <td valign="top" class="vncell">Firmware Auto Update URL</td>
<td class="vtable">
- <input name="alturlenable" type="checkbox" id="alturlenable" value="yes" onClick="enable_altfirmwareurl()" <?php if(isset($curcfg['alturl']['enable'])) echo "checked"; ?>> Use a different XMLRPC server for firmware upgrades<br>
+ <input name="alturlenable" type="checkbox" id="alturlenable" value="yes" onClick="enable_altfirmwareurl()" <?php if(isset($curcfg['alturl']['enable'])) echo "checked"; ?>> Use a different URL server for firmware upgrades<br>
<table>
- <tr><td>Base URL:</td><td><input name="firmwareurl" type="input" class="formfld url" id="firmwareurl" size="64" value="<?php if($curcfg['alturl']['firmwareurl']) echo $curcfg['alturl']['firmwareurl']; else echo $g['xmlrpcbaseurl']; ?>"></td></tr>
- <tr><td>Path:</td><td><input name="firmwarepath" type="input" class="formfld unknown"id="firmwarepath" size="64" value="<?php if($curcfg['alturl']['firmwarepath']) echo $curcfg['alturl']['firmwarepath']; else echo $g['xmlrpcpath']; ?>"></td></tr>
+ <tr><td>Base URL:</td><td><input name="firmwareurl" type="input" class="formfld url" id="firmwareurl" size="64" value="<?php if($curcfg['alturl']['firmwareurl']) echo $curcfg['alturl']['firmwareurl']; else echo $g['']; ?>"></td></tr>
</table>
- <span class="vexpl">This is where {$g['product_name']} will check for newer firmware versions when the <a href="system_firmware_check.php">System: Firmware: Auto Update</a> page is viewed.</span></td>
+ <span class="vexpl">This is where <?php echo $g['product_name'] ?> will check for newer firmware versions when the <a href="system_firmware_check.php">System: Firmware: Auto Update</a> page is viewed.</span></td>
</tr>
<script>enable_altfirmwareurl();</script>
-<!--
- <tr>
- <td width="22%" valign="top" class="vncell">Update Preference</td>
- <td width="78%" class="vtable">
- <select onChange="update_description(branchinfo, this.selectedIndex);" name="branch" id="branch">
- <option value="patches"<?php if($curcfg['updates']=="diffs") echo " SELECTED"; ?>>Patches</option>
- <option value="full"<?php if($curcfg['updates']=="full") echo " SELECTED"; ?>>Full Updates</option>
- <option value="combination"<?php if($config['updates']=="combination") echo " SELECTED"; ?>>Combination</option>
- </select>
- <textarea cols="60" rows="2" id="info" name="info"style="border:1px dashed #000066; background-color: #ffffff; color: #000000; font-size: 8pt;">
- </textarea>
- <script language="javascript">
- update_description(branchinfo, document.forms[0].optimization.selectedIndex);
- </script>
- <br><span class="vexpl"><b>Select the update branch you would like this system to track</b></td>
- </tr>
--->
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
OpenPOWER on IntegriCloud