summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2010-03-19 15:34:56 +0000
committerErmal <eri@pfsense.org>2010-03-19 15:34:56 +0000
commit773c99bc37c742cc94a1894914c5ba4a7b5abdd7 (patch)
tree162bb355b699de6caef49167c93eb26d6ae7bb80 /usr
parentf3b000b2d10cf2010563b28b8107706178e64081 (diff)
downloadpfsense-773c99bc37c742cc94a1894914c5ba4a7b5abdd7.zip
pfsense-773c99bc37c742cc94a1894914c5ba4a7b5abdd7.tar.gz
Fix auto update checking and showing always there is an update available.
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/system_firmware_auto.php49
-rwxr-xr-xusr/local/www/system_firmware_check.php84
-rw-r--r--usr/local/www/widgets/widgets/system_information.widget.php31
3 files changed, 84 insertions, 80 deletions
diff --git a/usr/local/www/system_firmware_auto.php b/usr/local/www/system_firmware_auto.php
index dca454b..a777d18 100755
--- a/usr/local/www/system_firmware_auto.php
+++ b/usr/local/www/system_firmware_auto.php
@@ -123,21 +123,36 @@ include("head.inc");
<?php
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 ...");
- conf_mount_rw();
- $status = download_file_with_progress_bar("{$updater_url}/latest.tgz", "{$g['upload_path']}/latest.tgz", "read_body_firmware");
- $status = download_file_with_progress_bar("{$updater_url}/latest.tgz.sha256", "{$g['upload_path']}/latest.tgz.sha256");
- conf_mount_ro();
- update_output_window("{$g['product_name']} download complete.");
+download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
+$latest_version = str_replace("\n", "", @file_get_contents("/tmp/{$g['product_name']}_version"));
+if(!$latest_version) {
+ update_output_window("Unable to check for updates.");
+ require("fend.inc");
+ exit;
+} else {
+ $current_installed_pfsense_version = str_replace("\n", "", @file_get_contents("/etc/version.buildtime"));
+ $current_installed_pfsense = strtotime($current_installed_pfsense_version);
+ $latest_version = str_replace("\n", "", @file_get_contents("/tmp/{$g['product_name']}_version"));
+ $latest_version_pfsense = strtotime($latest_version);
+ if(!$latest_version) {
+ update_output_window("Unable to check for updates.");
+ require("fend.inc");
+ exit;
+ } else {
+ $needs_system_upgrade = false;
+ if($current_installed_pfsense_version < $latest_version_pfsense) {
+ update_status("Downloading updates ...");
+ conf_mount_rw();
+ $status = download_file_with_progress_bar("{$updater_url}/latest.tgz", "{$g['upload_path']}/latest.tgz", "read_body_firmware");
+ $status = download_file_with_progress_bar("{$updater_url}/latest.tgz.sha256", "{$g['upload_path']}/latest.tgz.sha256");
+ conf_mount_ro();
+ update_output_window("{$g['product_name']} download complete.");
+ } else {
+ update_output_window("You are on the latest version.");
+ require("fend.inc");
+ exit;
+ }
+ }
}
/* launch external upgrade helper */
@@ -214,8 +229,8 @@ function read_body_firmware($ch, $string) {
$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 .= " Latest Version : {$latest_version}\\n";
$text .= " File size : {$a}\\n";
$text .= " Downloaded : {$b}\\n";
$text .= " Percent : {$c}%\\n";
@@ -230,4 +245,4 @@ function read_body_firmware($ch, $string) {
return $length;
}
-?> \ 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 45c07a2..4094376 100755
--- a/usr/local/www/system_firmware_check.php
+++ b/usr/local/www/system_firmware_check.php
@@ -43,6 +43,7 @@
$d_isfwfile = 1;
require("guiconfig.inc");
+require_once("pfsense-utils.inc");
$curcfg = $config['system']['firmware'];
$pgtitle=array("System", "Firmware", "Auto Update");
@@ -96,7 +97,7 @@ include("head.inc");
</table>
<br>
<!-- command output box -->
- <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols='90' rows='7' name='output' id='output' wrap='hard'>
+ <textarea border='1' bordercolordark='#000000' bordercolorlight='#000000' cols='90' rows='9' name='output' id='output' wrap='hard'>
</textarea>
</center>
<p>
@@ -113,59 +114,54 @@ include("head.inc");
<?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_output_window("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) {
+$static_text = "Downloading current version information... ";
+update_output_window($static_text);
+download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
+$latest_version = str_replace("\n", "", @file_get_contents("/tmp/{$g['product_name']}_version"));
+$static_text .= "done.\n";
+if(!$latest_version)
+ $static_text .= "Unable to check for updates.\n";
+else {
+ $static_text .= "Downloading current version information...";
+ update_output_window($static_text);
+ $current_installed_pfsense_version = str_replace("\n", "", file_get_contents("/etc/version.buildtime"));
+ $current_installed_pfsense = strtotime($current_installed_pfsense_version);
+ $latest_build_version = strtotime($latest_version);
+ $static_text .= "done\n";
+ update_output_window($static_text);
+ if(!$latest_build_version) {
+ $static_text .= "Unable to check for updates.\n";
if(isset($curcfg['alturl']['enable']))
- update_output_window("Could not contact custom update server.");
+ $static_text .= "Could not contact custom update server.\n";
else
- update_output_window("Could not contact {$g['product_name']} update server {$updater_url}.");
-} else {
- if($needs_system_upgrade) {
- echo "\n<script>$('invokeupgrade').style.visibility = 'visible';</script>";
- $txt = "A new version is now available \\n\\n";
- $txt .= "New version: {$latest_version}\\n";
- $txt .= "Current version: {$current_installed_pfsense_version}\\n";
- $txt .= "Update source: {$updater_url}\\n";
- update_output_window($txt);
- } else {
- update_output_window("You are on the latest version.");
- }
+ $static_text .= "Could not contact {$g['product_name']} update server {$updater_url}.\n";
+ } else {
+ if($current_installed_pfsense < $latest_build_version) {
+ $needs_system_upgrade = true;
+ } else {
+ $static_text .= "You are on the latest version.\n";
+ }
+ }
+}
+update_output_window($static_text);
+if ($needs_system_upgrade == false) {
+ require("fend.inc");
+ exit;
}
-?>
+echo "\n<script>$('invokeupgrade').style.visibility = 'visible';</script>";
+$txt = "A new version is now available \\n\\n";
+$txt .= "Current version: {$current_installed_pfsense_version}\\n";
+$txt .= "New version: {$latest_version}\\n\\n";
+$txt .= "Update source: {$updater_url}\\n";
+update_output_window($txt);
+?>
</form>
<?php include("fend.inc"); ?>
</body>
</html>
-
-
-</body>
-</html> \ No newline at end of file
diff --git a/usr/local/www/widgets/widgets/system_information.widget.php b/usr/local/www/widgets/widgets/system_information.widget.php
index d275010..294867d 100644
--- a/usr/local/www/widgets/widgets/system_information.widget.php
+++ b/usr/local/www/widgets/widgets/system_information.widget.php
@@ -40,35 +40,28 @@ if($_REQUEST['getupdatestatus']) {
$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
else
$updater_url = $g['update_url'];
- /* ensure we can obtain the DNS information quickly */
- $host = split("/", $updater_url);
- $test_dns = `/usr/bin/host -W1 {$host[2]} | grep "has address" | awk '{ print $4 }' | wc -l`;
- if($test_dns)
- $latest_version = download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
- else
- $latest_version ="404";
- if(strstr($latest_version,"404")) {
+ download_file_with_progress_bar("{$updater_url}/version", "/tmp/{$g['product_name']}_version");
+ $latest_version = file_get_contents("/tmp/{$g['product_name']}_version");
+ if(empty($latest_version))
echo "<br /><br />Unable to check for updates.";
- } else {
- $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;
+ else {
+ $current_installed_pfsense_version = strtotime(str_replace("\n", "", file_get_contents("/etc/version.buildtime")));
+
+ $latest_version = strtotime(str_replace("\n", "", file_get_contents("/tmp/{$g['product_name']}_version")));
if(!$latest_version) {
echo "<br /><br />Unable to check for updates.";
}
else {
- if($needs_system_upgrade) {
+ $needs_system_upgrade = false;
+ if($current_installed_pfsense_version < $latest_version) {
echo "<br/><span class=\"red\" id=\"updatealert\"><b>Update available. </b></span><a href=\"/system_firmware_check.php\">Click Here</a> to view update.";
echo "<script type=\"text/javascript\">";
echo "Effect.Pulsate('updatealert', { pulses: 30, duration: 10});";
echo "</script>";
- } else {
+ } else
echo "<br /><br />You are on the latest version.";
- }
- }
- }
+ }
+ }
exit;
}
OpenPOWER on IntegriCloud