diff options
author | Ramón M. Gómez <ramongomez@us.es> | 2018-06-12 12:33:14 +0200 |
---|---|---|
committer | Ramón M. Gómez <ramongomez@us.es> | 2018-06-12 12:33:14 +0200 |
commit | c00832504a4a2d0c569850525ed95214a1cffbaa (patch) | |
tree | 375d418a299b72134927696e2dc810e3177ef01a | |
parent | 3bbaf79bf5961f05f2a6f278f6f222b8e3ba49f7 (diff) |
#843: API REST uses new version file.
-rw-r--r-- | admin/WebConsole/rest/common.php | 22 | ||||
-rw-r--r-- | admin/WebConsole/rest/opengnsys-api.yml | 8 |
2 files changed, 20 insertions, 10 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); diff --git a/admin/WebConsole/rest/opengnsys-api.yml b/admin/WebConsole/rest/opengnsys-api.yml index fcd4961f..13ea37a1 100644 --- a/admin/WebConsole/rest/opengnsys-api.yml +++ b/admin/WebConsole/rest/opengnsys-api.yml @@ -87,6 +87,12 @@ paths: version: description: project version type: string + codename: + description: version codename + type: string + definition: + description: codename definition URL + type: string release: description: project release type: string @@ -122,7 +128,7 @@ paths: description: ISO file type: string required: [ distribution, kernel, architecture, revision, directory, iso ] - required: [ project, version, release, services ] + required: [ project, services ] tags: - server - repository |