feature: Added check for if git executable (#5444)

This commit is contained in:
David Bell
2017-01-15 22:54:06 +00:00
committed by Neil Lathwood
parent bfe6ce610c
commit 44071e83b1
2 changed files with 46 additions and 28 deletions

View File

@@ -1086,19 +1086,20 @@ function version_info($remote = true)
{
global $config;
$output = array();
if ($remote === true && $config['update_channel'] == 'master') {
$api = curl_init();
set_curl_proxy($api);
curl_setopt($api, CURLOPT_USERAGENT, 'LibreNMS');
curl_setopt($api, CURLOPT_URL, $config['github_api'].'commits/master');
curl_setopt($api, CURLOPT_RETURNTRANSFER, 1);
$output['github'] = json_decode(curl_exec($api), true);
if (check_git_exists() === true) {
if ($remote === true && $config['update_channel'] == 'master') {
$api = curl_init();
set_curl_proxy($api);
curl_setopt($api, CURLOPT_USERAGENT, 'LibreNMS');
curl_setopt($api, CURLOPT_URL, $config['github_api'].'commits/master');
curl_setopt($api, CURLOPT_RETURNTRANSFER, 1);
$output['github'] = json_decode(curl_exec($api), true);
}
list($local_sha, $local_date) = explode('|', rtrim(`git show --pretty='%H|%ct' -s HEAD`));
$output['local_sha'] = $local_sha;
$output['local_date'] = $local_date;
$output['local_branch'] = rtrim(`git rev-parse --abbrev-ref HEAD`);
}
list($local_sha, $local_date) = explode('|', rtrim(`git show --pretty='%H|%ct' -s HEAD`));
$output['local_sha'] = $local_sha;
$output['local_date'] = $local_date;
$output['local_branch'] = rtrim(`git rev-parse --abbrev-ref HEAD`);
$output['db_schema'] = dbFetchCell('SELECT version FROM dbSchema');
$output['php_ver'] = phpversion();
$output['mysql_ver'] = dbFetchCell('SELECT version()');
@@ -1570,3 +1571,12 @@ function set_numeric($value, $default = 0)
}
return $value;
}
function check_git_exists()
{
if (`which git`) {
return true;
} else {
return false;
}
}