Install Rapid SCADA on Linux
----------------------------

1. Install ASP.NET Core Runtime 8.0.x according to the instructions
   https://docs.microsoft.com/en-us/dotnet/core/install/linux

   If installation of .NET from the repository is not possible,
   the manual installation sequence is as follows:
   1.1. Download .NET binaries corresponding to the operating system from
        https://dotnet.microsoft.com/en-us/download/dotnet/8.0
   1.2. Extract and copy the downloaded files to /usr/share/dotnet/
   1.3. Make the dotnet file executable:
        sudo chmod +x /usr/share/dotnet/dotnet
   1.4. Create a link to the dotnet file:
        sudo ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet

2. Install Rapid SCADA from the package (option 1)
   sudo dpkg -i rapidscada_VERSION_all.deb

3. Install Rapid SCADA manually (option 2)
   3.1. Copy the extracted files from the scada folder to /opt/scada
   3.2. Make the scripts executable:
        sudo chmod +x /opt/scada/make_executable.sh
        sudo /opt/scada/make_executable.sh
   3.3. Copy the extracted files from the daemons folder to /etc/systemd/system
   3.4. Enable daemons:
        sudo systemctl enable scadaagent6.service
        sudo systemctl enable scadaserver6.service
        sudo systemctl enable scadacomm6.service
        sudo systemctl enable scadaweb6.service

4. Create a RAM drive for writing logs:
   4.1. Create a log directory:
        sudo mkdir /var/log/scada
   4.2. Make a backup copy the /etc/fstab file, and add the following line to the file
tmpfs           /var/log/scada  tmpfs   defaults,noatime,size=100m    0    0

5. Install and setup Nginx:
   5.1. Install Nginx using the instructions:
        https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04
        https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-nginx-in-ubuntu-18-04
        https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04
        Installation commands:
        sudo apt update
        sudo apt install nginx
   5.2. Create a self-signed certificate:
        sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt
   5.3. Copy the extracted file nginx/default to /etc/nginx/sites-available
        after saving a backup copy of the existing file.

6. Restart the computer:
   sudo reboot

7. After restart, open http://localhost or http://SERVER_IP in a web browser
   Username: admin
   Password: scada



Uninstall Rapid SCADA on Linux
------------------------------
1. Restore the original file /etc/fstab

2. If Rapid SCADA was installed from the package:
   sudo dpkg -r rapidscada

3. If Rapid SCADA was installed manually:
   3.1. Disable daemons:
        sudo systemctl disable scadaagent6.service
        sudo systemctl disable scadaserver6.service
        sudo systemctl disable scadacomm6.service
        sudo systemctl disable scadaweb6.service
   3.2. Remove the previously added daemon files from /etc/systemd/system
   3.3. Delete /opt/scada directory with all contents.

4. Remove Nginx and .NET if necessary.
