From 773c99bc37c742cc94a1894914c5ba4a7b5abdd7 Mon Sep 17 00:00:00 2001 From: Ermal Date: Fri, 19 Mar 2010 15:34:56 +0000 Subject: Fix auto update checking and showing always there is an update available. --- usr/local/www/system_firmware_auto.php | 49 ++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 17 deletions(-) (limited to 'usr/local/www/system_firmware_auto.php') 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"); $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 +?> -- cgit v1.1