Revision 7f211807
Added by Renato Botelho almost 8 years ago
src/etc/inc/globals.inc | ||
---|---|---|
217 | 217 |
/* Read all XML files in following dir and load menu entries */ |
218 | 218 |
$g["ext_menu_path"] = "/usr/local/share/{$g['product_name']}/menu"; |
219 | 219 |
|
220 |
/* Cache file used to store pfSense version */ |
|
221 |
$g["version_cache_file"] = "{$g['varrun_path']}/{$g['product_name']}_version"; |
|
222 |
$g['version_cache_refresh'] = 24 * 60 * 60; /* 24h */ |
|
223 |
|
|
220 | 224 |
function platform_booting($on_console = false) { |
221 | 225 |
global $g; |
222 | 226 |
|
src/etc/inc/pkg-utils.inc | ||
---|---|---|
1187 | 1187 |
} |
1188 | 1188 |
|
1189 | 1189 |
/* Verify if system needs upgrade (meta package or base) */ |
1190 |
function get_system_pkg_version($baseonly = false) { |
|
1190 |
function get_system_pkg_version($baseonly = false, $use_cache = true) {
|
|
1191 | 1191 |
global $g; |
1192 | 1192 |
|
1193 |
$output = exec("/usr/local/sbin/{$g['product_name']}-upgrade -c", $_gc, |
|
1194 |
$rc); |
|
1193 |
$cache_file = $g['version_cache_file']; |
|
1194 |
$rc_file = $cache_file . '.rc'; |
|
1195 |
|
|
1196 |
$rc = ""; |
|
1197 |
if ($use_cache && file_exists($rc_file) && |
|
1198 |
(time()-filemtime($rc_file) < $g['version_cache_refresh'])) { |
|
1199 |
$rc = chop(@file_get_contents($rc_file)); |
|
1200 |
} |
|
1201 |
|
|
1202 |
if ($rc == "2") { |
|
1203 |
$output = @file_get_contents($cache_file); |
|
1204 |
} else if ($rc != "0") { |
|
1205 |
$output = exec( |
|
1206 |
"/usr/local/sbin/{$g['product_name']}-upgrade -c", $_gc, |
|
1207 |
$rc); |
|
1208 |
} |
|
1195 | 1209 |
|
1196 | 1210 |
/* pfSense-upgrade returns 2 when there is a new version */ |
1197 |
if ($rc == 2) {
|
|
1211 |
if ($rc == "2") {
|
|
1198 | 1212 |
$new_version = explode(' ', $output)[0]; |
1199 | 1213 |
} |
1200 | 1214 |
|
Also available in: Unified diff
Use cache file to show pfSense version information