diff --git a/CCEngineServer/SystemParamsProvider_linux.cpp b/CCEngineServer/SystemParamsProvider_linux.cpp index 9e23203..80861c7 100644 --- a/CCEngineServer/SystemParamsProvider_linux.cpp +++ b/CCEngineServer/SystemParamsProvider_linux.cpp @@ -109,12 +109,12 @@ namespace BOOST_LOG_TRIVIAL(debug) << "Trying to find processor idenfication..."; uint32_t a, b, c, d; __cpuid (0 /* vendor string */, a, b, c, d); - std::cout << "EAX: " << std::hex << std::setw(8) << std::setfill('0') << a << "\nEBX: " << b << "\nECX: " << c << "\nEDX: " << d << "\n"; + BOOST_LOG_TRIVIAL(debug) << "EAX: " << std::hex << std::setw(8) << std::setfill('0') << a << "\nEBX: " << b << "\nECX: " << c << "\nEDX: " << d; uint32_t vendorId = a; uint32_t vendorString[] = {b, d, c, 0}; __cpuid (1 /* Processor Info and Feature Bits */, a, b, c, d); - std::cout << "EAX: " << std::hex << std::setw(8) << std::setfill('0') << a << "\nEBX: " << b << "\nECX: " << c << "\nEDX: " << d << "\n"; + BOOST_LOG_TRIVIAL(debug) << "EAX: " << std::hex << std::setw(8) << std::setfill('0') << a << "\nEBX: " << b << "\nECX: " << c << "\nEDX: " << d; bool isHypervisor = c & 0x80000000; uint32_t modelId = a & 0b00001111111111110011111111111111; @@ -421,7 +421,7 @@ namespace detail auto result2 = read_dmidecode(); for (auto it = result2.cbegin(); it != result2.cend(); ++it) { - std::cout << it->first << ": " << it->second << std::endl; + BOOST_LOG_TRIVIAL(debug) << it->first << ": " << it->second; } if (result.find(SystemParamTypes::mainboardSerialNum) == result.end() && diff --git a/CCEngineServer/main.cpp b/CCEngineServer/main.cpp index 0694f60..f343e9b 100644 --- a/CCEngineServer/main.cpp +++ b/CCEngineServer/main.cpp @@ -40,6 +40,7 @@ void initLogging(std::optional logFolder, bool debug = false) keywords::open_mode = std::ios_base::app, keywords::rotation_size = 10 * 1024 * 1024, keywords::max_files = 10, + keywords::auto_flush = true, keywords::format = ( expr::stream << expr::format_date_time("TimeStamp", "%Y-%m-%d %H:%M:%S") diff --git a/docs/CCEngineServer/CREATING_LICENSE.html b/docs/CCEngineServer/CREATING_LICENSE.html new file mode 100644 index 0000000..ca2f84e --- /dev/null +++ b/docs/CCEngineServer/CREATING_LICENSE.html @@ -0,0 +1,67 @@ + + + + + CCEngineServer service guide: Creating a new license + + + + + + + + + + + +
+

Important: This file is confidential for APIS internal use

+
+ +

CCEngineServer service guide: Creating a new license

+

1. Pripojenie na databazu licencii cez Adminer

+

https://license-admin.apis.sk/

+

license-admin connection

+

2. (optional) Zoznam este neaktivovanych licencii si viem pozriet nasledovnym query:

+
Select * From License Where productId='cocserver' and licenseNum Not In (select licenseNum FROM ActiveActivationView) +
+

license-admin query

+

3. Vygenerovanie novej licencie

+

Pre vygenerovanie novej licencie nabrowsujem na +(https://license.apis.sk/temp/generate-new-license)

+

kde najdem dve hlavne casti:

+
    +
  1. Prva cast kde je licencia oddelena pomlckami pre jednoduchsi prepis (treba si niekde odlozit)
  2. +
  3. Druha cast kde je query aby sa ulozila nova licencia do databazy +
    +

    Nepouzi vygenerovane SQL prikazy. Musis ich najprv upravit na taketo:

    +
    coc -> cocserver +ccengine -> ccengineserver +posledny riadok vymaz +
    +
    +
  4. +
+

Pre pridanie licencie do databazy treba cez obrazovku "SQL Command" ako v kroku 2 skopirovat query (3 prikazy = samotna +licencia + pridelenie modulov ccengine a cndata) z druhej casti a spustit. +Ci bola licencia uspesne pridana sa da pozriet podla navodu v kroku 2.

+ + + \ No newline at end of file diff --git a/docs/CCEngineServer/CREATING_LICENSE.md b/docs/CCEngineServer/CREATING_LICENSE.md new file mode 100644 index 0000000..94059a5 --- /dev/null +++ b/docs/CCEngineServer/CREATING_LICENSE.md @@ -0,0 +1,43 @@ +> Important: This file is confidential for APIS internal use + +- [CCEngineServer service guide: Creating a new license](#ccengineserver-service-guide-creating-a-new-license) + - [1. Pripojenie na databazu licencii cez Adminer](#1-pripojenie-na-databazu-licencii-cez-adminer) + - [2. (optional) Zoznam este neaktivovanych licencii si viem pozriet nasledovnym query:](#2-optional-zoznam-este-neaktivovanych-licencii-si-viem-pozriet-nasledovnym-query) + - [3. Vygenerovanie novej licencie](#3-vygenerovanie-novej-licencie) + +# CCEngineServer service guide: Creating a new license + +### 1. Pripojenie na databazu licencii cez Adminer + +[https://license-admin.apis.sk/](https://license-admin.apis.sk/) + +![license-admin connection](license_admin_connection.png) + +### 2. (optional) Zoznam este neaktivovanych licencii si viem pozriet nasledovnym query: + +```sql +Select * From License Where productId='cocserver' and licenseNum Not In (select licenseNum FROM ActiveActivationView) +``` + +![license-admin query](license_admin_query.png) + + +### 3. Vygenerovanie novej licencie + +Pre vygenerovanie novej licencie nabrowsujem na +(https://license.apis.sk/temp/generate-new-license) + +kde najdem dve hlavne casti: + 1. Prva cast kde je licencia oddelena pomlckami pre jednoduchsi prepis (treba si niekde odlozit) + 2. Druha cast kde je query aby sa ulozila nova licencia do databazy + > Nepouzi vygenerovane SQL prikazy. Musis ich najprv upravit na taketo: + > + > ``` + > coc -> cocserver + > ccengine -> ccengineserver + > posledny riadok vymaz + > ``` + +Pre pridanie licencie do databazy treba cez obrazovku "SQL Command" ako v kroku 2 skopirovat query (3 prikazy = samotna +licencia + pridelenie modulov ccengine a cndata) z druhej casti a spustit. +Ci bola licencia uspesne pridana sa da pozriet podla navodu v kroku 2. diff --git a/docs/CCEngineServer/PROCESSING_ACTIVATION_REQUEST.html b/docs/CCEngineServer/PROCESSING_ACTIVATION_REQUEST.html new file mode 100644 index 0000000..5d149e5 --- /dev/null +++ b/docs/CCEngineServer/PROCESSING_ACTIVATION_REQUEST.html @@ -0,0 +1,54 @@ + + + + + CCEngineServer service guide: Processing activation request + + + + + + + + + + + +
+

Important: This file is confidential for APIS internal use

+
+

CCEngineServer service guide: Processing activation request

+

1. Prijatie poziadavky o aktivaciu od zakaznika

+

Tento process zacne prijatim poziadavky od zakaznika na offline aktivaciu (vid User guide). +Aktivacny request ma nasledovny format:

+
-----BEGIN ACTIVATION REQUEST----- +ABCabc.... +... +xyzXYZ== +-----END ACTIVATION REQUEST----- +
+

2. Aktivacia

+

https://license.apis.sk/temp/license-activator-tool/

+
    +
  1. Aktivacny request treba nakopirovat do prveho okienka (Activation request):
  2. +
  3. Kliknes Parse activation request
  4. +
  5. Ak bol spravny mal by si v dalsom okienku vidiet zahashovane identifikatory
  6. +
  7. Vyplnis licencne cislo ktore bolo vygenerovanie podla Creating license
  8. +
  9. Kliknes Activate
  10. +
  11. Po uspesnej aktivacii mozes stiahnut "license.dat"
  12. +
+

License activator tool

+

3. Poslanie vygenerovaneho license.dat naspat zakaznikovi

+

Vygenerovany license.dat treba dorucit zakaznikovi s instrukciou aby ho nakopiroval do hlavneho foldra kde ma applikaciu

+ + + \ No newline at end of file diff --git a/docs/CCEngineServer/PROCESSING_ACTIVATION_REQUEST.md b/docs/CCEngineServer/PROCESSING_ACTIVATION_REQUEST.md new file mode 100644 index 0000000..8d75a59 --- /dev/null +++ b/docs/CCEngineServer/PROCESSING_ACTIVATION_REQUEST.md @@ -0,0 +1,32 @@ +> Important: This file is confidential for APIS internal use + +# CCEngineServer service guide: Processing activation request + +## 1. Prijatie poziadavky o aktivaciu od zakaznika + +Tento process zacne prijatim poziadavky od zakaznika na offline aktivaciu (vid [User guide](USER_GUIDE.md)). +Aktivacny request ma nasledovny format: + +``` +-----BEGIN ACTIVATION REQUEST----- +ABCabc.... +... +xyzXYZ== +-----END ACTIVATION REQUEST----- +``` + +## 2. Aktivacia + +[https://license.apis.sk/temp/license-activator-tool/](https://license.apis.sk/temp/license-activator-tool/) +1. Aktivacny request treba nakopirovat do prveho okienka (Activation request): +1. Kliknes Parse activation request +1. Ak bol spravny mal by si v dalsom okienku vidiet zahashovane identifikatory +1. Vyplnis licencne cislo ktore bolo vygenerovanie podla [Creating license](CREATING_LICENSE.md) +1. Kliknes Activate +1. Po uspesnej aktivacii mozes stiahnut "license.dat" + +![License activator tool](license_activator_tool.png) + +## 3. Poslanie vygenerovaneho license.dat naspat zakaznikovi + +Vygenerovany `license.dat` treba dorucit zakaznikovi s instrukciou aby ho nakopiroval do hlavneho foldra kde ma applikaciu diff --git a/docs/CCEngineServer/USER_GUIDE.html b/docs/CCEngineServer/USER_GUIDE.html new file mode 100644 index 0000000..fd48924 --- /dev/null +++ b/docs/CCEngineServer/USER_GUIDE.html @@ -0,0 +1,159 @@ + + + + + CCEngineServer User guide + + + + + + + + + + + + +

CCEngineServer User guide

+

Installation

+

Extract the application

+

Extract the application into /opt folder

+
mkdir /opt/CCEngineServer +tar -xvzf CCEngineServer-<VER>.tar.gz --directory /opt/CCEngineServer/ +
+

Extract application data into data folder

+
unzip data-<VER>.zip -d /opt/CCEngineServer/data +
+

Activation

+

There are two ways to activate the application. One is online activation if you have a license key and your target system +can access internet. The second options is for closed environments where internet access is not possible.

+

Option A: Online activation

+
cd /opt/CCEngineServer +sudo ./bin/CCEngineServer --activate_online +
+

When prompted, please enter provided license key and press enter.

+
+

Note: In case of connection problems please check if your /etc/ssl/certs/ca-certificates.crt exists. +On some systems the ca-certificates bundle is not in the expected location. You can fix that by creating symbolic link +to the right location. +Example on fedora:

+
sudo ln -s /etc/ssl/certs/ca-bundle.crt /etc/ssl/certs/ca-certificates.crt +
+
+

Option B: Offline activation

+
cd /opt/CCEngineServer +sudo ./bin/CCEngineServer --activate_offline +
+

Copy the generated request as in below example and send by email to customer support of Catalogue of Currencies

+
Subject: CCEngineServer activation request + +-----BEGIN ACTIVATION REQUEST----- +ABCabc.... +... +xyzXYZ== +-----END ACTIVATION REQUEST----- +
+
+

Note: Please note that the activation request contains hardware fingerprints from the target device

+
+

The support will email you back license.dat file which should be copied to application installation directory +(i.e. its location should be /opt/CCEngineServer/license.dat).

+

Running

+

Optional: Create a non-root user

+

Although the application needs to be started as root, it can swith to non-root user just after successfull startup. +You can use the commands below to create a new user.

+
sudo useradd -M ccengine +sudo usermod -L ccengine +
+

Find the assigned uid and gid to the created user:

+
id ccengine +> uid=1001(ccengine) gid=1001(ccengine) groups=1001(ccengine) +
+

Run

+

If the application is successfully activate it can be started by following commands. Please note that --set_uid 1001 +and --set_gid 1001 are optional so these parameters can be either removed and in such case the application will be +running as root, or the numbers should be replaced by the uid and gid of the non-root user created in previous steps.

+
cd /opt/CCEngineServer +sudo /opt/CCEngineServer/bin/CCEngineServer --data_root ./data --set_uid 1001 --set_gid 1001 +
+
+

Note: The application by default bind all network interfaces and listens on port 8080. If a different port is needed +please refer to CCEngineServer --help to see how defaults can be changed.

+
+

Test connection with browser

+

Open web browser and enter following into the addres bar http://<server_address>:8080/.

+

Starting the application as systemd service

+

Create new service unit

+

Example service unit file can look like this. Please note that uid 1001 and gid 1001 should be changed to your own prefered +user

+
# /etc/systemd/system/ccengineserver.service +[Unit] +Description=CCEngineServer data server for Catalogue of Currencies + +[Service] +WorkingDirectory=/opt/CCEngineServer +User=root +ExecStart=/opt/CCEngineServer/bin/CCEngineServer --data_root ./data --log_folder ./log --set_uid 1001 --set_gid 1001 + +[Install] +WantedBy=multi-user.target +
+
+

Note: Please note that in case of using SELinux, the following security context need to be set to the binary executable: +sudo chcon -R -t bin_t /opt/CCEngineServer/bin/. +The selinux status can be checked by getenforce, sestatus commands

+
+

Start the CCEngineServer service

+
sudo systemctl start ccengineserver +
+

Enable automatic startup

+
sudo systemctl enable ccengineserver +
+

Optional: Stopping application

+
sudo systemctl stop ccengineserver +
+ + + \ No newline at end of file diff --git a/docs/CCEngineServer/USER_GUIDE.md b/docs/CCEngineServer/USER_GUIDE.md new file mode 100644 index 0000000..28db912 --- /dev/null +++ b/docs/CCEngineServer/USER_GUIDE.md @@ -0,0 +1,150 @@ + +- [CCEngineServer User guide](#ccengineserver-user-guide) + - [Installation](#installation) + - [Extract the application](#extract-the-application) + - [Extract application data into data folder](#extract-application-data-into-data-folder) + - [Activation](#activation) + - [Option A: Online activation](#option-a-online-activation) + - [Option B: Offline activation](#option-b-offline-activation) + - [Running](#running) + - [Optional: Create a non-root user](#optional-create-a-non-root-user) + - [Run](#run) + - [Test connection with browser](#test-connection-with-browser) + - [Starting the application as systemd service](#starting-the-application-as-systemd-service) + - [Create new service unit](#create-new-service-unit) + - [Start the CCEngineServer service](#start-the-ccengineserver-service) + - [Enable automatic startup](#enable-automatic-startup) + - [Optional: Stopping application](#optional-stopping-application) + +# CCEngineServer User guide + +## Installation + +### Extract the application +Extract the application into /opt folder +```bash +mkdir /opt/CCEngineServer +tar -xvzf CCEngineServer-.tar.gz --directory /opt/CCEngineServer/ +``` + +### Extract application data into data folder +```bash +unzip data-.zip -d /opt/CCEngineServer/data +``` + +## Activation + +There are two ways to activate the application. One is online activation if you have a license key and your target system +can access internet. The second options is for closed environments where internet access is not possible. + +### Option A: Online activation +```bash +cd /opt/CCEngineServer +sudo ./bin/CCEngineServer --activate_online +``` + +When prompted, please enter provided license key and press enter. + +> Note: In case of connection problems please check if your `/etc/ssl/certs/ca-certificates.crt` exists. +> On some systems the ca-certificates bundle is not in the expected location. You can fix that by creating symbolic link +> to the right location. +> Example on fedora: +> ```bash +> sudo ln -s /etc/ssl/certs/ca-bundle.crt /etc/ssl/certs/ca-certificates.crt +> ``` + +### Option B: Offline activation +```bash +cd /opt/CCEngineServer +sudo ./bin/CCEngineServer --activate_offline +``` + +Copy the generated request as in below example and send by email to customer support of Catalogue of Currencies +```mail +Subject: CCEngineServer activation request + +-----BEGIN ACTIVATION REQUEST----- +ABCabc.... +... +xyzXYZ== +-----END ACTIVATION REQUEST----- +``` + +> Note: Please note that the activation request contains hardware fingerprints from the target device + +The support will email you back `license.dat` file which should be copied to application installation directory +(i.e. its location should be `/opt/CCEngineServer/license.dat`). + +## Running + +### Optional: Create a non-root user + +Although the application needs to be started as root, it can swith to non-root user just after successfull startup. +You can use the commands below to create a new user. +```bash +sudo useradd -M ccengine +sudo usermod -L ccengine +``` + +Find the assigned uid and gid to the created user: +``` +id ccengine +> uid=1001(ccengine) gid=1001(ccengine) groups=1001(ccengine) +``` + +### Run + +If the application is successfully activate it can be started by following commands. Please note that `--set_uid 1001` +and `--set_gid 1001` are optional so these parameters can be either removed and in such case the application will be +running as `root`, or the numbers should be replaced by the uid and gid of the non-root user created in previous steps. + +```bash +cd /opt/CCEngineServer +sudo /opt/CCEngineServer/bin/CCEngineServer --data_root ./data --set_uid 1001 --set_gid 1001 +``` + +> Note: The application by default bind all network interfaces and listens on port 8080. If a different port is needed +> please refer to `CCEngineServer --help` to see how defaults can be changed. + +### Test connection with browser + +Open web browser and enter following into the addres bar `http://:8080/`. + +## Starting the application as systemd service + +### Create new service unit +Example service unit file can look like this. Please note that uid 1001 and gid 1001 should be changed to your own prefered +user + +```ini +# /etc/systemd/system/ccengineserver.service +[Unit] +Description=CCEngineServer data server for Catalogue of Currencies + +[Service] +WorkingDirectory=/opt/CCEngineServer +User=root +ExecStart=/opt/CCEngineServer/bin/CCEngineServer --data_root ./data --log_folder ./log --set_uid 1001 --set_gid 1001 + +[Install] +WantedBy=multi-user.target +``` + +> Note: Please note that in case of using SELinux, the following security context need to be set to the binary executable: +> `sudo chcon -R -t bin_t /opt/CCEngineServer/bin/`. +> The selinux status can be checked by `getenforce`, `sestatus` commands + +### Start the CCEngineServer service +```bash +sudo systemctl start ccengineserver +``` + +### Enable automatic startup +```bash +sudo systemctl enable ccengineserver +``` + +### Optional: Stopping application +```bash +sudo systemctl stop ccengineserver +``` \ No newline at end of file diff --git a/docs/CCEngineServer/license_activator_tool.png b/docs/CCEngineServer/license_activator_tool.png new file mode 100644 index 0000000..ffb715b Binary files /dev/null and b/docs/CCEngineServer/license_activator_tool.png differ diff --git a/docs/CCEngineServer/license_admin_connection.png b/docs/CCEngineServer/license_admin_connection.png new file mode 100644 index 0000000..c096868 Binary files /dev/null and b/docs/CCEngineServer/license_admin_connection.png differ diff --git a/docs/CCEngineServer/license_admin_query.png b/docs/CCEngineServer/license_admin_query.png new file mode 100644 index 0000000..5a5eac1 Binary files /dev/null and b/docs/CCEngineServer/license_admin_query.png differ