summaryrefslogtreecommitdiffstats
path: root/admin/WebConsole/rest/common.php
diff options
context:
space:
mode:
authorRamón M. Gómez <ramongomez@us.es>2018-06-12 12:33:14 +0200
committerRamón M. Gómez <ramongomez@us.es>2018-06-12 12:33:14 +0200
commitc00832504a4a2d0c569850525ed95214a1cffbaa (patch)
tree375d418a299b72134927696e2dc810e3177ef01a /admin/WebConsole/rest/common.php
parent3bbaf79bf5961f05f2a6f278f6f222b8e3ba49f7 (diff)
#843: API REST uses new version file.
Diffstat (limited to 'admin/WebConsole/rest/common.php')
-rw-r--r--admin/WebConsole/rest/common.php22
1 files changed, 13 insertions, 9 deletions
diff --git a/admin/WebConsole/rest/common.php b/admin/WebConsole/rest/common.php
index 8d192035..bc39ced9 100644
--- a/admin/WebConsole/rest/common.php
+++ b/admin/WebConsole/rest/common.php
@@ -13,6 +13,7 @@
// Common constants.
define('REST_LOGFILE', '/opt/opengnsys/log/rest.log');
+define('VERSION_FILE', '/opt/opengnsys/doc/VERSION.json');
// Set time zone.
if (function_exists("date_default_timezone_set")) {
@@ -247,25 +248,28 @@ $app->hook('slim.after', function() use ($app) {
* @return JSON object with basic server information (version, services, etc.)
*/
$app->get('/info', function() {
+ $response = new \stdClass;
// Reading version file.
- @list($project, $version, $release) = explode(' ', file_get_contents('/opt/opengnsys/doc/VERSION.txt'));
- $response['project'] = trim($project);
- $response['version'] = trim($version);
- $response['release'] = trim($release);
+ $data = json_decode(@file_get_contents(VERSION_FILE));
+ if (isset($data->project)) {
+ $response = $data;
+ } else {
+ $response->project = 'OpenGnsys';
+ }
// Getting actived services.
@$services = parse_ini_file('/etc/default/opengnsys');
- $response['services'] = Array();
+ $response->services = Array();
if (@$services["RUN_OGADMSERVER"] === "yes") {
- array_push($response['services'], "server");
+ array_push($response->services, "server");
$hasOglive = true;
}
- if (@$services["RUN_OGADMREPO"] === "yes") array_push($response['services'], "repository");
- if (@$services["RUN_BTTRACKER"] === "yes") array_push($response['services'], "tracker");
+ if (@$services["RUN_OGADMREPO"] === "yes") array_push($response->services, "repository");
+ if (@$services["RUN_BTTRACKER"] === "yes") array_push($response->services, "tracker");
// Reading installed ogLive information file.
if ($hasOglive === true) {
$data = json_decode(@file_get_contents('/opt/opengnsys/etc/ogliveinfo.json'));
if (isset($data->oglive)) {
- $response['oglive'] = $data->oglive;
+ $response->oglive = $data->oglive;
}
}
jsonResponse(200, $response);