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

@@ -75,6 +75,11 @@ if (!file_exists($config['install_dir'].'/config.php')) {
exit;
}
$git_found = check_git_exists();
if ($git_found !== true) {
print_warn('Unable to locate git. This should probably be installed.');
}
$versions = version_info();
$cur_sha = $versions['local_sha'];
@@ -103,9 +108,11 @@ if (!($username === 'root' || (isset($config['user']) && $username === $config['
print_fail('You need to run this script as root' . (isset($config['user']) ? ' or '.$config['user'] : ''));
}
if ($config['update_channel'] == 'master' && $cur_sha != $versions['github']['sha']) {
$commit_date = new DateTime('@'.$versions['local_date'], new DateTimeZone(date_default_timezone_get()));
print_warn("Your install is out of date, last update: " . $commit_date->format('r'));
if ($git_found === true) {
if ($config['update_channel'] == 'master' && $cur_sha != $versions['github']['sha']) {
$commit_date = new DateTime('@'.$versions['local_date'], new DateTimeZone(date_default_timezone_get()));
print_warn("Your install is out of date, last update: " . $commit_date->format('r'));
}
}
// Check php modules we use to make sure they are loaded
@@ -252,21 +259,22 @@ if (count($devices = dbFetchColumn('SELECT `hostname` FROM `devices` WHERE last_
print_list($devices, "\t %s\n");
}
if ($versions['local_branch'] != 'master') {
print_warn("Your local git branch is not master, this will prevent automatic updates.");
}
if ($git_found === true) {
if ($versions['local_branch'] != 'master') {
print_warn("Your local git branch is not master, this will prevent automatic updates.");
}
// check for modified files
$modifiedcmd = 'git diff --name-only --exit-code';
if ($username === 'root') {
$modifiedcmd = 'su '.$config['user'].' -c "'.$modifiedcmd.'"';
// check for modified files
$modifiedcmd = 'git diff --name-only --exit-code';
if ($username === 'root') {
$modifiedcmd = 'su '.$config['user'].' -c "'.$modifiedcmd.'"';
}
exec($modifiedcmd, $cmdoutput, $code);
if ($code !== 0 && !empty($cmdoutput)) {
print_warn("Your local git contains modified files, this could prevent automatic updates.\nModified files:");
print_list($cmdoutput, "\t %s\n");
}
}
exec($modifiedcmd, $cmdoutput, $code);
if ($code !== 0 && !empty($cmdoutput)) {
print_warn("Your local git contains modified files, this could prevent automatic updates.\nModified files:");
print_list($cmdoutput, "\t %s\n");
}
// Modules test
$modules = explode(',', $options['m']);
foreach ($modules as $module) {