Difference between revisions of "Documentation/sysconfig"

From The Kinguard Project Wiki
Jump to: navigation, search
m (Python)
Line 1: Line 1:
 
=System configuration file=
 
=System configuration file=
  
Runtime parameters should be saved in the file "/etc/kinguard/sysconfig.json".
+
The kinguard system components store all generic none security sensitive configuration in a central configuration file "/etc/kinguard/sysconfig.json".
  
Access to the file should be done using [https://github.com/Kinguard/libkgp libkgp (former libopi)], either directly using the shared lib, or by the wrappers for different programming languages.
+
This file should however never be manually edited it should always be accessed programatically using either [https://github.com/Kinguard/libkgp libkgp] or any wrapper to this library described further down.
  
 
=== File Syntax ===
 
=== File Syntax ===
The configuration file is a json object (note that javascript object syntax is not permitted).
+
For reference here is the layout of the sysconfig json file. Please read the file for reference but never ever edit it manually.
 +
 
 +
The complete configuration file is one json object (note that javascript object syntax is not permitted).
  
 
The file is set up using a "scope" and "key/value" pairs.
 
The file is set up using a "scope" and "key/value" pairs.
Line 26: Line 28:
 
  }
 
  }
  
 +
=== Native access via libkgp ===
 +
Libkgp is the main library to use when programming locally for the kinguard system it contains c++ objects for managing all kinguard functions. No official documentation exists for this yet but pointers on how it works can be found in the [https://github.com/Kinguard/libkgp/tree/master/test unit tests] and in the applications utilizing them for example [https://github.com/Kinguard/kgp-backend KGP backend] and [https://github.com/Kinguard/kgp-control KGP startup control]
 +
 +
To access the system configuration the [https://github.com/Kinguard/libkgp/blob/master/SysConfig.h SysConfig class]
  
 
=== Wrappers ===
 
=== Wrappers ===

Revision as of 10:08, 6 June 2018

System configuration file

The kinguard system components store all generic none security sensitive configuration in a central configuration file "/etc/kinguard/sysconfig.json".

This file should however never be manually edited it should always be accessed programatically using either libkgp or any wrapper to this library described further down.

File Syntax

For reference here is the layout of the sysconfig json file. Please read the file for reference but never ever edit it manually.

The complete configuration file is one json object (note that javascript object syntax is not permitted).

The file is set up using a "scope" and "key/value" pairs.

All scope and key identifiers shall be lowercase and written with letters and digits only, no "-" or "_".

Example:

{
  "webapps":
  {
    "theme":"kgp"
  },
  "hostinfo":
  {
    "unitid":"c79f425c-9af7-4f38-b1ba-d53277b14939",
    "hostname":"myhost",
    "domain":"example.org"
  }
}

Native access via libkgp

Libkgp is the main library to use when programming locally for the kinguard system it contains c++ objects for managing all kinguard functions. No official documentation exists for this yet but pointers on how it works can be found in the unit tests and in the applications utilizing them for example KGP backend and KGP startup control

To access the system configuration the SysConfig class

Wrappers

Most wrappers can also be used to access other information provided by libkgp, such as the current running system type, information about system storage etc.

Shell Scripts

For shell scripts, use "kgp-sysinfo". Run kgp-sysinfo --help for options.

Example:

# kgp-sysinfo -c hostinfo -k unitid -p
c79f425c-9af7-4f38-b1ba-d53277b14939

# kgp-sysinfo -c hostinfo -k unitid
{"unitid":"c79f425c-9af7-4f38-b1ba-d53277b14939"}
Python

For Python3, use the python library "pylibopi"

Example:

>>> import pylibopi
>>> pylibopi.StorageDevice()
'/dev/disk/by-path/platform-f10a8000.sata-ata-2'
C

For C programs, libkgp_wrapper can be used.

PHP

Currently no native PHP wrapper exists, but kgp-sysinfo defaults to output json (see above) that can easily be used in PHP.