summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/pkg-utils.inc
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2017-08-10 17:26:09 -0300
committerRenato Botelho <renato@netgate.com>2017-08-10 17:26:30 -0300
commite8f8aeb631079e15d434b7ad80e3a553210bc777 (patch)
tree80301bdd08c7992dcc17d6d1fa214bd2f28b1407 /src/etc/inc/pkg-utils.inc
parentca77322046df2206512a4095b5e07003972a900d (diff)
downloadpfsense-e8f8aeb631079e15d434b7ad80e3a553210bc777.zip
pfsense-e8f8aeb631079e15d434b7ad80e3a553210bc777.tar.gz
Use cache file to show pfSense version information
Diffstat (limited to 'src/etc/inc/pkg-utils.inc')
-rw-r--r--src/etc/inc/pkg-utils.inc22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/etc/inc/pkg-utils.inc b/src/etc/inc/pkg-utils.inc
index cb805eb..9130ed6 100644
--- a/src/etc/inc/pkg-utils.inc
+++ b/src/etc/inc/pkg-utils.inc
@@ -1170,14 +1170,28 @@ function get_base_pkg_name() {
}
/* Verify if system needs upgrade (meta package or base) */
-function get_system_pkg_version($baseonly = false) {
+function get_system_pkg_version($baseonly = false, $use_cache = true) {
global $g;
- $output = exec("/usr/local/sbin/{$g['product_name']}-upgrade -c", $_gc,
- $rc);
+ $cache_file = $g['version_cache_file'];
+ $rc_file = $cache_file . '.rc';
+
+ $rc = "";
+ if ($use_cache && file_exists($rc_file) &&
+ (time()-filemtime($rc_file) < $g['version_cache_refresh'])) {
+ $rc = chop(@file_get_contents($rc_file));
+ }
+
+ if ($rc == "2") {
+ $output = @file_get_contents($cache_file);
+ } else if ($rc != "0") {
+ $output = exec(
+ "/usr/local/sbin/{$g['product_name']}-upgrade -c", $_gc,
+ $rc);
+ }
/* pfSense-upgrade returns 2 when there is a new version */
- if ($rc == 2) {
+ if ($rc == "2") {
$new_version = explode(' ', $output)[0];
}
OpenPOWER on IntegriCloud