summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2008-05-24 06:38:59 +0000
committerScott Ullrich <sullrich@pfsense.org>2008-05-24 06:38:59 +0000
commit00b1a7ebc15f7ebd597cf6d6a2e6cbcfeccf6c28 (patch)
tree78fc827fd6343db65f877d59d406e440f2248db4
parentb23d010231875651fbfb6f85c936e96cd6230928 (diff)
downloadpfsense-00b1a7ebc15f7ebd597cf6d6a2e6cbcfeccf6c28.zip
pfsense-00b1a7ebc15f7ebd597cf6d6a2e6cbcfeccf6c28.tar.gz
Add back auto update support.
Discussed-with: cmb
-rwxr-xr-xusr/local/www/system_firmware.php34
-rwxr-xr-xusr/local/www/system_firmware_auto.php269
-rwxr-xr-xusr/local/www/system_firmware_check.php335
-rwxr-xr-xusr/local/www/system_firmware_settings.php99
4 files changed, 357 insertions, 380 deletions
diff --git a/usr/local/www/system_firmware.php b/usr/local/www/system_firmware.php
index 5a22cd7..ea25156 100755
--- a/usr/local/www/system_firmware.php
+++ b/usr/local/www/system_firmware.php
@@ -31,15 +31,22 @@
$d_isfwfile = 1;
require_once("guiconfig.inc");
+
+$curcfg = $config['system']['firmware'];
+
+
require_once("xmlrpc_client.inc");
+/* Allow additional execution time 0 = no limit. */
+ini_set('max_execution_time', '3600');
+ini_set('max_input_time', '3600');
+
/* if upgrade in progress, alert user */
if(file_exists($d_firmwarelock_path)) {
- $pgtitle = "System: Firmware: Manual Update";
+ $pgtitle = array("System","Firmware","Manual Update");
include("head.inc");
echo "<body link=\"#0000CC\" vlink=\"#0000CC\" alink=\"#0000CC\">\n";
include("fbegin.inc");
- echo "<p class=\"pgtitle\"><?=$pgtitle?></p>\n";
echo "<div>\n";
print_info_box("An upgrade is currently in progress.<p>The firewall will reboot when the operation is complete.<p><center><img src='/themes/{$g['theme']}/images/icons/icon_fw-update.gif'>");
echo "</div>\n";
@@ -61,7 +68,7 @@ if ($_POST && !file_exists($d_firmwarelock_path)) {
unset($input_errors);
unset($sig_warning);
-
+
if (stristr($_POST['Submit'], "Enable"))
$mode = "enable";
else if (stristr($_POST['Submit'], "Disable"))
@@ -120,7 +127,10 @@ if ($_POST && !file_exists($d_firmwarelock_path)) {
/* fire up the update script in the background */
touch($d_firmwarelock_path);
$savemsg = "The firmware is now being updated. The firewall will reboot automatically.";
- mwexec_bg("/etc/rc.firmware pfSenseupgrade {$g['upload_path']}/firmware.tgz");
+ if(stristr($_FILES['ulfile']['tmp_name'],"bdiff"))
+ mwexec_bg("/etc/rc.firmware delta_update {$g['upload_path']}/firmware.tgz");
+ else
+ mwexec_bg("/etc/rc.firmware pfSenseupgrade {$g['upload_path']}/firmware.tgz");
} else {
$savemsg = "Firmware image missing or other error, please try again.";
}
@@ -129,13 +139,12 @@ if ($_POST && !file_exists($d_firmwarelock_path)) {
}
}
-$pgtitle = "System: Firmware: Manual Update";
+$pgtitle = array("Diagnostics","Firmware");
include("head.inc");
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
<?php if ($fwinfo <> "") print_info_box($fwinfo); ?>
@@ -161,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>
@@ -172,7 +181,7 @@ print_info_box($sig_warning);
<div id="mainarea">
<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
- <td colspan="2" class="listtopic">Invoke pfSense Manual Upgrade</td>
+ <td colspan="2" class="listtopic">Invoke <?=$g['product_name']?> Manual Upgrade</td>
</tr>
<td width="22%" valign="baseline" class="vncell">&nbsp;</td>
<td width="78%" class="vtable">
@@ -180,11 +189,6 @@ print_info_box($sig_warning);
upload&quot; below, then choose the image file (<?=$g['platform'];?>-*.tgz)
to be uploaded.<br>Click &quot;Upgrade firmware&quot;
to start the upgrade process.</p>
- <?php if ($g['platform'] == "embedded" or $g['platform'] == "cdrom"): ?>
- This platform cannot be upgraded. Consider using option 13 from the console.
- <?php include("fend.inc"); ?>
- <?php exit; ?>
- <?php endif; ?>
<?php if (!file_exists($d_sysrebootreqd_path)): ?>
<?php if (!file_exists($d_fwupenabled_path)): ?>
<input name="Submit" type="submit" class="formbtn" value="Enable firmware upload">
@@ -204,7 +208,7 @@ print_info_box($sig_warning);
echo "<option value='wrap'>Embedded kernel</option>";
echo "<option value='Developers'>Developers kernel</option>";
echo "</select>";
- echo "<br><br>";
+ echo "<br><br>";
}
}
?>
diff --git a/usr/local/www/system_firmware_auto.php b/usr/local/www/system_firmware_auto.php
index 98e46fb..aef4a71 100755
--- a/usr/local/www/system_firmware_auto.php
+++ b/usr/local/www/system_firmware_auto.php
@@ -2,10 +2,10 @@
/* $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,61 +28,78 @@
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");
-require_once("guiconfig.inc");
-require_once("xmlrpc.inc");
+$curcfg = $config['system']['firmware'];
-$pgtitle = "System: Firmware: Auto Update";
+if(isset($curcfg['alturl']['enable']))
+ $updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
+else
+ $updater_url = $g['update_url'];
+
+$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"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
<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>
@@ -93,72 +110,134 @@ 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($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($_GET['category'] == 'full') {
- $tocheck = 'all';
- $categories = array('firmware', 'kernel', 'base');
+$sigchk = 0;
+
+if(!isset($curcfg['alturl']['enable']))
+ $sigchk = verify_digital_signature("/tmp/latest.tgz");
+
+if ($sigchk == 1)
+ $sig_warning = "The digital signature on this image is invalid.";
+else if ($sigchk == 2)
+ $sig_warning = "This image is not digitally signed.";
+else if (($sigchk == 3) || ($sigchk == 4))
+ $sig_warning = "There has been an error verifying the signature on this image.";
+
+if (!verify_gzip_file("/tmp/latest.tgz")) {
+ update_status("The image file is corrupt.");
+ update_output_window("Update cannot continue");
+ unlink("{$g['upload_path']}/latest.tgz");
+ require("fend.inc");
+ exit;
+}
+
+if ($sigchk) {
+ update_status($sig_warning);
+ update_output_window("Update cannot continue");
+ unlink("{$g['upload_path']}/latest.tgz");
+ require("fend.inc");
+ exit;
+}
+
+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_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 3563e07..903cd79 100755
--- a/usr/local/www/system_firmware_check.php
+++ b/usr/local/www/system_firmware_check.php
@@ -1,233 +1,158 @@
<?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 = "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"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
- <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']}";
+else
+ $updater_url = $g['update_url'];
+
+update_status("Downloading current version information...");
+$latest_version = download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
+
+if(strstr($latest_version,"404")) {
+ update_output_window("Could not download version information file {$updater_url}/version");
+ include("fend.inc");
+ exit;
+}
+
+$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 {$updater_url}.");
} 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 1373b8f..4dc457c 100755
--- a/usr/local/www/system_firmware_settings.php
+++ b/usr/local/www/system_firmware_settings.php
@@ -27,27 +27,18 @@
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']);
+ unset($config['system']['firmware']['alturl']);
+ unset($config['system']['firmware']);
}
write_config();
}
@@ -55,34 +46,25 @@ if ($_POST) {
$curcfg = $config['system']['firmware'];
-$pgtitle = "System: Firmware: Settings";
+$pgtitle = array("System","Firmware","Settings");
include("head.inc");
-?>
+exec("fetch -q -o /tmp/manifest \"{$g['update_manifest']}\"");
+if(file_exists("/tmp/manifest")) {
+ $preset_urls_split = split("\n", file_get_contents("/tmp/manifest"));
+}
+?>
+<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
<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;
}
}
@@ -91,7 +73,6 @@ function enable_altfirmwareurl(enable_over) {
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc");?>
-<p class="pgtitle"><?=$pgtitle?></p>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<form action="system_firmware_settings.php" method="post" name="iform" id="iform">
<?php if ($savemsg) print_info_box($savemsg); ?>
@@ -112,50 +93,38 @@ function enable_altfirmwareurl(enable_over) {
<tr>
<td colspan="2" valign="top" class="listtopic">Firmware Branch</td>
</tr>
+<?php if(is_array($preset_urls_split)): ?>
<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>
+ <td valign="top" class="vncell">Default Auto Update URLs</td>
+ <td class="vtable">
+ <select name='preseturls' id='preseturls' onChange="firmwareurl.value = preseturls.value; document.iform.firmwareurl.disabled = 0; alturlenable.checked=true;">
+ <option></option>
+ <?php
+ foreach($preset_urls_split as $pus) {
+ $pus_text = split("\t", $pus);
+ if($pus_text[0])
+ echo "<option value='{$pus_text[1]}'>{$pus_text[0]}</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>
+ </td>
</tr>
+<?php endif; ?>
<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" 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" 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 pfSense 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.
+ <p/>
+ <b>NOTE:</b> When a custom URL is enabled the system will not verify the digital signature from <?php echo $g['product_website'] ?>.
+ </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