mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Three new validate.php checks
* Check that $config['install_dir'] is set correctly by checking that config.php exists there. * Check if the local branch is not master, warn that it will prevent updates * Check for modified files and list them (this will not include staged files)
This commit is contained in:
@@ -1041,7 +1041,13 @@ function version_info($remote=true) {
|
||||
curl_setopt($api, CURLOPT_RETURNTRANSFER, 1);
|
||||
$output['github'] = json_decode(curl_exec($api),true);
|
||||
}
|
||||
$output['local_sha'] = chop(`git rev-parse HEAD`);
|
||||
$output['local_sha'] = rtrim(`git rev-parse HEAD`);
|
||||
$output['local_branch'] = rtrim(`git rev-parse --abbrev-ref HEAD`);
|
||||
|
||||
exec('git diff --name-only --exit-code', $cmdoutput, $code);
|
||||
$output['git_modified'] = ($code !== 0);
|
||||
$output['git_modified_files'] = $cmdoutput;
|
||||
|
||||
$output['db_schema'] = dbFetchCell('SELECT version FROM dbSchema');
|
||||
$output['php_ver'] = phpversion();
|
||||
$output['mysql_ver'] = dbFetchCell('SELECT version()');
|
||||
|
16
validate.php
16
validate.php
@@ -59,6 +59,14 @@ if ($username !== 'root') {
|
||||
// load config.php now
|
||||
require_once 'includes/defaults.inc.php';
|
||||
require_once 'config.php';
|
||||
|
||||
// make sure install_dir is set correctly, or the next includes will fail
|
||||
if(!file_exists($config['install_dir'].'/config.php')) {
|
||||
print_fail('$config[\'install_dir\'] is not set correctly. It should probably be set to: ' . getcwd());
|
||||
exit;
|
||||
}
|
||||
|
||||
// continue loading includes
|
||||
require_once 'includes/definitions.inc.php';
|
||||
require_once 'includes/functions.php';
|
||||
require_once 'includes/common.php';
|
||||
@@ -73,6 +81,14 @@ if ($config['update_channel'] == 'master' && $cur_sha != $versions['github']['sh
|
||||
else {
|
||||
echo "Commit SHA: $cur_sha\n";
|
||||
}
|
||||
if($versions['local_branch'] != 'master') {
|
||||
print_warn("Your local git branch is not master, this will prevent automatic updates.");
|
||||
}
|
||||
if($versions['git_modified'] === true) {
|
||||
print_warn("Your local git contains modified files, this could prevent automatic updates.\nModified files:");
|
||||
echo(implode("\n", $versions['git_modified_files']) . "\n");
|
||||
}
|
||||
|
||||
echo "DB Schema: ".$versions['db_schema']."\n";
|
||||
echo "PHP: ".$versions['php_ver']."\n";
|
||||
echo "MySQL: ".$versions['mysql_ver']."\n";
|
||||
|
Reference in New Issue
Block a user