From 400752615552ba660505f9cff6836ca2394b1d5e Mon Sep 17 00:00:00 2001 From: Andrii Landiak Date: Tue, 12 Sep 2023 15:39:57 +0300 Subject: [PATCH 1/9] Add init edge instructions for ubuntu and centos --- .../centos/instructions.md | 197 ++++++++++++++++++ .../docker/instructions.md | 4 +- .../ubuntu/instructions.md | 125 +++++++++++ .../server/controller/EdgeController.java | 6 +- .../DefaultEdgeInstallService.java | 50 ++++- .../edge/instructions/EdgeInstallService.java | 3 +- .../data/edge/EdgeInstallInstructions.java | 4 +- 7 files changed, 372 insertions(+), 17 deletions(-) create mode 100644 application/src/main/data/json/edge/install_instructions/centos/instructions.md create mode 100644 application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md diff --git a/application/src/main/data/json/edge/install_instructions/centos/instructions.md b/application/src/main/data/json/edge/install_instructions/centos/instructions.md new file mode 100644 index 0000000000..d42ce4499e --- /dev/null +++ b/application/src/main/data/json/edge/install_instructions/centos/instructions.md @@ -0,0 +1,197 @@ +## Install ThingsBoard Edge on CentOS/RHEL Server + +Here is the list of commands, that can be used to quickly install ThingsBoard Edge on RHEL/CentOS 7/8 and connect to the cloud. + +### Prerequisites +Before continue to installation execute the following commands in order to install necessary tools: + +```bash +sudo yum install -y nano wget +sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +``` + +### Install Java 11 (OpenJDK) +ThingsBoard service is running on Java 11. Follow this instructions to install OpenJDK 11: + +```bash +sudo yum install java-11-openjdk +``` +{: .copy-code} + +Please don't forget to configure your operating system to use OpenJDK 11 by default. +You can configure which version is the default using the following command: + +```bash +sudo update-alternatives --config java +``` +{: .copy-code} + +You can check the installation using the following command: + +```bash +java -version +``` +{: .copy-code} + +Expected command output is: + +```text +openjdk version "11.0.xx" +OpenJDK Runtime Environment (...) +OpenJDK 64-Bit Server VM (build ...) +``` + +### Configure PostgreSQL +ThingsBoard Edge uses PostgreSQL database as a local storage. +Instructions listed below will help you to install PostgreSQL. + +```bash +# Update your system +sudo yum update +``` +{: .copy-code} + +**For CentOS 7:** + +```bash +# Install the repository RPM (for CentOS 7): +sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm +# Install packages +sudo yum -y install epel-release yum-utils +sudo yum-config-manager --enable pgdg12 +sudo yum install postgresql12-server postgresql12 +# Initialize your PostgreSQL DB +sudo /usr/pgsql-12/bin/postgresql-12-setup initdb +sudo systemctl start postgresql-12 +# Optional: Configure PostgreSQL to start on boot +sudo systemctl enable --now postgresql-12 + +``` +{: .copy-code} + +**For CentOS 8:** + +```bash +# Install the repository RPM (for CentOS 8): +sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm +# Install packages +sudo dnf -qy module disable postgresql +sudo dnf -y install postgresql12 postgresql12-server +# Initialize your PostgreSQL DB +sudo /usr/pgsql-12/bin/postgresql-12-setup initdb +sudo systemctl start postgresql-12 +# Optional: Configure PostgreSQL to start on boot +sudo systemctl enable --now postgresql-12 + +``` +{: .copy-code} + +Once PostgreSQL is installed you may want to create a new user or set the password for the the main user. +The instructions below will help to set the password for main postgresql user + +```text +sudo su - postgres +psql +\password +\q +``` + +Then, press "Ctrl+D" to return to main user console. + +After configuring the password, edit the pg_hba.conf to use MD5 authentication with the postgres user. + +Edit pg_hba.conf file: + +```bash +sudo nano /var/lib/pgsql/12/data/pg_hba.conf +``` +{: .copy-code} + +Locate the following lines: + +```text +# IPv4 local connections: +host all all 127.0.0.1/32 ident +``` + +Replace `ident` with `md5`: + +```text +host all all 127.0.0.1/32 md5 +``` + +Finally, you should restart the PostgreSQL service to initialize the new configuration: + +```bash +sudo systemctl restart postgresql-12.service +``` +{: .copy-code} + +Connect to the database to create ThingsBoard Edge DB: + +```bash +psql -U postgres -d postgres -h 127.0.0.1 -W +``` +{: .copy-code} + +Execute create database statement + +```bash +CREATE DATABASE tb_edge; +\q +``` +{: .copy-code} + +### ThingsBoard Edge service installation +Download installation package. + +```bash +wget https://github.com/thingsboard/thingsboard-edge/releases/download/{{ site.release.edge_tag }}/tb-edge-{{ site.release.edge_ver }}.rpm +``` +{: .copy-code} + +Go to the download repository and install ThingsBoard Edge service + +```bash +sudo rpm -Uvh tb-edge-${TB_EDGE_VERSION}.rpm +``` +{: .copy-code} + +### Configure ThingsBoard Edge + + +#### [Optional] Update bind ports +If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update docker compose port mapping to avoid port collision between ThingsBoard server and ThingsBoard Edge. + +Please update next lines of `docker-compose.yml` file: + +```bash +ports: + - "18080:8080" + - "11883:1883" + - "15683-15688:5683-5688/udp" +``` +Make sure that ports above (18080, 11883, 15683-15688) are not used by any other application. + +#### Run installation script +Once ThingsBoard Edge is installed and configured please execute the following install script: + +```bash +sudo /usr/share/tb-edge/bin/install/install.sh +``` +{: .copy-code} + +### Restart ThingsBoard Edge service + +```bash +sudo service tb-edge restart +``` + +#### Open ThingsBoard Edge UI + +Once started, you will be able to open **ThingsBoard Edge UI** using the following link http://localhost:8080. + +###### NOTE: Edge HTTP bind port update + +Use next **ThingsBoard Edge UI** link **http://localhost:18080** if you updated HTTP 8080 bind port to **18080**. + diff --git a/application/src/main/data/json/edge/install_instructions/docker/instructions.md b/application/src/main/data/json/edge/install_instructions/docker/instructions.md index 6b93447851..14307dbea7 100644 --- a/application/src/main/data/json/edge/install_instructions/docker/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/docker/instructions.md @@ -1,6 +1,6 @@ -## Install ThingsBoard Edge and connect to cloud instructions +## Install ThingsBoard Edge using Docker -Here is the list of commands, that can be used to quickly install and connect ThingsBoard Edge to the cloud using docker compose. +Here is the list of commands, that can be used to quickly install ThingsBoard Edge using docker compose and connect to the cloud. ### Prerequisites diff --git a/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md b/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md new file mode 100644 index 0000000000..58df993bfa --- /dev/null +++ b/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md @@ -0,0 +1,125 @@ +## Install ThingsBoard Edge on Ubuntu Server + +Here is the list of commands, that can be used to quickly install ThingsBoard Edge on Ubuntu Server and connect to the cloud. + +### Install Java 11 (OpenJDK) +ThingsBoard service is running on Java 11. Follow this instructions to install OpenJDK 11: + +```bash +sudo apt update +sudo apt install openjdk-11-jdk +``` +{: .copy-code} + +Please don't forget to configure your operating system to use OpenJDK 11 by default. +You can configure which version is the default using the following command: + +```bash +sudo update-alternatives --config java +``` +{: .copy-code} + +You can check the installation using the following command: + +```bash +java -version +``` +{: .copy-code} + +Expected command output is: + +```text +openjdk version "11.0.xx" +OpenJDK Runtime Environment (...) +OpenJDK 64-Bit Server VM (build ...) +``` + +### Configure PostgreSQL +ThingsBoard Edge uses PostgreSQL database as a local storage. +Instructions listed below will help you to install PostgreSQL. + +```bash +# install **wget** if not already installed: +sudo apt install -y wget + +# import the repository signing key: +wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - + +# add repository contents to your system: +RELEASE=$(lsb_release -cs) +echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}"-pgdg main | sudo tee /etc/apt/sources.list.d/pgdg.list + +# install and launch the postgresql service: +sudo apt update +sudo apt -y install postgresql-12 +sudo service postgresql start +``` +{: .copy-code} + +Once PostgreSQL is installed you may want to create a new user or set the password for the the main user. +The instructions below will help to set the password for main postgresql user + +```text +sudo su - postgres +psql +\password +\q +``` + +Then, press “Ctrl+D” to return to main user console and connect to the database to create ThingsBoard Edge DB: + +```text +psql -U postgres -d postgres -h 127.0.0.1 -W +CREATE DATABASE tb_edge; +\q +``` + +### Thingsboard Edge service installation +Download installation package. + +```bash +wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_VERSION}/tb-edge-${TB_EDGE_VERSION}.deb +``` +{: .copy-code} + +Go to the download repository and install ThingsBoard Edge service + +```bash +sudo dpkg -i tb-edge-{TB_EDGE_VERSION}.deb +{:copy-code} +``` + +Edit ThingsBoard Edge configuration file + +```bash +sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf +export HTTP_BIND_PORT=18080 +export MQTT_BIND_PORT=11883 +export COAP_BIND_PORT=15683 +export LWM2M_ENABLED=false +EOL' +{:copy-code} +``` + +#### Run installation script + +Once ThingsBoard Edge is installed and configured please execute the following install script: + +```bash +sudo /usr/share/tb-edge/bin/install/install.sh +``` + +#### Restart ThingsBoard Edge service + +```bash +sudo service tb-edge restart +``` + +#### Open ThingsBoard Edge UI + +Once started, you will be able to open **ThingsBoard Edge UI** using the following link http://localhost:8080. + +###### NOTE: Edge HTTP bind port update + +Use next **ThingsBoard Edge UI** link **http://localhost:18080** if you updated HTTP 8080 bind port to **18080**. + diff --git a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java index a50f9c7658..2bc9c0e128 100644 --- a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java +++ b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java @@ -557,17 +557,19 @@ public class EdgeController extends BaseController { notes = "Get a docker install instructions for provided edge id." + TENANT_AUTHORITY_PARAGRAPH, produces = MediaType.APPLICATION_JSON_VALUE) @PreAuthorize("hasAnyAuthority('TENANT_ADMIN')") - @RequestMapping(value = "/edge/instructions/{edgeId}", method = RequestMethod.GET) + @RequestMapping(value = "/edge/instructions/{edgeId}/{method}", method = RequestMethod.GET) @ResponseBody public EdgeInstallInstructions getEdgeDockerInstallInstructions( @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true) @PathVariable("edgeId") String strEdgeId, + @ApiParam(value = "Installation method (e.g., 'docker', 'ubuntu', 'centos')") + @PathVariable("method") String installationMethod, HttpServletRequest request) throws ThingsboardException { if (isEdgesEnabled() && edgeInstallServiceOpt.isPresent()) { EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); edgeId = checkNotNull(edgeId); Edge edge = checkEdgeId(edgeId, Operation.READ); - return checkNotNull(edgeInstallServiceOpt.get().getDockerInstallInstructions(getTenantId(), edge, request)); + return checkNotNull(edgeInstallServiceOpt.get().getInstallInstructions(getTenantId(), edge, installationMethod, request)); } else { throw new ThingsboardException("Edges support disabled", ThingsboardErrorCode.GENERAL); } diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java index 2c4a14635d..455b3e657a 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java @@ -28,7 +28,6 @@ import org.thingsboard.server.service.install.InstallScripts; import javax.servlet.http.HttpServletRequest; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -56,7 +55,20 @@ public class DefaultEdgeInstallService implements EdgeInstallService { private String appVersion; @Override - public EdgeInstallInstructions getDockerInstallInstructions(TenantId tenantId, Edge edge, HttpServletRequest request) { + public EdgeInstallInstructions getInstallInstructions(TenantId tenantId, Edge edge, String installationMethod, HttpServletRequest request) { + switch (installationMethod.toLowerCase()) { + case "docker": + return getDockerInstallInstructions(edge, request); + case "ubuntu": + return getUbuntuInstallInstructions(edge, request); + case "centos": + return getCentosInstallInstructions(edge, request); + default: + throw new IllegalArgumentException("Unsupported installation method for Edge: " + installationMethod); + } + } + + private EdgeInstallInstructions getDockerInstallInstructions(Edge edge, HttpServletRequest request) { String dockerInstallInstructions = readFile(resolveFile("docker", "instructions.md")); String baseUrl = request.getServerName(); if (baseUrl.contains("localhost") || baseUrl.contains("127.0.0.1")) { @@ -67,19 +79,39 @@ public class DefaultEdgeInstallService implements EdgeInstallService { dockerInstallInstructions = dockerInstallInstructions.replace("${LOCALHOST_WARNING}", ""); dockerInstallInstructions = dockerInstallInstructions.replace("${BASE_URL}", baseUrl); } + dockerInstallInstructions = replacePlaceholders(dockerInstallInstructions, edge); + return new EdgeInstallInstructions(dockerInstallInstructions); + } + + private EdgeInstallInstructions getUbuntuInstallInstructions(Edge edge, HttpServletRequest request) { + String ubuntuInstallInstructions = readFile(resolveFile("ubuntu", "instructions.md")); + ubuntuInstallInstructions = replacePlaceholders(ubuntuInstallInstructions, edge); + ubuntuInstallInstructions = ubuntuInstallInstructions.replace("${BASE_URL}", request.getServerName()); + return new EdgeInstallInstructions(ubuntuInstallInstructions); + } + + + private EdgeInstallInstructions getCentosInstallInstructions(Edge edge, HttpServletRequest request) { + String centosInstallInstructions = readFile(resolveFile("centos", "instructions.md")); + centosInstallInstructions = replacePlaceholders(centosInstallInstructions, edge); + centosInstallInstructions = centosInstallInstructions.replace("${BASE_URL}", request.getServerName()); + return new EdgeInstallInstructions(centosInstallInstructions); + } + + private String replacePlaceholders(String instructions, Edge edge) { String edgeVersion = appVersion + "EDGE"; edgeVersion = edgeVersion.replace("-SNAPSHOT", ""); - dockerInstallInstructions = dockerInstallInstructions.replace("${TB_EDGE_VERSION}", edgeVersion); - dockerInstallInstructions = dockerInstallInstructions.replace("${CLOUD_ROUTING_KEY}", edge.getRoutingKey()); - dockerInstallInstructions = dockerInstallInstructions.replace("${CLOUD_ROUTING_SECRET}", edge.getSecret()); - dockerInstallInstructions = dockerInstallInstructions.replace("${CLOUD_RPC_PORT}", Integer.toString(rpcPort)); - dockerInstallInstructions = dockerInstallInstructions.replace("${CLOUD_RPC_SSL_ENABLED}", Boolean.toString(sslEnabled)); - return new EdgeInstallInstructions(dockerInstallInstructions); + instructions = instructions.replace("${TB_EDGE_VERSION}", edgeVersion); + instructions = instructions.replace("${CLOUD_ROUTING_KEY}", edge.getRoutingKey()); + instructions = instructions.replace("${CLOUD_ROUTING_SECRET}", edge.getSecret()); + instructions = instructions.replace("${CLOUD_RPC_PORT}", Integer.toString(rpcPort)); + instructions = instructions.replace("${CLOUD_RPC_SSL_ENABLED}", Boolean.toString(sslEnabled)); + return instructions; } private String readFile(Path file) { try { - return new String(Files.readAllBytes(file), StandardCharsets.UTF_8); + return Files.readString(file); } catch (IOException e) { log.warn("Failed to read file: {}", file, e); throw new RuntimeException(e); diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallService.java index 2a030fc4fa..20cac25e33 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallService.java @@ -23,6 +23,5 @@ import javax.servlet.http.HttpServletRequest; public interface EdgeInstallService { - EdgeInstallInstructions getDockerInstallInstructions(TenantId tenantId, Edge edge, HttpServletRequest request); - + EdgeInstallInstructions getInstallInstructions(TenantId tenantId, Edge edge, String installationMethod, HttpServletRequest request); } diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/edge/EdgeInstallInstructions.java b/common/data/src/main/java/org/thingsboard/server/common/data/edge/EdgeInstallInstructions.java index acfc458906..8343058250 100644 --- a/common/data/src/main/java/org/thingsboard/server/common/data/edge/EdgeInstallInstructions.java +++ b/common/data/src/main/java/org/thingsboard/server/common/data/edge/EdgeInstallInstructions.java @@ -27,6 +27,6 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class EdgeInstallInstructions { - @ApiModelProperty(position = 1, value = "Markdown with docker install instructions") - private String dockerInstallInstructions; + @ApiModelProperty(position = 1, value = "Markdown with install instructions") + private String installInstructions; } From 8412b61812d947751b048aeaa0a2e7146d73c2d8 Mon Sep 17 00:00:00 2001 From: Andrii Landiak Date: Tue, 12 Sep 2023 16:33:30 +0300 Subject: [PATCH 2/9] Improve centos and ubuntu instruction for edge --- .../centos/instructions.md | 58 ++++++++++++++++--- .../docker/instructions.md | 2 +- .../ubuntu/instructions.md | 55 +++++++++++++++++- .../server/controller/EdgeController.java | 2 +- 4 files changed, 105 insertions(+), 12 deletions(-) diff --git a/application/src/main/data/json/edge/install_instructions/centos/instructions.md b/application/src/main/data/json/edge/install_instructions/centos/instructions.md index d42ce4499e..3b0b823777 100644 --- a/application/src/main/data/json/edge/install_instructions/centos/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/centos/instructions.md @@ -158,21 +158,65 @@ sudo rpm -Uvh tb-edge-${TB_EDGE_VERSION}.rpm {: .copy-code} ### Configure ThingsBoard Edge +To configure ThingsBoard Edge, you can either manually edit the configuration file or use a command to automate the process. +#### Automated Configuration +You can use the following command to automatically update the configuration file with specific values: + +```bash +sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf +export CLOUD_ROUTING_KEY=${CLOUD_ROUTING_KEY} +export CLOUD_ROUTING_SECRET=${CLOUD_ROUTING_SECRET} +export CLOUD_RPC_HOST=${BASE_URL} +export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} +export CLOUD_RPC_SSL_ENABLED=${CLOUD_RPC_SSL_ENABLED} +EOL' +``` +{: .copy-code} + +#### Manual Configuration + +```bash +sudo nano /etc/tb-edge/conf/tb-edge.conf +``` +{: .copy-code} + +Please update the following lines in your configuration file. Make sure to replace: + +```text +export CLOUD_ROUTING_KEY=${CLOUD_ROUTING_KEY} +export CLOUD_ROUTING_SECRET=${CLOUD_ROUTING_SECRET} +export CLOUD_RPC_HOST=${BASE_URL} +export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} +export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE + +``` #### [Optional] Update bind ports -If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update docker compose port mapping to avoid port collision between ThingsBoard server and ThingsBoard Edge. +If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update configuration parameters to avoid port collision between ThingsBoard server and ThingsBoard Edge. + +Please uncomment the following parameters in the ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): + +```text +export HTTP_BIND_PORT=18080 +export MQTT_BIND_PORT=11883 +export COAP_BIND_PORT=15683 +export LWM2M_ENABLED=false +``` -Please update next lines of `docker-compose.yml` file: +Or update using command: ```bash -ports: - - "18080:8080" - - "11883:1883" - - "15683-15688:5683-5688/udp" +sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf +export HTTP_BIND_PORT=18080 +export MQTT_BIND_PORT=11883 +export COAP_BIND_PORT=15683 +export LWM2M_ENABLED=false +EOL' ``` -Make sure that ports above (18080, 11883, 15683-15688) are not used by any other application. +{: .copy-code} +Make sure that ports above (18080, 11883, 15683-15688) are not used by any other application. #### Run installation script Once ThingsBoard Edge is installed and configured please execute the following install script: diff --git a/application/src/main/data/json/edge/install_instructions/docker/instructions.md b/application/src/main/data/json/edge/install_instructions/docker/instructions.md index 14307dbea7..d01986a831 100644 --- a/application/src/main/data/json/edge/install_instructions/docker/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/docker/instructions.md @@ -69,7 +69,7 @@ If ThingsBoard Edge is going to be running on the same machine where ThingsBoard Please update next lines of `docker-compose.yml` file: -```bash +```text ports: - "18080:8080" - "11883:1883" diff --git a/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md b/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md index 58df993bfa..ab2bf6f8b4 100644 --- a/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md @@ -86,10 +86,57 @@ Go to the download repository and install ThingsBoard Edge service ```bash sudo dpkg -i tb-edge-{TB_EDGE_VERSION}.deb -{:copy-code} ``` +{: .copy-code} + +### Configure ThingsBoard Edge +To configure ThingsBoard Edge, you can either manually edit the configuration file or use a command to automate the process. + +#### Automated Configuration +You can use the following command to automatically update the configuration file with specific values: + +```bash +sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf +export CLOUD_ROUTING_KEY=${CLOUD_ROUTING_KEY} +export CLOUD_ROUTING_SECRET=${CLOUD_ROUTING_SECRET} +export CLOUD_RPC_HOST=${BASE_URL} +export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} +export CLOUD_RPC_SSL_ENABLED=${CLOUD_RPC_SSL_ENABLED} +EOL' +``` +{: .copy-code} + +#### Manual Configuration + +```bash +sudo nano /etc/tb-edge/conf/tb-edge.conf +``` +{: .copy-code} + +Please update the following lines in your configuration file. Make sure to replace: -Edit ThingsBoard Edge configuration file +```text +export CLOUD_ROUTING_KEY=${CLOUD_ROUTING_KEY} +export CLOUD_ROUTING_SECRET=${CLOUD_ROUTING_SECRET} +export CLOUD_RPC_HOST=${BASE_URL} +export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} +export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE + +``` + +#### [Optional] Update bind ports +If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update configuration parameters to avoid port collision between ThingsBoard server and ThingsBoard Edge. + +Please uncomment the following parameters in the ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): + +```text +export HTTP_BIND_PORT=18080 +export MQTT_BIND_PORT=11883 +export COAP_BIND_PORT=15683 +export LWM2M_ENABLED=false +``` + +Or update using command: ```bash sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf @@ -98,8 +145,10 @@ export MQTT_BIND_PORT=11883 export COAP_BIND_PORT=15683 export LWM2M_ENABLED=false EOL' -{:copy-code} ``` +{: .copy-code} + +Make sure that ports above (18080, 11883, 15683-15688) are not used by any other application. #### Run installation script diff --git a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java index 2bc9c0e128..fa16fbff81 100644 --- a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java +++ b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java @@ -562,7 +562,7 @@ public class EdgeController extends BaseController { public EdgeInstallInstructions getEdgeDockerInstallInstructions( @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true) @PathVariable("edgeId") String strEdgeId, - @ApiParam(value = "Installation method (e.g., 'docker', 'ubuntu', 'centos')") + @ApiParam(value = "Installation method ('docker', 'ubuntu' or 'centos')") @PathVariable("method") String installationMethod, HttpServletRequest request) throws ThingsboardException { if (isEdgesEnabled() && edgeInstallServiceOpt.isPresent()) { From c3f4f8d3a1fcd49e3e04669bdfe6b662d731a669 Mon Sep 17 00:00:00 2001 From: deaflynx Date: Wed, 13 Sep 2023 14:28:59 +0300 Subject: [PATCH 3/9] Edge instructions show after add - UI --- ui-ngx/src/app/core/http/edge.service.ts | 4 +- .../edge-instructions-dialog.component.html | 95 +++++++++---- .../edge-instructions-dialog.component.scss | 129 ++++++++++++++++++ .../edge-instructions-dialog.component.ts | 84 +++++++++--- .../pages/edge/edges-table-config.resolver.ts | 65 ++++++--- ui-ngx/src/app/shared/models/edge.models.ts | 8 +- .../app/shared/models/user-settings.models.ts | 1 + .../assets/locale/locale.constant-en_US.json | 2 + 8 files changed, 326 insertions(+), 62 deletions(-) create mode 100644 ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss diff --git a/ui-ngx/src/app/core/http/edge.service.ts b/ui-ngx/src/app/core/http/edge.service.ts index 078ada56aa..aac095412b 100644 --- a/ui-ngx/src/app/core/http/edge.service.ts +++ b/ui-ngx/src/app/core/http/edge.service.ts @@ -114,7 +114,7 @@ export class EdgeService { return this.http.post('/api/edge/bulk_import', entitiesData, defaultHttpOptionsFromConfig(config)); } - public getEdgeDockerInstallInstructions(edgeId: string, config?: RequestConfig): Observable { - return this.http.get(`/api/edge/instructions/${edgeId}`, defaultHttpOptionsFromConfig(config)); + public getEdgeDockerInstallInstructions(edgeId: string, method: string, config?: RequestConfig): Observable { + return this.http.get(`/api/edge/instructions/${edgeId}/${method}`, defaultHttpOptionsFromConfig(config)); } } diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.html b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.html index 599d984738..cf834e203e 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.html @@ -15,29 +15,74 @@ limitations under the License. --> -
- -

info_outline - {{ 'edge.install-connect-instructions' | translate }}

- - -
- - -
-
- -
-
- -
+ +

{{ dialogTitle }}

+ + +
+
+
+
+ + + + + Ubuntu + + +
+
+ +
+
+
+
+ + + + CentOS + + +
+
+ +
+
+
+
+ + + + Docker + + +
+
+ +
+
+
+
+
+
+
+
+ {{ 'action.dont-show-again' | translate}} + + +
+ +
+ + + {{ 'edge.loading-edge-instructions' | translate }} + +
+
diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss new file mode 100644 index 0000000000..d69eeb6c23 --- /dev/null +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss @@ -0,0 +1,129 @@ +/** + * Copyright © 2016-2023 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@import "../../../../../scss/constants"; + +:host { + height: 100%; + max-height: 100vh; + display: grid; + grid-template-rows: min-content minmax(auto, 1fr) min-content; + + .tb-loader { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + gap: 16px; + height: 300px; + max-height: 100%; + + .label { + margin-bottom: 0; + text-align: center; + } + } + + .tb-font-14 { + font-size: 14px; + } + + .tb-flex-1 { + flex: 1; + } + + @media #{$mat-sm} { + width: 470px; + } + + @media #{$mat-gt-sm} { + width: 720px; + } +} + +:host-context(.mat-mdc-dialog-container) { + .tb-dialog-actions { + display: flex; + gap: 8px; + padding: 8px 16px; + } + + .mat-mdc-dialog-content { + max-height: 80vh; + padding: 16px; + } +} + +:host ::ng-deep { + .tb-markdown-view { + .tb-command-code { + .code-wrapper { + padding: 0; + pre[class*=language-] { + margin: 0; + background: #F3F6FA; + border-color: #305680; + padding-right: 38px; + overflow: scroll; + padding-bottom: 4px; + + &::-webkit-scrollbar { + width: 4px; + height: 4px; + } + } + } + button.clipboard-btn { + right: -2px; + p { + color: #305680; + } + p, div { + background-color: #F3F6FA; + } + div { + img { + display: none; + } + &:after { + content: ""; + position: initial; + display: block; + width: 18px; + height: 18px; + background: #305680; + mask-image: url(/assets/copy-code-icon.svg); + mask-repeat: no-repeat; + } + } + } + } + } + .mdc-button__label > span { + .mat-icon { + vertical-align: text-bottom; + box-sizing: initial; + } + } + + .tabs-icon { + margin-right: 8px; + } + + .tb-form-panel.tb-tab-body { + padding: 16px 0 0; + } +} diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.ts index a4dfe4345b..51d7e42238 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.ts @@ -14,33 +14,83 @@ /// limitations under the License. /// -import { Component, Inject } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogRef } from "@angular/material/dialog"; -import { DialogComponent } from "@shared/components/dialog.component"; -import { Store } from "@ngrx/store"; -import { AppState } from "@core/core.state"; -import { Router } from "@angular/router"; - -export interface EdgeInstructionsData { - instructions: string; +import { Component, Inject, OnDestroy, OnInit } from '@angular/core'; +import { DialogComponent } from '@shared/components/dialog.component'; +import { Store } from '@ngrx/store'; +import { AppState } from '@core/core.state'; +import { Router } from '@angular/router'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { ActionPreferencesPutUserSettings } from '@core/auth/auth.actions'; +import { EdgeInfo, EdgeInstructionsMethod } from '@shared/models/edge.models'; +import { EdgeService } from '@core/http/edge.service'; + +export interface EdgeInstructionsDialogData { + edge: EdgeInfo; + afterAdd: boolean; } @Component({ - selector: 'tb-edge-instructions', - templateUrl: './edge-instructions-dialog.component.html' + selector: 'tb-edge-installation-dialog', + templateUrl: './edge-instructions-dialog.component.html', + styleUrls: ['./edge-instructions-dialog.component.scss'] }) -export class EdgeInstructionsDialogComponent extends DialogComponent { +export class EdgeInstructionsDialogComponent extends DialogComponent implements OnInit, OnDestroy { + + dialogTitle: string; + showDontShowAgain: boolean; - instructions: string = this.data.instructions; + loadedInstructions = false; + notShowAgain = false; + tabIndex = 0; + instructionsMethod = EdgeInstructionsMethod; + contentData: any = {}; constructor(protected store: Store, protected router: Router, - public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: EdgeInstructionsData) { + @Inject(MAT_DIALOG_DATA) private data: EdgeInstructionsDialogData, + public dialogRef: MatDialogRef, + private edgeService: EdgeService) { super(store, router, dialogRef); + + if (this.data.afterAdd) { + this.dialogTitle = 'edge.install-connect-instructions-edge-created'; + this.showDontShowAgain = true; + } else { + this.dialogTitle = 'edge.install-connect-instructions'; + this.showDontShowAgain = false; + } + } + + ngOnInit() { + this.getInstructions(this.instructionsMethod[this.tabIndex]); + } + + ngOnDestroy() { + super.ngOnDestroy(); + } + + close(): void { + if (this.notShowAgain && this.showDontShowAgain) { + this.store.dispatch(new ActionPreferencesPutUserSettings({notDisplayInstructionsAfterAddEdge: true})); + this.dialogRef.close(null); + } else { + this.dialogRef.close(null); + } + } + + selectedTabChange(index: number) { + this.getInstructions(this.instructionsMethod[index]); } - cancel(): void { - this.dialogRef.close(null); + getInstructions(method: string) { + if (!this.contentData[method]) { + this.loadedInstructions = false; + this.edgeService.getEdgeDockerInstallInstructions(this.data.edge.id.id, method).subscribe( + res => { + this.contentData[method] = res.installInstructions; + this.loadedInstructions = true; + } + ); + } } } diff --git a/ui-ngx/src/app/modules/home/pages/edge/edges-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/edge/edges-table-config.resolver.ts index 1acaff3841..6a80388b52 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edges-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/edge/edges-table-config.resolver.ts @@ -29,10 +29,10 @@ import { import { TranslateService } from '@ngx-translate/core'; import { DatePipe } from '@angular/common'; import { EntityType, entityTypeResources, entityTypeTranslations } from '@shared/models/entity-type.models'; -import { EntityAction } from '@home/models/entity/entity-component.models'; +import { AddEntityDialogData, EntityAction } from '@home/models/entity/entity-component.models'; import { forkJoin, Observable, of } from 'rxjs'; import { select, Store } from '@ngrx/store'; -import { selectAuthUser } from '@core/auth/auth.selectors'; +import { selectAuthUser, selectUserSettingsProperty } from '@core/auth/auth.selectors'; import { map, mergeMap, take, tap } from 'rxjs/operators'; import { AppState } from '@core/core.state'; import { Authority } from '@app/shared/models/authority.enum'; @@ -51,7 +51,7 @@ import { AddEntitiesToCustomerDialogData } from '../../dialogs/add-entities-to-customer-dialog.component'; import { HomeDialogsService } from '@home/dialogs/home-dialogs.service'; -import { Edge, EdgeInfo, EdgeInstallInstructions } from '@shared/models/edge.models'; +import { Edge, EdgeInfo } from '@shared/models/edge.models'; import { EdgeService } from '@core/http/edge.service'; import { EdgeComponent } from '@home/pages/edge/edge.component'; import { EdgeTableHeaderComponent } from '@home/pages/edge/edge-table-header.component'; @@ -59,9 +59,10 @@ import { EdgeId } from '@shared/models/id/edge-id'; import { EdgeTabsComponent } from '@home/pages/edge/edge-tabs.component'; import { ActionNotificationShow } from '@core/notification/notification.actions'; import { - EdgeInstructionsData, - EdgeInstructionsDialogComponent -} from "@home/pages/edge/edge-instructions-dialog.component"; + EdgeInstructionsDialogComponent, + EdgeInstructionsDialogData +} from '@home/pages/edge/edge-instructions-dialog.component'; +import { AddEntityDialogComponent } from '@home/components/entity/add-entity-dialog.component'; @Injectable() export class EdgesTableConfigResolver implements Resolve> { @@ -140,6 +141,7 @@ export class EdgesTableConfigResolver implements Resolve this.config.componentsData.edgeScope === 'tenant'; + this.config.addEntity = () => { this.addEdge(); return of(null); }; return this.config; }) ); @@ -530,21 +532,50 @@ export class EdgesTableConfigResolver implements Resolve, + EdgeInfo>(AddEntityDialogComponent, { + disableClose: true, + panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], + data: { + entitiesTableConfig: this.config + } + }).afterClosed().subscribe( + (entity) => { + if (entity) { + this.store.pipe(select(selectUserSettingsProperty('notDisplayInstructionsAfterAddEdge'))).pipe( + take(1) + ).subscribe((settings: boolean) => { + if (!settings) { + this.openInstructions(null, entity, true); + } else { + this.config.updateData(); + this.config.entityAdded(entity); + } + }); + } + } + ); + } + + openInstructions($event, edge: EdgeInfo, afterAdd = false) { if ($event) { $event.stopPropagation(); } - this.edgeService.getEdgeDockerInstallInstructions(edge.id.id).subscribe( - (edgeInstructionsTemplate: EdgeInstallInstructions) => { - this.dialog.open(EdgeInstructionsDialogComponent, { - disableClose: false, - panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], - data: { - instructions: edgeInstructionsTemplate.dockerInstallInstructions - } - }); + this.dialog.open + (EdgeInstructionsDialogComponent, { + disableClose: true, + panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], + data: { + edge, + afterAdd } - ) + }).afterClosed().subscribe(() => { + if (afterAdd) { + this.config.updateData(); + } + } + ); } onEdgeAction(action: EntityAction, config: EntityTableConfig): boolean { diff --git a/ui-ngx/src/app/shared/models/edge.models.ts b/ui-ngx/src/app/shared/models/edge.models.ts index 1acfa2ca28..7b5a6ddb3d 100644 --- a/ui-ngx/src/app/shared/models/edge.models.ts +++ b/ui-ngx/src/app/shared/models/edge.models.ts @@ -179,5 +179,11 @@ export interface EdgeEvent extends BaseData { } export interface EdgeInstallInstructions { - dockerInstallInstructions: string; + installInstructions: string; +} + +export enum EdgeInstructionsMethod { + ubuntu, + centos, + docker } diff --git a/ui-ngx/src/app/shared/models/user-settings.models.ts b/ui-ngx/src/app/shared/models/user-settings.models.ts index ac0bd95c29..bd64e0241b 100644 --- a/ui-ngx/src/app/shared/models/user-settings.models.ts +++ b/ui-ngx/src/app/shared/models/user-settings.models.ts @@ -17,6 +17,7 @@ export interface UserSettings { openedMenuSections?: string[]; notDisplayConnectivityAfterAddDevice?: boolean; + notDisplayInstructionsAfterAddEdge?: boolean; } export const initialUserSettings: UserSettings = { diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 672ed9b1b2..6e9c0375c9 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1962,6 +1962,8 @@ "make-private-edge-text": "After the confirmation the edge and all its data will be made private and won't be accessible by others.", "import": "Import edge", "install-connect-instructions": "Install & Connect Instructions", + "install-connect-instructions-edge-created": "Edge created! Check Install & Connect Instructions", + "loading-edge-instructions": "Loading edge instructions...", "label": "Label", "load-entity-error": "Failed to load data. Entity has been deleted.", "assign-new-edge": "Assign new edge", From 64f1b056f29f0c33c1e3bf9ea57157a53fc755a3 Mon Sep 17 00:00:00 2001 From: deaflynx Date: Wed, 13 Sep 2023 16:09:25 +0300 Subject: [PATCH 4/9] Edge instructions style updates --- .../edge-instructions-dialog.component.html | 22 +++++++++---------- .../edge-instructions-dialog.component.scss | 8 +++++-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.html b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.html index cf834e203e..e01e2ec965 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.html +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.html @@ -30,13 +30,13 @@ - + Ubuntu -
-
- +
+
+
@@ -44,12 +44,12 @@ - CentOS + CentOS/RHEL -
-
- +
+
+
@@ -60,9 +60,9 @@ Docker -
-
- +
+
+
diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss index d69eeb6c23..1524150330 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss @@ -46,11 +46,11 @@ } @media #{$mat-sm} { - width: 470px; + width: 705px; } @media #{$mat-gt-sm} { - width: 720px; + width: 1080px; } } @@ -111,6 +111,10 @@ } } } + > p, h1, h2, h3, h4, h5, div { + padding-left: 16px !important; + padding-right: 16px !important; + } } .mdc-button__label > span { .mat-icon { From bdad8454f8bdc6afcd65429ef96d304941a4e5e0 Mon Sep 17 00:00:00 2001 From: Andrii Landiak Date: Thu, 14 Sep 2023 08:12:30 +0300 Subject: [PATCH 5/9] Fix instructions for ubuntu and docker: styles, info --- .../centos/instructions.md | 90 +++++++++---------- .../docker/instructions.md | 10 +-- .../ubuntu/instructions.md | 72 +++++++-------- .../DefaultEdgeInstallService.java | 10 ++- .../server/controller/EdgeControllerTest.java | 2 +- .../edge-instructions-dialog.component.scss | 1 + 6 files changed, 84 insertions(+), 101 deletions(-) diff --git a/application/src/main/data/json/edge/install_instructions/centos/instructions.md b/application/src/main/data/json/edge/install_instructions/centos/instructions.md index 3b0b823777..486249e320 100644 --- a/application/src/main/data/json/edge/install_instructions/centos/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/centos/instructions.md @@ -1,8 +1,6 @@ -## Install ThingsBoard Edge on CentOS/RHEL Server - Here is the list of commands, that can be used to quickly install ThingsBoard Edge on RHEL/CentOS 7/8 and connect to the cloud. -### Prerequisites +#### Prerequisites Before continue to installation execute the following commands in order to install necessary tools: ```bash @@ -10,28 +8,28 @@ sudo yum install -y nano wget sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm ``` -### Install Java 11 (OpenJDK) -ThingsBoard service is running on Java 11. Follow this instructions to install OpenJDK 11: +#### Install Java 11 (OpenJDK) +ThingsBoard service is running on Java 11. Follow these instructions to install OpenJDK 11: ```bash sudo yum install java-11-openjdk +{:copy-code} ``` -{: .copy-code} Please don't forget to configure your operating system to use OpenJDK 11 by default. You can configure which version is the default using the following command: ```bash sudo update-alternatives --config java +{:copy-code} ``` -{: .copy-code} You can check the installation using the following command: ```bash java -version +{:copy-code} ``` -{: .copy-code} Expected command output is: @@ -41,15 +39,15 @@ OpenJDK Runtime Environment (...) OpenJDK 64-Bit Server VM (build ...) ``` -### Configure PostgreSQL +#### Configure PostgreSQL ThingsBoard Edge uses PostgreSQL database as a local storage. Instructions listed below will help you to install PostgreSQL. ```bash # Update your system sudo yum update +{:copy-code} ``` -{: .copy-code} **For CentOS 7:** @@ -66,8 +64,8 @@ sudo systemctl start postgresql-12 # Optional: Configure PostgreSQL to start on boot sudo systemctl enable --now postgresql-12 +{:copy-code} ``` -{: .copy-code} **For CentOS 8:** @@ -83,8 +81,8 @@ sudo systemctl start postgresql-12 # Optional: Configure PostgreSQL to start on boot sudo systemctl enable --now postgresql-12 +{:copy-code} ``` -{: .copy-code} Once PostgreSQL is installed you may want to create a new user or set the password for the the main user. The instructions below will help to set the password for main postgresql user @@ -104,8 +102,8 @@ Edit pg_hba.conf file: ```bash sudo nano /var/lib/pgsql/12/data/pg_hba.conf +{:copy-code} ``` -{: .copy-code} Locate the following lines: @@ -124,44 +122,41 @@ Finally, you should restart the PostgreSQL service to initialize the new configu ```bash sudo systemctl restart postgresql-12.service +{:copy-code} ``` -{: .copy-code} Connect to the database to create ThingsBoard Edge DB: ```bash psql -U postgres -d postgres -h 127.0.0.1 -W +{:copy-code} ``` -{: .copy-code} Execute create database statement ```bash CREATE DATABASE tb_edge; \q +{:copy-code} ``` -{: .copy-code} -### ThingsBoard Edge service installation -Download installation package. +#### ThingsBoard Edge service installation +Download installation package: ```bash -wget https://github.com/thingsboard/thingsboard-edge/releases/download/{{ site.release.edge_tag }}/tb-edge-{{ site.release.edge_ver }}.rpm +wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_VERSION}/tb-edge-${TB_EDGE_VERSION}.rpm +{:copy-code} ``` -{: .copy-code} Go to the download repository and install ThingsBoard Edge service ```bash sudo rpm -Uvh tb-edge-${TB_EDGE_VERSION}.rpm +{:copy-code} ``` -{: .copy-code} - -### Configure ThingsBoard Edge -To configure ThingsBoard Edge, you can either manually edit the configuration file or use a command to automate the process. -#### Automated Configuration -You can use the following command to automatically update the configuration file with specific values: +#### Configure ThingsBoard Edge +To configure ThingsBoard Edge, you can use the following command to automatically update the configuration file with specific values: ```bash sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf @@ -171,40 +166,33 @@ export CLOUD_RPC_HOST=${BASE_URL} export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} export CLOUD_RPC_SSL_ENABLED=${CLOUD_RPC_SSL_ENABLED} EOL' +{:copy-code} ``` -{: .copy-code} -#### Manual Configuration +##### [Optional] Database Configuration +In case you changed default PostgreSQL datasource settings please update the configuration file with your actual values (**/etc/tb-edge/conf/tb-edge.conf**). +Edit ThingsBoard Edge configuration file: ```bash sudo nano /etc/tb-edge/conf/tb-edge.conf +{:copy-code} ``` -{: .copy-code} -Please update the following lines in your configuration file. Make sure to replace: +Please update the following lines in your configuration file. Make sure **to replace**: +- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource username +- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource password. -```text -export CLOUD_ROUTING_KEY=${CLOUD_ROUTING_KEY} -export CLOUD_ROUTING_SECRET=${CLOUD_ROUTING_SECRET} -export CLOUD_RPC_HOST=${BASE_URL} -export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} +```bash +export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/tb_edge +export SPRING_DATASOURCE_USERNAME=PUT_YOUR_POSTGRESQL_USERNAME_HERE export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE - +{:copy-code} ``` -#### [Optional] Update bind ports +##### [Optional] Update bind ports If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update configuration parameters to avoid port collision between ThingsBoard server and ThingsBoard Edge. -Please uncomment the following parameters in the ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): - -```text -export HTTP_BIND_PORT=18080 -export MQTT_BIND_PORT=11883 -export COAP_BIND_PORT=15683 -export LWM2M_ENABLED=false -``` - -Or update using command: +Please execute the following command to update ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): ```bash sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf @@ -213,22 +201,24 @@ export MQTT_BIND_PORT=11883 export COAP_BIND_PORT=15683 export LWM2M_ENABLED=false EOL' +{:copy-code} ``` -{: .copy-code} Make sure that ports above (18080, 11883, 15683-15688) are not used by any other application. + #### Run installation script Once ThingsBoard Edge is installed and configured please execute the following install script: ```bash sudo /usr/share/tb-edge/bin/install/install.sh +{:copy-code} ``` -{: .copy-code} -### Restart ThingsBoard Edge service +#### Restart ThingsBoard Edge service ```bash sudo service tb-edge restart +{:copy-code} ``` #### Open ThingsBoard Edge UI diff --git a/application/src/main/data/json/edge/install_instructions/docker/instructions.md b/application/src/main/data/json/edge/install_instructions/docker/instructions.md index d01986a831..e308a38076 100644 --- a/application/src/main/data/json/edge/install_instructions/docker/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/docker/instructions.md @@ -1,12 +1,10 @@ -## Install ThingsBoard Edge using Docker - Here is the list of commands, that can be used to quickly install ThingsBoard Edge using docker compose and connect to the cloud. -### Prerequisites +#### Prerequisites Install Docker CE and Docker Compose. -### Create data and logs folders +#### Create data and logs folders Run following commands, before starting docker container(s), to create folders for storing data and logs. These commands additionally will change owner of newly created folders to docker container user. @@ -18,7 +16,7 @@ mkdir -p ~/.mytb-edge-logs && sudo chown -R 799:799 ~/.mytb-edge-logs {:copy-code} ``` -### Running ThingsBoard Edge as docker service +#### Running ThingsBoard Edge as docker service ${LOCALHOST_WARNING} @@ -64,7 +62,7 @@ services: {:copy-code} ``` -#### [Optional] Update bind ports +##### [Optional] Update bind ports If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update docker compose port mapping to avoid port collision between ThingsBoard server and ThingsBoard Edge. Please update next lines of `docker-compose.yml` file: diff --git a/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md b/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md index ab2bf6f8b4..21eb01654a 100644 --- a/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md @@ -1,30 +1,28 @@ -## Install ThingsBoard Edge on Ubuntu Server - Here is the list of commands, that can be used to quickly install ThingsBoard Edge on Ubuntu Server and connect to the cloud. -### Install Java 11 (OpenJDK) -ThingsBoard service is running on Java 11. Follow this instructions to install OpenJDK 11: +#### Install Java 11 (OpenJDK) +ThingsBoard service is running on Java 11. Follow these instructions to install OpenJDK 11: ```bash sudo apt update sudo apt install openjdk-11-jdk +{:copy-code} ``` -{: .copy-code} Please don't forget to configure your operating system to use OpenJDK 11 by default. You can configure which version is the default using the following command: ```bash sudo update-alternatives --config java +{:copy-code} ``` -{: .copy-code} You can check the installation using the following command: ```bash java -version +{:copy-code} ``` -{: .copy-code} Expected command output is: @@ -34,7 +32,7 @@ OpenJDK Runtime Environment (...) OpenJDK 64-Bit Server VM (build ...) ``` -### Configure PostgreSQL +#### Configure PostgreSQL ThingsBoard Edge uses PostgreSQL database as a local storage. Instructions listed below will help you to install PostgreSQL. @@ -53,10 +51,10 @@ echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}"-pgdg main | sudo sudo apt update sudo apt -y install postgresql-12 sudo service postgresql start +{:copy-code} ``` -{: .copy-code} -Once PostgreSQL is installed you may want to create a new user or set the password for the the main user. +Once PostgreSQL is installed you may want to create a new user or set the password for the main user. The instructions below will help to set the password for main postgresql user ```text @@ -74,26 +72,23 @@ CREATE DATABASE tb_edge; \q ``` -### Thingsboard Edge service installation +#### Thingsboard Edge service installation Download installation package. ```bash wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_VERSION}/tb-edge-${TB_EDGE_VERSION}.deb +{:copy-code} ``` -{: .copy-code} Go to the download repository and install ThingsBoard Edge service ```bash -sudo dpkg -i tb-edge-{TB_EDGE_VERSION}.deb +sudo dpkg -i tb-edge-${TB_EDGE_VERSION}.deb +{:copy-code} ``` -{: .copy-code} - -### Configure ThingsBoard Edge -To configure ThingsBoard Edge, you can either manually edit the configuration file or use a command to automate the process. -#### Automated Configuration -You can use the following command to automatically update the configuration file with specific values: +#### Configure ThingsBoard Edge +To configure ThingsBoard Edge, you can use the following command to automatically update the configuration file with specific values: ```bash sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf @@ -103,40 +98,33 @@ export CLOUD_RPC_HOST=${BASE_URL} export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} export CLOUD_RPC_SSL_ENABLED=${CLOUD_RPC_SSL_ENABLED} EOL' +{:copy-code} ``` -{: .copy-code} -#### Manual Configuration +##### [Optional] Database Configuration +In case you changed default PostgreSQL datasource settings please update the configuration file with your actual values (**/etc/tb-edge/conf/tb-edge.conf**). +Edit ThingsBoard Edge configuration file: ```bash sudo nano /etc/tb-edge/conf/tb-edge.conf +{:copy-code} ``` -{: .copy-code} -Please update the following lines in your configuration file. Make sure to replace: +Please update the following lines in your configuration file. Make sure **to replace**: +- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource username +- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource password. -```text -export CLOUD_ROUTING_KEY=${CLOUD_ROUTING_KEY} -export CLOUD_ROUTING_SECRET=${CLOUD_ROUTING_SECRET} -export CLOUD_RPC_HOST=${BASE_URL} -export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} +```bash +export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/tb_edge +export SPRING_DATASOURCE_USERNAME=PUT_YOUR_POSTGRESQL_USERNAME_HERE export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE - +{:copy-code} ``` -#### [Optional] Update bind ports +##### [Optional] Update bind ports If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update configuration parameters to avoid port collision between ThingsBoard server and ThingsBoard Edge. -Please uncomment the following parameters in the ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): - -```text -export HTTP_BIND_PORT=18080 -export MQTT_BIND_PORT=11883 -export COAP_BIND_PORT=15683 -export LWM2M_ENABLED=false -``` - -Or update using command: +Please execute the following command to update ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): ```bash sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf @@ -145,8 +133,8 @@ export MQTT_BIND_PORT=11883 export COAP_BIND_PORT=15683 export LWM2M_ENABLED=false EOL' +{:copy-code} ``` -{: .copy-code} Make sure that ports above (18080, 11883, 15683-15688) are not used by any other application. @@ -156,12 +144,14 @@ Once ThingsBoard Edge is installed and configured please execute the following i ```bash sudo /usr/share/tb-edge/bin/install/install.sh +{:copy-code} ``` #### Restart ThingsBoard Edge service ```bash sudo service tb-edge restart +{:copy-code} ``` #### Open ThingsBoard Edge UI diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java index 455b3e657a..dd17f83317 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java @@ -79,6 +79,9 @@ public class DefaultEdgeInstallService implements EdgeInstallService { dockerInstallInstructions = dockerInstallInstructions.replace("${LOCALHOST_WARNING}", ""); dockerInstallInstructions = dockerInstallInstructions.replace("${BASE_URL}", baseUrl); } + String edgeVersion = appVersion + "EDGE"; + edgeVersion = edgeVersion.replace("-SNAPSHOT", ""); + dockerInstallInstructions = dockerInstallInstructions.replace("${TB_EDGE_VERSION}", edgeVersion); dockerInstallInstructions = replacePlaceholders(dockerInstallInstructions, edge); return new EdgeInstallInstructions(dockerInstallInstructions); } @@ -87,6 +90,8 @@ public class DefaultEdgeInstallService implements EdgeInstallService { String ubuntuInstallInstructions = readFile(resolveFile("ubuntu", "instructions.md")); ubuntuInstallInstructions = replacePlaceholders(ubuntuInstallInstructions, edge); ubuntuInstallInstructions = ubuntuInstallInstructions.replace("${BASE_URL}", request.getServerName()); + String edgeVersion = appVersion.replace("-SNAPSHOT", ""); + ubuntuInstallInstructions = ubuntuInstallInstructions.replace("${TB_EDGE_VERSION}", edgeVersion); return new EdgeInstallInstructions(ubuntuInstallInstructions); } @@ -95,13 +100,12 @@ public class DefaultEdgeInstallService implements EdgeInstallService { String centosInstallInstructions = readFile(resolveFile("centos", "instructions.md")); centosInstallInstructions = replacePlaceholders(centosInstallInstructions, edge); centosInstallInstructions = centosInstallInstructions.replace("${BASE_URL}", request.getServerName()); + String edgeVersion = appVersion.replace("-SNAPSHOT", ""); + centosInstallInstructions = centosInstallInstructions.replace("${TB_EDGE_VERSION}", edgeVersion); return new EdgeInstallInstructions(centosInstallInstructions); } private String replacePlaceholders(String instructions, Edge edge) { - String edgeVersion = appVersion + "EDGE"; - edgeVersion = edgeVersion.replace("-SNAPSHOT", ""); - instructions = instructions.replace("${TB_EDGE_VERSION}", edgeVersion); instructions = instructions.replace("${CLOUD_ROUTING_KEY}", edge.getRoutingKey()); instructions = instructions.replace("${CLOUD_ROUTING_SECRET}", edge.getSecret()); instructions = instructions.replace("${CLOUD_RPC_PORT}", Integer.toString(rpcPort)); diff --git a/application/src/test/java/org/thingsboard/server/controller/EdgeControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/EdgeControllerTest.java index 081ce09ae7..1afeaff0cb 100644 --- a/application/src/test/java/org/thingsboard/server/controller/EdgeControllerTest.java +++ b/application/src/test/java/org/thingsboard/server/controller/EdgeControllerTest.java @@ -1107,7 +1107,7 @@ public class EdgeControllerTest extends AbstractControllerTest { public void testGetEdgeInstallInstructions() throws Exception { Edge edge = constructEdge(tenantId, "Edge for Test Docker Install Instructions", "default", "7390c3a6-69b0-9910-d155-b90aca4b772e", "l7q4zsjplzwhk16geqxy"); Edge savedEdge = doPost("/api/edge", edge, Edge.class); - String installInstructions = doGet("/api/edge/instructions/" + savedEdge.getId().getId().toString(), String.class); + String installInstructions = doGet("/api/edge/instructions/" + savedEdge.getId().getId().toString() + "/docker", String.class); Assert.assertTrue(installInstructions.contains("l7q4zsjplzwhk16geqxy")); Assert.assertTrue(installInstructions.contains("7390c3a6-69b0-9910-d155-b90aca4b772e")); } diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss index 1524150330..9b4339a66c 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss @@ -69,6 +69,7 @@ :host ::ng-deep { .tb-markdown-view { + padding-top: 16px; .tb-command-code { .code-wrapper { padding: 0; From 232810309cb4a3bfcf48dfefa0d866c5810ebd3d Mon Sep 17 00:00:00 2001 From: deaflynx Date: Thu, 14 Sep 2023 10:00:31 +0300 Subject: [PATCH 6/9] getEdgeDockerInstallInstructions rename to getEdgeInstallInstructions, set default param 'method' --- ui-ngx/src/app/core/http/edge.service.ts | 2 +- .../home/pages/edge/edge-instructions-dialog.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/core/http/edge.service.ts b/ui-ngx/src/app/core/http/edge.service.ts index aac095412b..aeb4f7d16b 100644 --- a/ui-ngx/src/app/core/http/edge.service.ts +++ b/ui-ngx/src/app/core/http/edge.service.ts @@ -114,7 +114,7 @@ export class EdgeService { return this.http.post('/api/edge/bulk_import', entitiesData, defaultHttpOptionsFromConfig(config)); } - public getEdgeDockerInstallInstructions(edgeId: string, method: string, config?: RequestConfig): Observable { + public getEdgeInstallInstructions(edgeId: string, method: string = 'ubuntu', config?: RequestConfig): Observable { return this.http.get(`/api/edge/instructions/${edgeId}/${method}`, defaultHttpOptionsFromConfig(config)); } } diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.ts b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.ts index 51d7e42238..99da1dfb14 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.ts @@ -85,7 +85,7 @@ export class EdgeInstructionsDialogComponent extends DialogComponent { this.contentData[method] = res.installInstructions; this.loadedInstructions = true; From f8eb27336565c836f8b0c3983e1b11bd92a6a5e3 Mon Sep 17 00:00:00 2001 From: deaflynx Date: Thu, 14 Sep 2023 10:16:00 +0300 Subject: [PATCH 7/9] Edge instructions add top padding --- .../home/pages/edge/edge-instructions-dialog.component.scss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss index 9b4339a66c..05614add89 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss @@ -131,4 +131,8 @@ .tb-form-panel.tb-tab-body { padding: 16px 0 0; } + + .mat-mdc-tab-body { + padding: 16px 0; + } } From 966af7b825066f36030e4b8d4f4069a9b4fce2b5 Mon Sep 17 00:00:00 2001 From: deaflynx Date: Thu, 14 Sep 2023 12:23:05 +0300 Subject: [PATCH 8/9] Edge instructions fix padding --- .../pages/edge/edge-instructions-dialog.component.scss | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss index 05614add89..0c561cd8f6 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss @@ -69,7 +69,7 @@ :host ::ng-deep { .tb-markdown-view { - padding-top: 16px; + padding: 16px; .tb-command-code { .code-wrapper { padding: 0; @@ -112,9 +112,9 @@ } } } - > p, h1, h2, h3, h4, h5, div { - padding-left: 16px !important; - padding-right: 16px !important; + & > *:not(ul) { + padding-right: unset !important; + padding-left: unset !important; } } .mdc-button__label > span { From 092e3b07c149d732746a7cc58648e4dc8314d0c7 Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 14 Sep 2023 13:44:51 +0300 Subject: [PATCH 9/9] Minor improvements for edge centos/ubuntu instruction. css minor updates --- .../centos/instructions.md | 19 +++--- .../ubuntu/instructions.md | 17 +++--- .../edge-instructions-dialog.component.scss | 61 +++++++------------ 3 files changed, 40 insertions(+), 57 deletions(-) diff --git a/application/src/main/data/json/edge/install_instructions/centos/instructions.md b/application/src/main/data/json/edge/install_instructions/centos/instructions.md index 486249e320..0e9bf251c3 100644 --- a/application/src/main/data/json/edge/install_instructions/centos/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/centos/instructions.md @@ -84,8 +84,8 @@ sudo systemctl enable --now postgresql-12 {:copy-code} ``` -Once PostgreSQL is installed you may want to create a new user or set the password for the the main user. -The instructions below will help to set the password for main postgresql user +Once PostgreSQL is installed you may want to create a new user or set the password for the main user. +The instructions below will help to set the password for main PostgreSQL user: ```text sudo su - postgres @@ -132,7 +132,7 @@ psql -U postgres -d postgres -h 127.0.0.1 -W {:copy-code} ``` -Execute create database statement +Execute create database statement: ```bash CREATE DATABASE tb_edge; @@ -148,7 +148,7 @@ wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDG {:copy-code} ``` -Go to the download repository and install ThingsBoard Edge service +Go to the download repository and install ThingsBoard Edge service: ```bash sudo rpm -Uvh tb-edge-${TB_EDGE_VERSION}.rpm @@ -170,8 +170,7 @@ EOL' ``` ##### [Optional] Database Configuration -In case you changed default PostgreSQL datasource settings please update the configuration file with your actual values (**/etc/tb-edge/conf/tb-edge.conf**). -Edit ThingsBoard Edge configuration file: +In case you changed default PostgreSQL datasource settings (**postgres**/**postgres**) please update the configuration file (**/etc/tb-edge/conf/tb-edge.conf**) with your actual values: ```bash sudo nano /etc/tb-edge/conf/tb-edge.conf @@ -179,12 +178,12 @@ sudo nano /etc/tb-edge/conf/tb-edge.conf ``` Please update the following lines in your configuration file. Make sure **to replace**: -- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource username -- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource password. +- Replace 'postgres' with your actual PostgreSQL username; +- Replace 'PUT_YOUR_POSTGRESQL_PASSWORD_HERE' with your actual PostgreSQL password. ```bash export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/tb_edge -export SPRING_DATASOURCE_USERNAME=PUT_YOUR_POSTGRESQL_USERNAME_HERE +export SPRING_DATASOURCE_USERNAME=postgres export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE {:copy-code} ``` @@ -204,7 +203,7 @@ EOL' {:copy-code} ``` -Make sure that ports above (18080, 11883, 15683-15688) are not used by any other application. +Make sure that ports above (18080, 11883, 15683) are not used by any other application. #### Run installation script Once ThingsBoard Edge is installed and configured please execute the following install script: diff --git a/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md b/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md index 21eb01654a..72b85e5190 100644 --- a/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md @@ -55,7 +55,7 @@ sudo service postgresql start ``` Once PostgreSQL is installed you may want to create a new user or set the password for the main user. -The instructions below will help to set the password for main postgresql user +The instructions below will help to set the password for main PostgreSQL user: ```text sudo su - postgres @@ -73,14 +73,14 @@ CREATE DATABASE tb_edge; ``` #### Thingsboard Edge service installation -Download installation package. +Download installation package: ```bash wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_VERSION}/tb-edge-${TB_EDGE_VERSION}.deb {:copy-code} ``` -Go to the download repository and install ThingsBoard Edge service +Go to the download repository and install ThingsBoard Edge service: ```bash sudo dpkg -i tb-edge-${TB_EDGE_VERSION}.deb @@ -102,8 +102,7 @@ EOL' ``` ##### [Optional] Database Configuration -In case you changed default PostgreSQL datasource settings please update the configuration file with your actual values (**/etc/tb-edge/conf/tb-edge.conf**). -Edit ThingsBoard Edge configuration file: +In case you changed default PostgreSQL datasource settings (**postgres**/**postgres**) please update the configuration file (**/etc/tb-edge/conf/tb-edge.conf**) with your actual values: ```bash sudo nano /etc/tb-edge/conf/tb-edge.conf @@ -111,12 +110,12 @@ sudo nano /etc/tb-edge/conf/tb-edge.conf ``` Please update the following lines in your configuration file. Make sure **to replace**: -- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource username -- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource password. +- Replace 'postgres' with your actual PostgreSQL username; +- Replace 'PUT_YOUR_POSTGRESQL_PASSWORD_HERE' with your actual PostgreSQL password. ```bash export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/tb_edge -export SPRING_DATASOURCE_USERNAME=PUT_YOUR_POSTGRESQL_USERNAME_HERE +export SPRING_DATASOURCE_USERNAME=postgres export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE {:copy-code} ``` @@ -136,7 +135,7 @@ EOL' {:copy-code} ``` -Make sure that ports above (18080, 11883, 15683-15688) are not used by any other application. +Make sure that ports above (18080, 11883, 15683) are not used by any other application. #### Run installation script diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss index 0c561cd8f6..a22671248a 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss @@ -69,48 +69,33 @@ :host ::ng-deep { .tb-markdown-view { - padding: 16px; - .tb-command-code { - .code-wrapper { - padding: 0; - pre[class*=language-] { - margin: 0; - background: #F3F6FA; - border-color: #305680; - padding-right: 38px; - overflow: scroll; - padding-bottom: 4px; - - &::-webkit-scrollbar { - width: 4px; - height: 4px; - } - } + padding: 16px 16px 32px 16px; + div.code-wrapper button.clipboard-btn { + right: -2px !important; + p { + color: #305680; } - button.clipboard-btn { - right: -2px; - p { - color: #305680; - } - p, div { - background-color: #F3F6FA; + p, div { + background-color: #F3F6FA; + } + div { + img { + display: none; } - div { - img { - display: none; - } - &:after { - content: ""; - position: initial; - display: block; - width: 18px; - height: 18px; - background: #305680; - mask-image: url(/assets/copy-code-icon.svg); - mask-repeat: no-repeat; - } + &:after { + content: ""; + position: initial; + display: block; + width: 18px; + height: 18px; + background: #305680; + mask-image: url(/assets/copy-code-icon.svg); + mask-repeat: no-repeat; } } + &.multiline { + right: -2px !important; + } } & > *:not(ul) { padding-right: unset !important;