mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add librenms command (#9619)
* Add librenms command Hook up to artisan. Hide dev commands and most other commands if app environment is production. Register all commands for php artisan or when not in production. * remove dead end line * Console application name and version. Had to shift some stuff from legacy code, but deferred others as it was too extensive of a change. * switch check order * always get local version now * update array format * whitepace * fix style
This commit is contained in:
43
LibreNMS/Util/Git.php
Normal file
43
LibreNMS/Util/Git.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Git.php
|
||||
*
|
||||
* -Description-
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 Tony Murray
|
||||
* @author Tony Murray <murraytony@gmail.com>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Util;
|
||||
|
||||
use LibreNMS\Config;
|
||||
|
||||
class Git
|
||||
{
|
||||
public static function repoPresent()
|
||||
{
|
||||
$install_dir = Config::get('install_dir', realpath(__DIR__ . '/../..'));
|
||||
return file_exists("$install_dir/.git");
|
||||
}
|
||||
|
||||
public static function binaryExists()
|
||||
{
|
||||
exec('git > /dev/null 2>&1', $response, $exit_code);
|
||||
return $exit_code === 1;
|
||||
}
|
||||
}
|
53
LibreNMS/Util/Version.php
Normal file
53
LibreNMS/Util/Version.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Version.php
|
||||
*
|
||||
* Get version info about LibreNMS and various components/dependencies
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @package LibreNMS
|
||||
* @link http://librenms.org
|
||||
* @copyright 2019 Tony Murray
|
||||
* @author Tony Murray <murraytony@gmail.com>
|
||||
*/
|
||||
|
||||
namespace LibreNMS\Util;
|
||||
|
||||
class Version
|
||||
{
|
||||
// Update this on release
|
||||
const VERSION = '1.47';
|
||||
|
||||
protected $is_git_install = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->is_git_install = Git::repoPresent() && Git::binaryExists();
|
||||
}
|
||||
|
||||
public static function get()
|
||||
{
|
||||
return new static;
|
||||
}
|
||||
|
||||
public function local()
|
||||
{
|
||||
if ($this->is_git_install) {
|
||||
return rtrim(shell_exec('git describe --tags'));
|
||||
}
|
||||
|
||||
return self::VERSION;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user