Detect if LibreNMS is installed from the official Docker image (librenms/docker#46) (#10879)

This commit is contained in:
CrazyMax
2019-11-25 15:05:34 +01:00
committed by Tony Murray
parent 2de39f58b3
commit 58459ff0c5
4 changed files with 28 additions and 0 deletions

View File

@@ -45,4 +45,14 @@ class Env
return $value;
}
/**
* Detect if LibreNMS is installed from the official Docker image.
*
* @return bool
*/
public static function librenmsDocker()
{
return getenv('LIBRENMS_DOCKER') === '1';
}
}

View File

@@ -25,6 +25,7 @@
namespace LibreNMS\Validations;
use LibreNMS\Util\Env;
use LibreNMS\Util\Git;
use LibreNMS\ValidationResult;
use LibreNMS\Validator;
@@ -39,6 +40,11 @@ class Dependencies extends BaseValidation
*/
public function validate(Validator $validator)
{
if (Env::librenmsDocker()) {
$validator->ok("Installed from the official Docker image; no Composer required");
return;
}
# if git is not installed, do not assume composer is either
if (!Git::repoPresent()) {
$validator->ok("Installed from package; no Composer required");

View File

@@ -29,6 +29,7 @@ use DateTime;
use DateTimeZone;
use Exception;
use LibreNMS\Config;
use LibreNMS\Util\Env;
use LibreNMS\Util\Git;
use LibreNMS\ValidationResult;
use LibreNMS\Validator;
@@ -37,6 +38,11 @@ class Updates extends BaseValidation
{
public function validate(Validator $validator)
{
if (Env::librenmsDocker()) {
$validator->warn('Updates are managed through the official Docker image');
return;
}
if (!Git::repoPresent()) {
$validator->warn('Non-git install, updates are manual or from package');
return;

View File

@@ -26,6 +26,7 @@
namespace LibreNMS\Validations;
use LibreNMS\Config;
use LibreNMS\Util\Env;
use LibreNMS\Util\Git;
use LibreNMS\ValidationResult;
use LibreNMS\Validator;
@@ -60,6 +61,11 @@ class User extends BaseValidation
}
}
// skip if docker image
if (Env::librenmsDocker()) {
return;
}
# if no git, then we probably have different permissions by design
if (!Git::repoPresent()) {
return;