Skip to content

Getting started Development

Patrykb0802 edited this page Jun 30, 2023 · 15 revisions

Table of Contents

1. Scada-LTS Installation using standalone installer

2. Enviromental variables

3. Node.js

4. IntelliJ

5. Docker compose

6. jSerialComm Configuration

Current technology stack table:

Technology Version Description
Java 11 Base programic language
Gradle 7.1 Tool for building the application
Tomcat 9.0.75 Servlet server for application
MySQL 8.0.33 Database server for data persistence
Node.js 14.20.1 JavaScript runtime for New UI
Git 2.17.1 Version control for source code

1. Scada-LTS Installation using standalone installer ↑↑↑


1.1 Go to /~https://github.com/SCADA-LTS/linux-installer and select releases tab and then download latest release to desired folder.

1.2. Go to location of downloaded installer and extract it.

1.3. Start first script by using terminal and typing ./mysql_start.sh

Script will ask for some basic information to make configuration run correctly. Below is an example of the data that can be entered:

  • Port: 3306
  • Username: admin
  • Password: admin
  • root password: root

After providing the information you should wait for the line confirming the correct operation of the database:

~/linux-installer-1.2.0/mysql/server/bin/mysqld: ready for connections. Version: '8.0.33' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server - GPL.


1.4. Start second terminal and run ./tomcat_start.sh script.

Similar to first script you will have to provide some information, example below:

  • Enter port: 8080
  • Enter username: root
  • enter password: root
  • enter database port: 3306 (same as one you provided while configurating database)
  • enter database username: admin
  • enter database password: admin

After that you should be able to access Scada-LTS via web browser by typing in search bar localhost:8080/Scada-LTS

2. Enviromental variables ↑↑↑

You will have to add PATH for Java and Catalina in ~/.bashrc file using any available text editor e.g.:

  • nano ~/.bashrc or vim ~/.bashrc

On the bottom of this text file add two lines from below:

  • export CATALINA_HOME="/absolute_path_to_installer/linux-installer-1.2.0/tomcat64/server"
  • export JAVA_HOME="/absolute_path_to_installer/linux-installer-1.2.0/java/jdk"

After all that type in terminal:

  • source ~/.bashrc

This will reload Enviromental variables.

3. Node.js ↑↑↑

First, you will need nvm which is Node Version Manager. You can install it running this command in terminal:

  • curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash

You can check if nvm has installed correctly by typing:

  • nvm --verison

When everything went succesfull we can install chosen version of Node.js with command below:

  • nvm install v14.20.1

To make sure that correct version of node is installed type:

  • node --version

NOTE: If you want to uninstall node or change version of it, you have to use nvm from now on.

4. IntelliJ ↑↑↑

5.1. Download desired version of IntelliJ (Ultimate or Community).

5.2. Put it in freshly made folder and extract it.

5.3. Go inside extracted folder, then to bin folder and run ./idea.sh script.

5.4. Install git with command below:

  • sudo apt-get install git-all

You can confirm if git setup finished correctly by running git version.

This should open your IntelliJ and make it ready to use.

5. Docker-compose ↑↑↑

To check if you have any version of docker installed, run command from below in terminal.

  • dpkg -l | grep -i docker

Installing docker compose

First, we start with commands below to update the apt package index:

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg

Run these commands to add docker’s official GPG key:

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Use command below to set up repository:

echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Than, we install Docker engine and all necessary docker plugins.

  • sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

After that we install docker-compose itself with command below:

  • sudo apt install docker-compose

To add non-admin user to docker group use command below:

  • sudo usermod -aG docker user_name

Where user_name is the username of user you want to be able to launch docker.

To launch Scada-LTS via docker-compose you will have to download docker-compose.yml to desired folder.

Than go inside docker-compose.yml location using terminal and run:

  • docker-compose up database

And in second terminal and same location:

  • docker-compose up scadalts

NOTE: You have to wait for docker-compose up database to finish, otherwise errors may appear.

Uninstalling docker compose

To uninstall all files related to docker use these two commands below:

  • sudo apt-get purge -y `dpkg-query -W -f='${binary:Package}\t' '*docker*'`
  • sudo apt-get autoremove -y --purge `dpkg-query -W -f='${binary:Package}\t' '*docker*'`

To delete all files that docker created e.g. groups, sockets etc. use commands below:

sudo rm -rf /var/lib/docker /etc/docker
sudo rm /etc/apparmor.d/docker
sudo groupdel docker
sudo rm -rf /var/run/docker.sock
sudo rm /etc/apt/keyrings/docker.gpg

If you deleted everything correctly command below should return nothing.

  • dpkg -l | grep -i docker

6. jSerialComm Configuration ↑↑↑

More information about jSerialComm: https://fazecast.github.io/jSerialComm/

However, on linux system configuration is necessary as long as we are not running on root:

sudo usermod -a -G uucp username
sudo usermod -a -G dialout username
sudo usermod -a -G lock username
sudo usermod -a -G tty username

Archives (Date: 30.06.2023) ↑↑↑

Table of Contents

Current technology stack table:

Technology Version Description
Java 11 Base programic language
Gradle 7.1 Tool for building the application
Tomcat 9.0.41 Servlet server for application
MySQL 5.7 Database server for data persistence
Node.js 14.20.1 JavaScript runtime for New UI
Git 2.17.1 Version control for source code

Tools Installation

Java

    The base project is written in Java. So to start development a new features to Scada-LTS you need to install Java Development Kit (JDK). You can do that easily by downloading the valid version from the jdk.java.net website. Then you only need to extract that file and set-up the PATH variable to /bin directory.

Windows

  • For windows download dedicated Windowsx64.zip version.
  • Extract that file in location where you want to keep your Java binaries
    (for example C:\services\java\jdk-11)
  • Set-up the PATH environment variable to bin directory of your installation location
    (for example C:\services\java\jdk-11\bin)
  • Verify that Java is installed correctly, open your terminal and type java -version

Linux

  • For Linux base systems download Linux_x64.tar.gz
  • Create a directory sudo mkdir /opt/java
  • Extract archive to that directory
    (for example: sudo tar -xzf openjdk-11*.tar.gz -C /opt/java/)
  • Set-up the PATH environment variable to bin directory of you installation location
    (for example nano ~/.bashrc and then add at the bottom of that file this lines and save it)

export JAVA_HOME=/opt/java/jdk-11
export PATH=$JAVA_HOME/bin:$PATH

  • Verify that Java is installed correctly, open your terminal and type java -version

Gradle

    Gradle is a general-purpose build tool that makes taht the build process is very simple. Installation of gradle is well described on their official web page. So follow the tutorial and then verify that gradle is installed:

gradle -v

Support Gradle v6.8.1-v7.1

Tomcat

    Tomcat is an servlet web-application server.

  • Download the Tomcat server from their official distribution page
    (If you want to download a specific version use that link to dist archive)

  • Extract that file to specific location

    • Windows: like in our example to C:\services\tomcat
    • Linux: in the same way as before but to /opt/tomcat
  • Set-up the new environment variable with name: CATALINA_HOME that is a reference to tomcat main directory.
    (That is required to perform Java build operation)

  • Import additional Tomcat server libraries:

    • Add that file to /usr/share/tomcat9/lib/ directory.
    • Add files from that directory to tomcat /usr/share/tomcat9/lib/ libs.
  • Setup the Database connection in $CATALINA_HOME\conf\context.xml file.
    Replace it with that configuration file

    From version 2.6.10 there's change in context.xml to work with Docker Compose, so after coping this file to Tomcat, change line: url="jdbc:mysql://database:3306/scadalts" to url="jdbc:mysql://localhost:3306/scadalts"

MySQL

    MySQL must be matching the provided version. If not there will be a problem with establishing the connection from the Scada-LTS application.

Windows

  • Use dedicated installer
  • Configure default password to "root" user: "root".
  • Create a new database with name: "scadalts".

Linux

There is a know bug that on Ubuntu 20.xx there is a problem with installing the MySQL server. It was solved by using the docker image with that server version.

  • Install mysql-server package
    sudo apt update
    sudo apt install mysql-server-5.7
    
  • Configure MySQL server with defaulr password to "root" user: "root".
    sudo mysql_secure_installation
    
  • Initialize MySQL data directory
    • Versions < 5.7.6 - mysql_install_db
    • Versions >= 5.7.6 - mysqld --initialize
  • Enable MySQL server
    sudo systemctl start mysql
    
  • Create a new database with name: "scadalts".

If there is a problem with MySQL server check the Internet for the solution. This installation process was based on the digitalOcean tutorial so check it for more details.

Node.js

  • Download the Long Term Support (LTS) version of Node.js from official site.
  • Extract that file to specific location
    • Windows: like in our example to C:\services\node
    • Linux: in the same way as before but to /opt/node
  • Add a new entry to PATH that is a reference to Node.js main directory.
    (/opt/node/node-v15/bin:$PATH)
  • Verify that Node.js is installed correctly, open your terminal and type node -v
  • Verify that Node Package Manager (npm) was installed with Node.js correctly.
    Open your terminal and type npm -v

Git

    Linux has installation of git by default. So you don't need to install it, but on Windows you need to download it from official site. The easiest way to install git is to use the installer.

Scada-LTS project initialization

Find a good place on your local drive where to store your Scada-LTS project. And in that place use Git Tool to download it from the GitHub repository.

git clone /~https://github.com/SCADA-LTS/Scada-LTS.git

Now you should be able to build and run the project using Gradle (support v6.8.1-v7.1). That command will build the Java application from source code and then will try to compile the Frontend apllication with installing all necessary dependencies. Then that two projects will be bundled together into the one Scada-LTS.war file that will be deployed to the Tomcat server.

gradle buildRunDebugDev

When it will be ready you should be able to access to the application at the following address: localhost:8080/ScadaBR.

Integrated Developmnet Environments (IDEs)

It's up to you to choose the IDE that you want to use. But we recommend to use the JetBrains IntelliJ for the base Java application and VisualStudio Code for the Frontend sub-project. But you can use any other IDE that you want.

Quick install - Linux Ubuntu 20.04+

1. Install mysql server/client commandline:

2. Install mysql client: (optional)

sudo dpkg -i dbeaver-ce_22.1.4_amd64.deb

3. Install JDK11:

sudo apt update
sudo apt install openjdk-11-jdk

4. Install Apache Tomcat 9:

tar -x -f apache-tomcat-9.0.53.tar.gz
  • Set CATALINA_HOME in ~/.bashrc :
vim ~/.bashrc
source ~/.bashrc
  • Copy jar lib to CATALINA_HOME/lib from:
/~https://github.com/SCADA-LTS/Scada-LTS/tree/develop/tomcat/lib
/~https://github.com/SCADA-LTS/Scada-LTS/raw/develop/WebContent/WEB-INF/lib/mysql-connector-java-5.1.49.jar
  • Copy context.xml file to CATALINA_HOME/conf:
/~https://github.com/SCADA-LTS/Scada-LTS/blob/develop/docker/config/context.xml

5. Install Git:

sudo apt update
sudo apt install git

6. Install npm:

sudo apt update
sudo apt install npm

7. Install and configure Intellij:

tar -x -f ideaIC-2022.2.tar.gz
  • run:
./ideaIC-2022.2/bin/idea.sh
  • Clone Scada-LTS project;
  • Create remote JVM port 8000, module Scada-LTS as remote-debug;
  • Build, deploy, and run application (mysql server is running, support Gradle v6.8.1-v7.1):
gradle buildRunDebugDev

8. Open application: Open in browser:

http://localhost:8080/ScadaBR