Private GIT

Skip to content
Snippets Groups Projects
Commit ee58839c authored by Maximilien Bersoult's avatar Maximilien Bersoult
Browse files

* Add get installed version on Centreon

parent f0510b54
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
namespace Centreon\Internal; namespace Centreon\Internal;
use Centreon\Internal\Di;
use Centreon\Internal\Utils\CommandLine\Colorize; use Centreon\Internal\Utils\CommandLine\Colorize;
use Centreon\Internal\Module\Informations; use Centreon\Internal\Module\Informations;
...@@ -105,6 +106,25 @@ class Command ...@@ -105,6 +106,25 @@ class Command
} }
} }
/**
* Display the current installed version
*/
public function getVersion()
{
$dbconn = Di::getDefault()->get('db_centreon');
try {
$stmt = $dbconn->query('SELECT value FROM cfg_informations where `key` = "version"');
} catch (\Exception $e) {
throw new \Exception("Version not present.");
}
if (0 === $stmt->rowCount()) {
throw new \Exception("Version not present.");
}
$row = $stmt->fetch();
$stmt->closeCursor();
echo $row['value'] . "\n";
}
/** /**
* *
* @param array $ListOfCommands * @param array $ListOfCommands
......
...@@ -9,10 +9,11 @@ ...@@ -9,10 +9,11 @@
$parametersLine = null; $parametersLine = null;
$helpMode = false; $helpMode = false;
$listMode = false; $listMode = false;
$getVersion = false;
$requireAuthentication = false; $requireAuthentication = false;
// Get Options // Get Options
$shortOpts = "hlu::p::"; $shortOpts = "hvlu::p::";
$options = getopt($shortOpts); $options = getopt($shortOpts);
// Remove options from the list of arguments // Remove options from the list of arguments
...@@ -49,12 +50,18 @@ ...@@ -49,12 +50,18 @@
$requireAuthentication = true; $requireAuthentication = true;
} }
if (isset($options['v'])) {
$getVersion = true;
}
try { try {
$commandeLineManager = new \Centreon\Internal\Command($requestLine, $parametersLine); $commandeLineManager = new \Centreon\Internal\Command($requestLine, $parametersLine);
if ($helpMode) { if ($helpMode) {
$commandeLineManager->getHelp(); $commandeLineManager->getHelp();
} elseif ($listMode) { } elseif ($listMode) {
$commandeLineManager->getCommandList(); $commandeLineManager->getCommandList();
} elseif ($getVersion) {
$commandeLineManager->getVersion();
} else { } else {
if ($requireAuthentication) { if ($requireAuthentication) {
$password = ''; $password = '';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment