Commit 587bd387b82faeccf9a6ffc8b2ae6e0fbcb91932

Authored by YevhenBondarenko
2 parents 9e4387af feba4b04

Merge branch 'develop/2.5.1' of https://github.com/thingsboard/thingsboard into develop/2.5.1

Showing 133 changed files with 833 additions and 3127 deletions
@@ -34,10 +34,15 @@ @@ -34,10 +34,15 @@
34 <properties> 34 <properties>
35 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 35 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36 <main.dir>${basedir}/..</main.dir> 36 <main.dir>${basedir}/..</main.dir>
  37 + <pkg.type>java</pkg.type>
  38 + <pkg.disabled>false</pkg.disabled>
  39 + <pkg.process-resources.phase>process-resources</pkg.process-resources.phase>
  40 + <pkg.package.phase>package</pkg.package.phase>
37 <pkg.name>thingsboard</pkg.name> 41 <pkg.name>thingsboard</pkg.name>
38 - <pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder>  
39 - <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder>  
40 <pkg.win.dist>${project.build.directory}/windows</pkg.win.dist> 42 <pkg.win.dist>${project.build.directory}/windows</pkg.win.dist>
  43 + <pkg.copyInstallScripts>true</pkg.copyInstallScripts>
  44 + <pkg.implementationTitle>ThingsBoard</pkg.implementationTitle>
  45 + <pkg.mainClass>org.thingsboard.server.ThingsboardServerApplication</pkg.mainClass>
41 </properties> 46 </properties>
42 47
43 <dependencies> 48 <dependencies>
@@ -309,6 +314,10 @@ @@ -309,6 +314,10 @@
309 <plugins> 314 <plugins>
310 <plugin> 315 <plugin>
311 <groupId>org.apache.maven.plugins</groupId> 316 <groupId>org.apache.maven.plugins</groupId>
  317 + <artifactId>maven-compiler-plugin</artifactId>
  318 + </plugin>
  319 + <plugin>
  320 + <groupId>org.apache.maven.plugins</groupId>
312 <artifactId>maven-surefire-plugin</artifactId> 321 <artifactId>maven-surefire-plugin</artifactId>
313 <version>${surfire.version}</version> 322 <version>${surfire.version}</version>
314 <configuration> 323 <configuration>
@@ -323,313 +332,30 @@ @@ -323,313 +332,30 @@
323 <plugin> 332 <plugin>
324 <groupId>org.apache.maven.plugins</groupId> 333 <groupId>org.apache.maven.plugins</groupId>
325 <artifactId>maven-resources-plugin</artifactId> 334 <artifactId>maven-resources-plugin</artifactId>
326 - <executions>  
327 - <execution>  
328 - <id>copy-conf</id>  
329 - <phase>process-resources</phase>  
330 - <goals>  
331 - <goal>copy-resources</goal>  
332 - </goals>  
333 - <configuration>  
334 - <outputDirectory>${project.build.directory}/conf</outputDirectory>  
335 - <resources>  
336 - <resource>  
337 - <directory>src/main/resources</directory>  
338 - <excludes>  
339 - <exclude>logback.xml</exclude>  
340 - </excludes>  
341 - <filtering>false</filtering>  
342 - </resource>  
343 - </resources>  
344 - </configuration>  
345 - </execution>  
346 - <execution>  
347 - <id>copy-service-conf</id>  
348 - <phase>process-resources</phase>  
349 - <goals>  
350 - <goal>copy-resources</goal>  
351 - </goals>  
352 - <configuration>  
353 - <outputDirectory>${project.build.directory}/conf</outputDirectory>  
354 - <resources>  
355 - <resource>  
356 - <directory>src/main/conf</directory>  
357 - <filtering>true</filtering>  
358 - </resource>  
359 - </resources>  
360 - <filters>  
361 - <filter>src/main/filters/unix.properties</filter>  
362 - </filters>  
363 - </configuration>  
364 - </execution>  
365 - <execution>  
366 - <id>copy-win-conf</id>  
367 - <phase>process-resources</phase>  
368 - <goals>  
369 - <goal>copy-resources</goal>  
370 - </goals>  
371 - <configuration>  
372 - <outputDirectory>${pkg.win.dist}/conf</outputDirectory>  
373 - <resources>  
374 - <resource>  
375 - <directory>src/main/resources</directory>  
376 - <excludes>  
377 - <exclude>logback.xml</exclude>  
378 - </excludes>  
379 - <filtering>false</filtering>  
380 - </resource>  
381 - <resource>  
382 - <directory>src/main/conf</directory>  
383 - <excludes>  
384 - <exclude>thingsboard.conf</exclude>  
385 - </excludes>  
386 - <filtering>true</filtering>  
387 - </resource>  
388 - </resources>  
389 - <filters>  
390 - <filter>src/main/filters/windows.properties</filter>  
391 - </filters>  
392 - </configuration>  
393 - </execution>  
394 - <execution>  
395 - <id>copy-control</id>  
396 - <phase>process-resources</phase>  
397 - <goals>  
398 - <goal>copy-resources</goal>  
399 - </goals>  
400 - <configuration>  
401 - <outputDirectory>${project.build.directory}/control</outputDirectory>  
402 - <resources>  
403 - <resource>  
404 - <directory>src/main/scripts/control</directory>  
405 - <filtering>true</filtering>  
406 - </resource>  
407 - </resources>  
408 - <filters>  
409 - <filter>src/main/filters/unix.properties</filter>  
410 - </filters>  
411 - </configuration>  
412 - </execution>  
413 - <execution>  
414 - <id>copy-install</id>  
415 - <phase>process-resources</phase>  
416 - <goals>  
417 - <goal>copy-resources</goal>  
418 - </goals>  
419 - <configuration>  
420 - <outputDirectory>${project.build.directory}/bin/install</outputDirectory>  
421 - <resources>  
422 - <resource>  
423 - <directory>src/main/scripts/install</directory>  
424 - <includes>  
425 - <include>**/*.sh</include>  
426 - <include>**/*.xml</include>  
427 - </includes>  
428 - <filtering>true</filtering>  
429 - </resource>  
430 - </resources>  
431 - <filters>  
432 - <filter>src/main/filters/unix.properties</filter>  
433 - </filters>  
434 - </configuration>  
435 - </execution>  
436 - <execution>  
437 - <id>copy-windows-control</id>  
438 - <phase>process-resources</phase>  
439 - <goals>  
440 - <goal>copy-resources</goal>  
441 - </goals>  
442 - <configuration>  
443 - <outputDirectory>${pkg.win.dist}</outputDirectory>  
444 - <resources>  
445 - <resource>  
446 - <directory>src/main/scripts/windows</directory>  
447 - <filtering>true</filtering>  
448 - </resource>  
449 - </resources>  
450 - <filters>  
451 - <filter>src/main/filters/windows.properties</filter>  
452 - </filters>  
453 - </configuration>  
454 - </execution>  
455 - <execution>  
456 - <id>copy-windows-install</id>  
457 - <phase>process-resources</phase>  
458 - <goals>  
459 - <goal>copy-resources</goal>  
460 - </goals>  
461 - <configuration>  
462 - <outputDirectory>${pkg.win.dist}/install</outputDirectory>  
463 - <resources>  
464 - <resource>  
465 - <directory>src/main/scripts/install</directory>  
466 - <includes>  
467 - <include>logback.xml</include>  
468 - </includes>  
469 - <filtering>true</filtering>  
470 - </resource>  
471 - </resources>  
472 - <filters>  
473 - <filter>src/main/filters/windows.properties</filter>  
474 - </filters>  
475 - </configuration>  
476 - </execution>  
477 - <execution>  
478 - <id>copy-data</id>  
479 - <phase>process-resources</phase>  
480 - <goals>  
481 - <goal>copy-resources</goal>  
482 - </goals>  
483 - <configuration>  
484 - <outputDirectory>${project.build.directory}/data</outputDirectory>  
485 - <resources>  
486 - <resource>  
487 - <directory>src/main/data</directory>  
488 - </resource>  
489 - <resource>  
490 - <directory>../dao/src/main/resources</directory>  
491 - <includes>  
492 - <include>**/*.cql</include>  
493 - <include>**/*.sql</include>  
494 - </includes>  
495 - <filtering>false</filtering>  
496 - </resource>  
497 - </resources>  
498 - </configuration>  
499 - </execution>  
500 - </executions>  
501 </plugin> 335 </plugin>
502 <plugin> 336 <plugin>
503 <groupId>org.apache.maven.plugins</groupId> 337 <groupId>org.apache.maven.plugins</groupId>
504 <artifactId>maven-dependency-plugin</artifactId> 338 <artifactId>maven-dependency-plugin</artifactId>
505 - <executions>  
506 - <execution>  
507 - <id>copy-winsw-service</id>  
508 - <phase>package</phase>  
509 - <goals>  
510 - <goal>copy</goal>  
511 - </goals>  
512 - <configuration>  
513 - <artifactItems>  
514 - <artifactItem>  
515 - <groupId>com.sun.winsw</groupId>  
516 - <artifactId>winsw</artifactId>  
517 - <classifier>bin</classifier>  
518 - <type>exe</type>  
519 - <destFileName>service.exe</destFileName>  
520 - </artifactItem>  
521 - </artifactItems>  
522 - <outputDirectory>${pkg.win.dist}</outputDirectory>  
523 - </configuration>  
524 - </execution>  
525 - </executions>  
526 </plugin> 339 </plugin>
527 <plugin> 340 <plugin>
528 <groupId>org.apache.maven.plugins</groupId> 341 <groupId>org.apache.maven.plugins</groupId>
529 <artifactId>maven-jar-plugin</artifactId> 342 <artifactId>maven-jar-plugin</artifactId>
530 - <configuration>  
531 - <excludes>  
532 - <exclude>**/logback.xml</exclude>  
533 - </excludes>  
534 - <archive>  
535 - <manifestEntries>  
536 - <Implementation-Title>ThingsBoard</Implementation-Title>  
537 - <Implementation-Version>${project.version}</Implementation-Version>  
538 - </manifestEntries>  
539 - </archive>  
540 - </configuration>  
541 </plugin> 343 </plugin>
542 <plugin> 344 <plugin>
543 <groupId>org.springframework.boot</groupId> 345 <groupId>org.springframework.boot</groupId>
544 <artifactId>spring-boot-maven-plugin</artifactId> 346 <artifactId>spring-boot-maven-plugin</artifactId>
545 - <configuration>  
546 - <mainClass>org.thingsboard.server.ThingsboardServerApplication</mainClass>  
547 - <classifier>boot</classifier>  
548 - <layout>ZIP</layout>  
549 - <executable>true</executable>  
550 - <excludeDevtools>true</excludeDevtools>  
551 - <embeddedLaunchScriptProperties>  
552 - <confFolder>${pkg.installFolder}/conf</confFolder>  
553 - <logFolder>${pkg.unixLogFolder}</logFolder>  
554 - <logFilename>${pkg.name}.out</logFilename>  
555 - <initInfoProvides>${pkg.name}</initInfoProvides>  
556 - </embeddedLaunchScriptProperties>  
557 - </configuration>  
558 - <executions>  
559 - <execution>  
560 - <goals>  
561 - <goal>repackage</goal>  
562 - </goals>  
563 - </execution>  
564 - </executions>  
565 </plugin> 347 </plugin>
566 <plugin> 348 <plugin>
567 <groupId>org.thingsboard</groupId> 349 <groupId>org.thingsboard</groupId>
568 <artifactId>gradle-maven-plugin</artifactId> 350 <artifactId>gradle-maven-plugin</artifactId>
569 - <configuration>  
570 - <tasks>  
571 - <task>build</task>  
572 - <task>buildDeb</task>  
573 - <task>buildRpm</task>  
574 - </tasks>  
575 - <args>  
576 - <arg>-PprojectBuildDir=${project.build.directory}</arg>  
577 - <arg>-PprojectVersion=${project.version}</arg>  
578 - <arg>-PmainJar=${project.build.directory}/${project.build.finalName}-boot.${project.packaging}  
579 - </arg>  
580 - <arg>-PpkgName=${pkg.name}</arg>  
581 - <arg>-PpkgInstallFolder=${pkg.installFolder}</arg>  
582 - <arg>-PpkgLogFolder=${pkg.unixLogFolder}</arg>  
583 - </args>  
584 - </configuration>  
585 - <executions>  
586 - <execution>  
587 - <phase>package</phase>  
588 - <goals>  
589 - <goal>invoke</goal>  
590 - </goals>  
591 - </execution>  
592 - </executions>  
593 </plugin> 351 </plugin>
594 <plugin> 352 <plugin>
595 <groupId>org.apache.maven.plugins</groupId> 353 <groupId>org.apache.maven.plugins</groupId>
596 <artifactId>maven-assembly-plugin</artifactId> 354 <artifactId>maven-assembly-plugin</artifactId>
597 - <configuration>  
598 - <finalName>${pkg.name}</finalName>  
599 - <descriptors>  
600 - <descriptor>src/main/assembly/windows.xml</descriptor>  
601 - </descriptors>  
602 - </configuration>  
603 - <executions>  
604 - <execution>  
605 - <id>assembly</id>  
606 - <phase>package</phase>  
607 - <goals>  
608 - <goal>single</goal>  
609 - </goals>  
610 - </execution>  
611 - </executions>  
612 </plugin> 355 </plugin>
613 <plugin> 356 <plugin>
614 <groupId>org.apache.maven.plugins</groupId> 357 <groupId>org.apache.maven.plugins</groupId>
615 <artifactId>maven-install-plugin</artifactId> 358 <artifactId>maven-install-plugin</artifactId>
616 - <configuration>  
617 - <file>${project.build.directory}/${pkg.name}.deb</file>  
618 - <artifactId>${project.artifactId}</artifactId>  
619 - <groupId>${project.groupId}</groupId>  
620 - <version>${project.version}</version>  
621 - <classifier>deb</classifier>  
622 - <packaging>deb</packaging>  
623 - </configuration>  
624 - <executions>  
625 - <execution>  
626 - <id>install-deb</id>  
627 - <phase>package</phase>  
628 - <goals>  
629 - <goal>install-file</goal>  
630 - </goals>  
631 - </execution>  
632 - </executions>  
633 </plugin> 359 </plugin>
634 <plugin> 360 <plugin>
635 <groupId>org.xolstice.maven.plugins</groupId> 361 <groupId>org.xolstice.maven.plugins</groupId>
@@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; @@ -20,6 +20,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
20 import com.google.common.util.concurrent.FutureCallback; 20 import com.google.common.util.concurrent.FutureCallback;
21 import lombok.extern.slf4j.Slf4j; 21 import lombok.extern.slf4j.Slf4j;
22 import org.springframework.beans.factory.annotation.Autowired; 22 import org.springframework.beans.factory.annotation.Autowired;
  23 +import org.springframework.beans.factory.annotation.Value;
23 import org.springframework.http.HttpStatus; 24 import org.springframework.http.HttpStatus;
24 import org.springframework.http.ResponseEntity; 25 import org.springframework.http.ResponseEntity;
25 import org.springframework.security.access.prepost.PreAuthorize; 26 import org.springframework.security.access.prepost.PreAuthorize;
@@ -65,7 +66,6 @@ import java.util.UUID; @@ -65,7 +66,6 @@ import java.util.UUID;
65 @Slf4j 66 @Slf4j
66 public class RpcController extends BaseController { 67 public class RpcController extends BaseController {
67 68
68 - public static final int DEFAULT_TIMEOUT = 10000;  
69 protected final ObjectMapper jsonMapper = new ObjectMapper(); 69 protected final ObjectMapper jsonMapper = new ObjectMapper();
70 70
71 @Autowired 71 @Autowired
@@ -74,6 +74,12 @@ public class RpcController extends BaseController { @@ -74,6 +74,12 @@ public class RpcController extends BaseController {
74 @Autowired 74 @Autowired
75 private AccessValidator accessValidator; 75 private AccessValidator accessValidator;
76 76
  77 + @Value("${server.rest.server_side_rpc.min_timeout:5000}")
  78 + private long minTimeout;
  79 +
  80 + @Value("${server.rest.server_side_rpc.default_timeout:10000}")
  81 + private long defaultTimeout;
  82 +
77 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')") 83 @PreAuthorize("hasAnyAuthority('SYS_ADMIN', 'TENANT_ADMIN', 'CUSTOMER_USER')")
78 @RequestMapping(value = "/oneway/{deviceId}", method = RequestMethod.POST) 84 @RequestMapping(value = "/oneway/{deviceId}", method = RequestMethod.POST)
79 @ResponseBody 85 @ResponseBody
@@ -100,7 +106,8 @@ public class RpcController extends BaseController { @@ -100,7 +106,8 @@ public class RpcController extends BaseController {
100 SecurityUser currentUser = getCurrentUser(); 106 SecurityUser currentUser = getCurrentUser();
101 TenantId tenantId = currentUser.getTenantId(); 107 TenantId tenantId = currentUser.getTenantId();
102 final DeferredResult<ResponseEntity> response = new DeferredResult<>(); 108 final DeferredResult<ResponseEntity> response = new DeferredResult<>();
103 - long timeout = System.currentTimeMillis() + (cmd.getTimeout() != null ? cmd.getTimeout() : DEFAULT_TIMEOUT); 109 + long timeout = cmd.getTimeout() != null ? cmd.getTimeout() : defaultTimeout;
  110 + long expTime = System.currentTimeMillis() + Math.max(minTimeout, timeout);
104 ToDeviceRpcRequestBody body = new ToDeviceRpcRequestBody(cmd.getMethodName(), cmd.getRequestData()); 111 ToDeviceRpcRequestBody body = new ToDeviceRpcRequestBody(cmd.getMethodName(), cmd.getRequestData());
105 accessValidator.validate(currentUser, Operation.RPC_CALL, deviceId, new HttpValidationCallback(response, new FutureCallback<DeferredResult<ResponseEntity>>() { 112 accessValidator.validate(currentUser, Operation.RPC_CALL, deviceId, new HttpValidationCallback(response, new FutureCallback<DeferredResult<ResponseEntity>>() {
106 @Override 113 @Override
@@ -109,7 +116,7 @@ public class RpcController extends BaseController { @@ -109,7 +116,7 @@ public class RpcController extends BaseController {
109 tenantId, 116 tenantId,
110 deviceId, 117 deviceId,
111 oneWay, 118 oneWay,
112 - timeout, 119 + expTime,
113 body 120 body
114 ); 121 );
115 deviceRpcService.processRestApiRpcRequest(rpcRequest, fromDeviceRpcResponse -> reply(new LocalRequestMetaData(rpcRequest, currentUser, result), fromDeviceRpcResponse)); 122 deviceRpcService.processRestApiRpcRequest(rpcRequest, fromDeviceRpcResponse -> reply(new LocalRequestMetaData(rpcRequest, currentUser, result), fromDeviceRpcResponse));
@@ -32,6 +32,8 @@ import org.thingsboard.server.utils.MiscUtils; @@ -32,6 +32,8 @@ import org.thingsboard.server.utils.MiscUtils;
32 import javax.servlet.http.HttpServletRequest; 32 import javax.servlet.http.HttpServletRequest;
33 import javax.servlet.http.HttpServletResponse; 33 import javax.servlet.http.HttpServletResponse;
34 import java.io.IOException; 34 import java.io.IOException;
  35 +import java.net.URLEncoder;
  36 +import java.nio.charset.StandardCharsets;
35 37
36 @Component(value = "oauth2AuthenticationSuccessHandler") 38 @Component(value = "oauth2AuthenticationSuccessHandler")
37 @ConditionalOnProperty(prefix = "security.oauth2", value = "enabled", havingValue = "true") 39 @ConditionalOnProperty(prefix = "security.oauth2", value = "enabled", havingValue = "true")
@@ -57,16 +59,22 @@ public class Oauth2AuthenticationSuccessHandler extends SimpleUrlAuthenticationS @@ -57,16 +59,22 @@ public class Oauth2AuthenticationSuccessHandler extends SimpleUrlAuthenticationS
57 public void onAuthenticationSuccess(HttpServletRequest request, 59 public void onAuthenticationSuccess(HttpServletRequest request,
58 HttpServletResponse response, 60 HttpServletResponse response,
59 Authentication authentication) throws IOException { 61 Authentication authentication) throws IOException {
60 - OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) authentication;  
61 62
62 - OAuth2Client oauth2Client = oauth2Configuration.getClientByRegistrationId(token.getAuthorizedClientRegistrationId());  
63 - OAuth2ClientMapper mapper = oauth2ClientMapperProvider.getOAuth2ClientMapperByType(oauth2Client.getMapperConfig().getType());  
64 - SecurityUser securityUser = mapper.getOrCreateUserByClientPrincipal(token, oauth2Client.getMapperConfig()); 63 + String baseUrl = MiscUtils.constructBaseUrl(request);
  64 + try {
  65 + OAuth2AuthenticationToken token = (OAuth2AuthenticationToken) authentication;
65 66
66 - JwtToken accessToken = tokenFactory.createAccessJwtToken(securityUser);  
67 - JwtToken refreshToken = refreshTokenRepository.requestRefreshToken(securityUser); 67 + OAuth2Client oauth2Client = oauth2Configuration.getClientByRegistrationId(token.getAuthorizedClientRegistrationId());
  68 + OAuth2ClientMapper mapper = oauth2ClientMapperProvider.getOAuth2ClientMapperByType(oauth2Client.getMapperConfig().getType());
  69 + SecurityUser securityUser = mapper.getOrCreateUserByClientPrincipal(token, oauth2Client.getMapperConfig());
68 70
69 - String baseUrl = MiscUtils.constructBaseUrl(request);  
70 - getRedirectStrategy().sendRedirect(request, response, baseUrl + "/?accessToken=" + accessToken.getToken() + "&refreshToken=" + refreshToken.getToken()); 71 + JwtToken accessToken = tokenFactory.createAccessJwtToken(securityUser);
  72 + JwtToken refreshToken = refreshTokenRepository.requestRefreshToken(securityUser);
  73 +
  74 + getRedirectStrategy().sendRedirect(request, response, baseUrl + "/?accessToken=" + accessToken.getToken() + "&refreshToken=" + refreshToken.getToken());
  75 + } catch (Exception e) {
  76 + getRedirectStrategy().sendRedirect(request, response, baseUrl + "/login?loginError=" +
  77 + URLEncoder.encode(e.getMessage(), StandardCharsets.UTF_8.toString()));
  78 + }
71 } 79 }
72 } 80 }
@@ -17,6 +17,7 @@ package org.thingsboard.server.service.transport; @@ -17,6 +17,7 @@ package org.thingsboard.server.service.transport;
17 17
18 import com.fasterxml.jackson.core.JsonProcessingException; 18 import com.fasterxml.jackson.core.JsonProcessingException;
19 import com.fasterxml.jackson.databind.ObjectMapper; 19 import com.fasterxml.jackson.databind.ObjectMapper;
  20 +import com.fasterxml.jackson.databind.node.ObjectNode;
20 import com.google.common.util.concurrent.Futures; 21 import com.google.common.util.concurrent.Futures;
21 import com.google.common.util.concurrent.ListenableFuture; 22 import com.google.common.util.concurrent.ListenableFuture;
22 import com.google.common.util.concurrent.MoreExecutors; 23 import com.google.common.util.concurrent.MoreExecutors;
@@ -24,13 +25,18 @@ import lombok.extern.slf4j.Slf4j; @@ -24,13 +25,18 @@ import lombok.extern.slf4j.Slf4j;
24 import org.springframework.beans.factory.annotation.Autowired; 25 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.stereotype.Service; 26 import org.springframework.stereotype.Service;
26 import org.springframework.util.StringUtils; 27 import org.springframework.util.StringUtils;
  28 +import org.thingsboard.server.common.data.DataConstants;
27 import org.thingsboard.server.common.data.Device; 29 import org.thingsboard.server.common.data.Device;
28 import org.thingsboard.server.common.data.Tenant; 30 import org.thingsboard.server.common.data.Tenant;
  31 +import org.thingsboard.server.common.data.id.CustomerId;
29 import org.thingsboard.server.common.data.id.DeviceId; 32 import org.thingsboard.server.common.data.id.DeviceId;
30 import org.thingsboard.server.common.data.id.TenantId; 33 import org.thingsboard.server.common.data.id.TenantId;
31 import org.thingsboard.server.common.data.relation.EntityRelation; 34 import org.thingsboard.server.common.data.relation.EntityRelation;
32 import org.thingsboard.server.common.data.security.DeviceCredentials; 35 import org.thingsboard.server.common.data.security.DeviceCredentials;
33 import org.thingsboard.server.common.data.security.DeviceCredentialsType; 36 import org.thingsboard.server.common.data.security.DeviceCredentialsType;
  37 +import org.thingsboard.server.common.msg.TbMsg;
  38 +import org.thingsboard.server.common.msg.TbMsgDataType;
  39 +import org.thingsboard.server.common.msg.TbMsgMetaData;
34 import org.thingsboard.server.dao.device.DeviceCredentialsService; 40 import org.thingsboard.server.dao.device.DeviceCredentialsService;
35 import org.thingsboard.server.dao.device.DeviceService; 41 import org.thingsboard.server.dao.device.DeviceService;
36 import org.thingsboard.server.dao.relation.RelationService; 42 import org.thingsboard.server.dao.relation.RelationService;
@@ -48,6 +54,7 @@ import org.thingsboard.server.gen.transport.TransportProtos.ValidateDeviceX509Ce @@ -48,6 +54,7 @@ import org.thingsboard.server.gen.transport.TransportProtos.ValidateDeviceX509Ce
48 import org.thingsboard.server.queue.common.TbProtoQueueMsg; 54 import org.thingsboard.server.queue.common.TbProtoQueueMsg;
49 import org.thingsboard.server.queue.util.TbCoreComponent; 55 import org.thingsboard.server.queue.util.TbCoreComponent;
50 import org.thingsboard.server.service.executors.DbCallbackExecutorService; 56 import org.thingsboard.server.service.executors.DbCallbackExecutorService;
  57 +import org.thingsboard.server.service.queue.TbClusterService;
51 import org.thingsboard.server.service.state.DeviceStateService; 58 import org.thingsboard.server.service.state.DeviceStateService;
52 59
53 import java.util.UUID; 60 import java.util.UUID;
@@ -82,6 +89,9 @@ public class DefaultTransportApiService implements TransportApiService { @@ -82,6 +89,9 @@ public class DefaultTransportApiService implements TransportApiService {
82 @Autowired 89 @Autowired
83 private DbCallbackExecutorService dbCallbackExecutorService; 90 private DbCallbackExecutorService dbCallbackExecutorService;
84 91
  92 + @Autowired
  93 + protected TbClusterService tbClusterService;
  94 +
85 private ReentrantLock deviceCreationLock = new ReentrantLock(); 95 private ReentrantLock deviceCreationLock = new ReentrantLock();
86 96
87 @Override 97 @Override
@@ -119,14 +129,27 @@ public class DefaultTransportApiService implements TransportApiService { @@ -119,14 +129,27 @@ public class DefaultTransportApiService implements TransportApiService {
119 try { 129 try {
120 Device device = deviceService.findDeviceByTenantIdAndName(gateway.getTenantId(), requestMsg.getDeviceName()); 130 Device device = deviceService.findDeviceByTenantIdAndName(gateway.getTenantId(), requestMsg.getDeviceName());
121 if (device == null) { 131 if (device == null) {
  132 + TenantId tenantId = gateway.getTenantId();
122 device = new Device(); 133 device = new Device();
123 - device.setTenantId(gateway.getTenantId()); 134 + device.setTenantId(tenantId);
124 device.setName(requestMsg.getDeviceName()); 135 device.setName(requestMsg.getDeviceName());
125 device.setType(requestMsg.getDeviceType()); 136 device.setType(requestMsg.getDeviceType());
126 device.setCustomerId(gateway.getCustomerId()); 137 device.setCustomerId(gateway.getCustomerId());
127 device = deviceService.saveDevice(device); 138 device = deviceService.saveDevice(device);
128 relationService.saveRelationAsync(TenantId.SYS_TENANT_ID, new EntityRelation(gateway.getId(), device.getId(), "Created")); 139 relationService.saveRelationAsync(TenantId.SYS_TENANT_ID, new EntityRelation(gateway.getId(), device.getId(), "Created"));
129 deviceStateService.onDeviceAdded(device); 140 deviceStateService.onDeviceAdded(device);
  141 +
  142 + TbMsgMetaData metaData = new TbMsgMetaData();
  143 + CustomerId customerId = gateway.getCustomerId();
  144 + if (customerId != null && !customerId.isNullUid()) {
  145 + metaData.putValue("customerId", customerId.toString());
  146 + }
  147 + metaData.putValue("gatewayId", gatewayId.toString());
  148 +
  149 + DeviceId deviceId = device.getId();
  150 + ObjectNode entityNode = mapper.valueToTree(device);
  151 + TbMsg tbMsg = TbMsg.newMsg(DataConstants.ENTITY_CREATED, deviceId, metaData, TbMsgDataType.JSON, mapper.writeValueAsString(entityNode));
  152 + tbClusterService.pushMsgToRuleEngine(tenantId, deviceId, tbMsg, null);
130 } 153 }
131 return TransportApiResponseMsg.newBuilder() 154 return TransportApiResponseMsg.newBuilder()
132 .setGetOrCreateDeviceResponseMsg(GetOrCreateDeviceFromGatewayResponseMsg.newBuilder().setDeviceInfo(getDeviceInfoProto(device)).build()).build(); 155 .setGetOrCreateDeviceResponseMsg(GetOrCreateDeviceFromGatewayResponseMsg.newBuilder().setDeviceInfo(getDeviceInfoProto(device)).build()).build();
@@ -54,6 +54,13 @@ server: @@ -54,6 +54,13 @@ server:
54 customer: 54 customer:
55 enabled: "${TB_SERVER_REST_LIMITS_CUSTOMER_ENABLED:false}" 55 enabled: "${TB_SERVER_REST_LIMITS_CUSTOMER_ENABLED:false}"
56 configuration: "${TB_SERVER_REST_LIMITS_CUSTOMER_CONFIGURATION:50:1,1000:60}" 56 configuration: "${TB_SERVER_REST_LIMITS_CUSTOMER_CONFIGURATION:50:1,1000:60}"
  57 + server_side_rpc:
  58 + # Minimum value of the server side RPC timeout. May override value provided in the REST API call.
  59 + # Since 2.5 migration to queues, the RPC delay depends on the size of the pending messages in the queue,
  60 + # so default UI parameter of 500ms may not be sufficient for loaded environments.
  61 + min_timeout: "${MIN_SERVER_SIDE_RPC_TIMEOUT:5000}"
  62 + # Default value of the server side RPC timeout.
  63 + default_timeout: "${DEFAULT_SERVER_SIDE_RPC_TIMEOUT:10000}"
57 64
58 # Zookeeper connection parameters. Used for service discovery. 65 # Zookeeper connection parameters. Used for service discovery.
59 zk: 66 zk:
1 -/**  
2 - * Copyright © 2016-2020 The Thingsboard Authors  
3 - *  
4 - * Licensed under the Apache License, Version 2.0 (the "License");  
5 - * you may not use this file except in compliance with the License.  
6 - * You may obtain a copy of the License at  
7 - *  
8 - * http://www.apache.org/licenses/LICENSE-2.0  
9 - *  
10 - * Unless required by applicable law or agreed to in writing, software  
11 - * distributed under the License is distributed on an "AS IS" BASIS,  
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
13 - * See the License for the specific language governing permissions and  
14 - * limitations under the License.  
15 - */  
16 -package org.thingsboard.server.rules;  
17 -  
18 -import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;  
19 -import org.junit.BeforeClass;  
20 -import org.junit.ClassRule;  
21 -import org.junit.extensions.cpsuite.ClasspathSuite;  
22 -import org.junit.runner.RunWith;  
23 -import org.thingsboard.server.dao.CustomCassandraCQLUnit;  
24 -import org.thingsboard.server.dao.CustomSqlUnit;  
25 -import org.thingsboard.server.queue.memory.InMemoryStorage;  
26 -  
27 -import java.util.Arrays;  
28 -  
29 -@RunWith(ClasspathSuite.class)  
30 -@ClasspathSuite.ClassnameFilters({  
31 - "org.thingsboard.server.rules.flow.nosql.*Test",  
32 - "org.thingsboard.server.rules.lifecycle.nosql.*Test"  
33 -})  
34 -public class RuleEngineNoSqlTestSuite {  
35 -  
36 - @ClassRule  
37 - public static CustomCassandraCQLUnit cassandraUnit =  
38 - new CustomCassandraCQLUnit(  
39 - Arrays.asList(  
40 - new ClassPathCQLDataSet("cassandra/schema-ts.cql", false, false),  
41 - new ClassPathCQLDataSet("cassandra/schema-entities.cql", false, false),  
42 - new ClassPathCQLDataSet("cassandra/system-data.cql", false, false)),  
43 - "cassandra-test.yaml", 30000l);  
44 -  
45 - @BeforeClass  
46 - public static void cleanupInMemStorage(){  
47 - InMemoryStorage.getInstance().cleanup();  
48 - }  
49 -  
50 -}  
@@ -40,6 +40,7 @@ import java.util.UUID; @@ -40,6 +40,7 @@ import java.util.UUID;
40 public final class TbMsg implements Serializable { 40 public final class TbMsg implements Serializable {
41 41
42 private final UUID id; 42 private final UUID id;
  43 + private final long ts;
43 private final String type; 44 private final String type;
44 private final EntityId originator; 45 private final EntityId originator;
45 private final TbMsgMetaData metaData; 46 private final TbMsgMetaData metaData;
@@ -51,38 +52,43 @@ public final class TbMsg implements Serializable { @@ -51,38 +52,43 @@ public final class TbMsg implements Serializable {
51 transient private final TbMsgCallback callback; 52 transient private final TbMsgCallback callback;
52 53
53 public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, String data) { 54 public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, String data) {
54 - return new TbMsg(UUID.randomUUID(), type, originator, metaData.copy(), TbMsgDataType.JSON, data, null, null, TbMsgCallback.EMPTY); 55 + return new TbMsg(UUID.randomUUID(), System.currentTimeMillis(), type, originator, metaData.copy(), TbMsgDataType.JSON, data, null, null, TbMsgCallback.EMPTY);
55 } 56 }
56 57
57 public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, String data, RuleChainId ruleChainId, RuleNodeId ruleNodeId) { 58 public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, String data, RuleChainId ruleChainId, RuleNodeId ruleNodeId) {
58 - return new TbMsg(UUID.randomUUID(), type, originator, metaData.copy(), TbMsgDataType.JSON, data, ruleChainId, ruleNodeId, TbMsgCallback.EMPTY); 59 + return new TbMsg(UUID.randomUUID(), System.currentTimeMillis(), type, originator, metaData.copy(), TbMsgDataType.JSON, data, ruleChainId, ruleNodeId, TbMsgCallback.EMPTY);
59 } 60 }
60 61
61 public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, TbMsgDataType dataType, String data) { 62 public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, TbMsgDataType dataType, String data) {
62 - return new TbMsg(UUID.randomUUID(), type, originator, metaData.copy(), dataType, data, null, null, TbMsgCallback.EMPTY); 63 + return new TbMsg(UUID.randomUUID(), System.currentTimeMillis(), type, originator, metaData.copy(), dataType, data, null, null, TbMsgCallback.EMPTY);
63 } 64 }
64 65
65 public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, TbMsgDataType dataType, String data, RuleChainId ruleChainId, RuleNodeId ruleNodeId) { 66 public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, TbMsgDataType dataType, String data, RuleChainId ruleChainId, RuleNodeId ruleNodeId) {
66 - return new TbMsg(UUID.randomUUID(), type, originator, metaData.copy(), dataType, data, ruleChainId, ruleNodeId, TbMsgCallback.EMPTY); 67 + return new TbMsg(UUID.randomUUID(), System.currentTimeMillis(), type, originator, metaData.copy(), dataType, data, ruleChainId, ruleNodeId, TbMsgCallback.EMPTY);
67 } 68 }
68 69
69 public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, String data, TbMsgCallback callback) { 70 public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, String data, TbMsgCallback callback) {
70 - return new TbMsg(UUID.randomUUID(), type, originator, metaData.copy(), TbMsgDataType.JSON, data, null, null, callback); 71 + return new TbMsg(UUID.randomUUID(), System.currentTimeMillis(), type, originator, metaData.copy(), TbMsgDataType.JSON, data, null, null, callback);
71 } 72 }
72 73
73 public static TbMsg transformMsg(TbMsg origMsg, String type, EntityId originator, TbMsgMetaData metaData, String data) { 74 public static TbMsg transformMsg(TbMsg origMsg, String type, EntityId originator, TbMsgMetaData metaData, String data) {
74 - return new TbMsg(origMsg.getId(), type, originator, metaData.copy(), origMsg.getDataType(), 75 + return new TbMsg(origMsg.getId(), origMsg.getTs(), type, originator, metaData.copy(), origMsg.getDataType(),
75 data, origMsg.getRuleChainId(), origMsg.getRuleNodeId(), origMsg.getCallback()); 76 data, origMsg.getRuleChainId(), origMsg.getRuleNodeId(), origMsg.getCallback());
76 } 77 }
77 78
78 public static TbMsg newMsg(TbMsg tbMsg, RuleChainId ruleChainId, RuleNodeId ruleNodeId) { 79 public static TbMsg newMsg(TbMsg tbMsg, RuleChainId ruleChainId, RuleNodeId ruleNodeId) {
79 - return new TbMsg(UUID.randomUUID(), tbMsg.getType(), tbMsg.getOriginator(), tbMsg.getMetaData().copy(), 80 + return new TbMsg(UUID.randomUUID(), tbMsg.getTs(), tbMsg.getType(), tbMsg.getOriginator(), tbMsg.getMetaData().copy(),
80 tbMsg.getDataType(), tbMsg.getData(), ruleChainId, ruleNodeId, TbMsgCallback.EMPTY); 81 tbMsg.getDataType(), tbMsg.getData(), ruleChainId, ruleNodeId, TbMsgCallback.EMPTY);
81 } 82 }
82 83
83 - private TbMsg(UUID id, String type, EntityId originator, TbMsgMetaData metaData, TbMsgDataType dataType, String data, 84 + private TbMsg(UUID id, long ts, String type, EntityId originator, TbMsgMetaData metaData, TbMsgDataType dataType, String data,
84 RuleChainId ruleChainId, RuleNodeId ruleNodeId, TbMsgCallback callback) { 85 RuleChainId ruleChainId, RuleNodeId ruleNodeId, TbMsgCallback callback) {
85 this.id = id; 86 this.id = id;
  87 + if (ts > 0) {
  88 + this.ts = ts;
  89 + } else {
  90 + this.ts = System.currentTimeMillis();
  91 + }
86 this.type = type; 92 this.type = type;
87 this.originator = originator; 93 this.originator = originator;
88 this.metaData = metaData; 94 this.metaData = metaData;
@@ -105,6 +111,7 @@ public final class TbMsg implements Serializable { @@ -105,6 +111,7 @@ public final class TbMsg implements Serializable {
105 public static byte[] toByteArray(TbMsg msg) { 111 public static byte[] toByteArray(TbMsg msg) {
106 MsgProtos.TbMsgProto.Builder builder = MsgProtos.TbMsgProto.newBuilder(); 112 MsgProtos.TbMsgProto.Builder builder = MsgProtos.TbMsgProto.newBuilder();
107 builder.setId(msg.getId().toString()); 113 builder.setId(msg.getId().toString());
  114 + builder.setTs(msg.getTs());
108 builder.setType(msg.getType()); 115 builder.setType(msg.getType());
109 builder.setEntityType(msg.getOriginator().getEntityType().name()); 116 builder.setEntityType(msg.getOriginator().getEntityType().name());
110 builder.setEntityIdMSB(msg.getOriginator().getId().getMostSignificantBits()); 117 builder.setEntityIdMSB(msg.getOriginator().getId().getMostSignificantBits());
@@ -124,7 +131,6 @@ public final class TbMsg implements Serializable { @@ -124,7 +131,6 @@ public final class TbMsg implements Serializable {
124 builder.setMetaData(MsgProtos.TbMsgMetaDataProto.newBuilder().putAllData(msg.getMetaData().getData()).build()); 131 builder.setMetaData(MsgProtos.TbMsgMetaDataProto.newBuilder().putAllData(msg.getMetaData().getData()).build());
125 } 132 }
126 133
127 -  
128 builder.setDataType(msg.getDataType().ordinal()); 134 builder.setDataType(msg.getDataType().ordinal());
129 builder.setData(msg.getData()); 135 builder.setData(msg.getData());
130 return builder.build().toByteArray(); 136 return builder.build().toByteArray();
@@ -144,18 +150,18 @@ public final class TbMsg implements Serializable { @@ -144,18 +150,18 @@ public final class TbMsg implements Serializable {
144 ruleNodeId = new RuleNodeId(new UUID(proto.getRuleNodeIdMSB(), proto.getRuleNodeIdLSB())); 150 ruleNodeId = new RuleNodeId(new UUID(proto.getRuleNodeIdMSB(), proto.getRuleNodeIdLSB()));
145 } 151 }
146 TbMsgDataType dataType = TbMsgDataType.values()[proto.getDataType()]; 152 TbMsgDataType dataType = TbMsgDataType.values()[proto.getDataType()];
147 - return new TbMsg(UUID.fromString(proto.getId()), proto.getType(), entityId, metaData, dataType, proto.getData(), ruleChainId, ruleNodeId, callback); 153 + return new TbMsg(UUID.fromString(proto.getId()), proto.getTs(), proto.getType(), entityId, metaData, dataType, proto.getData(), ruleChainId, ruleNodeId, callback);
148 } catch (InvalidProtocolBufferException e) { 154 } catch (InvalidProtocolBufferException e) {
149 throw new IllegalStateException("Could not parse protobuf for TbMsg", e); 155 throw new IllegalStateException("Could not parse protobuf for TbMsg", e);
150 } 156 }
151 } 157 }
152 158
153 public TbMsg copyWithRuleChainId(RuleChainId ruleChainId) { 159 public TbMsg copyWithRuleChainId(RuleChainId ruleChainId) {
154 - return new TbMsg(this.id, this.type, this.originator, this.metaData, this.dataType, this.data, ruleChainId, null, callback); 160 + return new TbMsg(this.id, this.ts, this.type, this.originator, this.metaData, this.dataType, this.data, ruleChainId, null, callback);
155 } 161 }
156 162
157 public TbMsg copyWithRuleNodeId(RuleChainId ruleChainId, RuleNodeId ruleNodeId) { 163 public TbMsg copyWithRuleNodeId(RuleChainId ruleChainId, RuleNodeId ruleNodeId) {
158 - return new TbMsg(this.id, this.type, this.originator, this.metaData, this.dataType, this.data, ruleChainId, ruleNodeId, callback); 164 + return new TbMsg(this.id, this.ts, this.type, this.originator, this.metaData, this.dataType, this.data, ruleChainId, ruleNodeId, callback);
159 } 165 }
160 166
161 public TbMsgCallback getCallback() { 167 public TbMsgCallback getCallback() {
@@ -44,4 +44,5 @@ message TbMsgProto { @@ -44,4 +44,5 @@ message TbMsgProto {
44 int32 dataType = 13; 44 int32 dataType = 13;
45 string data = 14; 45 string data = 14;
46 46
  47 + int64 ts = 15;
47 } 48 }
@@ -53,10 +53,6 @@ @@ -53,10 +53,6 @@
53 <artifactId>util</artifactId> 53 <artifactId>util</artifactId>
54 </dependency> 54 </dependency>
55 <dependency> 55 <dependency>
56 - <groupId>org.thingsboard.common</groupId>  
57 - <artifactId>queue</artifactId>  
58 - </dependency>  
59 - <dependency>  
60 <groupId>com.google.code.gson</groupId> 56 <groupId>com.google.code.gson</groupId>
61 <artifactId>gson</artifactId> 57 <artifactId>gson</artifactId>
62 </dependency> 58 </dependency>
@@ -112,7 +112,7 @@ public class EventEntity extends BaseSqlEntity<Event> implements BaseEntity<Eve @@ -112,7 +112,7 @@ public class EventEntity extends BaseSqlEntity<Event> implements BaseEntity<Eve
112 return event; 112 return event;
113 } 113 }
114 114
115 - private long getTs(UUID uuid) { 115 + private static long getTs(UUID uuid) {
116 return (uuid.timestamp() - EPOCH_DIFF) / 10000; 116 return (uuid.timestamp() - EPOCH_DIFF) / 10000;
117 } 117 }
118 } 118 }
@@ -46,7 +46,8 @@ public class ContainerTestSuite { @@ -46,7 +46,8 @@ public class ContainerTestSuite {
46 testContainer = new DockerComposeContainer( 46 testContainer = new DockerComposeContainer(
47 new File("./../../docker/docker-compose.yml"), 47 new File("./../../docker/docker-compose.yml"),
48 new File("./../../docker/docker-compose.postgres.yml"), 48 new File("./../../docker/docker-compose.postgres.yml"),
49 - new File("./../../docker/docker-compose.postgres.volumes.yml")) 49 + new File("./../../docker/docker-compose.postgres.volumes.yml"),
  50 + new File("./../../docker/docker-compose.kafka.yml"))
50 .withPull(false) 51 .withPull(false)
51 .withLocalCompose(true) 52 .withLocalCompose(true)
52 .withTailChildContainers(!skipTailChildContainers) 53 .withTailChildContainers(!skipTailChildContainers)
1 -/**  
2 - * Copyright © 2016-2020 The Thingsboard Authors  
3 - *  
4 - * Licensed under the Apache License, Version 2.0 (the "License");  
5 - * you may not use this file except in compliance with the License.  
6 - * You may obtain a copy of the License at  
7 - *  
8 - * http://www.apache.org/licenses/LICENSE-2.0  
9 - *  
10 - * Unless required by applicable law or agreed to in writing, software  
11 - * distributed under the License is distributed on an "AS IS" BASIS,  
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
13 - * See the License for the specific language governing permissions and  
14 - * limitations under the License.  
15 - */  
16 -import org.apache.tools.ant.filters.ReplaceTokens  
17 -  
18 -buildscript {  
19 - ext {  
20 - osPackageVersion = "3.8.0"  
21 - }  
22 - repositories {  
23 - jcenter()  
24 - }  
25 - dependencies {  
26 - classpath("com.netflix.nebula:gradle-ospackage-plugin:${osPackageVersion}")  
27 - }  
28 -}  
29 -  
30 -apply plugin: "nebula.ospackage"  
31 -  
32 -buildDir = projectBuildDir  
33 -version = projectVersion  
34 -distsDirName = "./"  
35 -  
36 -// OS Package plugin configuration  
37 -ospackage {  
38 - packageName = pkgName  
39 - version = "${project.version}"  
40 - release = 1  
41 - os = LINUX  
42 - type = BINARY  
43 -  
44 - into pkgInstallFolder  
45 -  
46 - user pkgUser  
47 - permissionGroup pkgUser  
48 -  
49 - // Copy the executable file  
50 - from("target/package/linux/bin/${pkgName}") {  
51 - fileMode 0500  
52 - into "bin"  
53 - }  
54 -  
55 - // Copy the init file  
56 - from("target/package/linux/init/${pkgName}") {  
57 - fileMode 0500  
58 - into "init"  
59 - }  
60 -  
61 - // Copy the config files  
62 - from("target/package/linux/conf") {  
63 - fileType CONFIG | NOREPLACE  
64 - fileMode 0754  
65 - into "conf"  
66 - }  
67 -  
68 -}  
69 -  
70 -// Configure our RPM build task  
71 -buildRpm {  
72 -  
73 - arch = X86_64  
74 -  
75 - version = projectVersion.replace('-', '')  
76 - archiveName = "${pkgName}.rpm"  
77 -  
78 - preInstall file("${buildDir}/control/rpm/preinst")  
79 - postInstall file("${buildDir}/control/rpm/postinst")  
80 - preUninstall file("${buildDir}/control/rpm/prerm")  
81 - postUninstall file("${buildDir}/control/rpm/postrm")  
82 -  
83 - user pkgUser  
84 - permissionGroup pkgUser  
85 -  
86 - // Copy the system unit files  
87 - from("${buildDir}/control/${pkgName}.service") {  
88 - addParentDirs = false  
89 - fileMode 0644  
90 - into "/usr/lib/systemd/system"  
91 - }  
92 -  
93 - directory(pkgLogFolder, 0755)  
94 - link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")  
95 -}  
96 -  
97 -// Same as the buildRpm task  
98 -buildDeb {  
99 -  
100 - arch = "amd64"  
101 -  
102 - archiveName = "${pkgName}.deb"  
103 -  
104 - configurationFile("${pkgInstallFolder}/conf/${pkgName}.conf")  
105 - configurationFile("${pkgInstallFolder}/conf/custom-environment-variables.yml")  
106 - configurationFile("${pkgInstallFolder}/conf/default.yml")  
107 - configurationFile("${pkgInstallFolder}/conf/logger.js")  
108 -  
109 - preInstall file("${buildDir}/control/deb/preinst")  
110 - postInstall file("${buildDir}/control/deb/postinst")  
111 - preUninstall file("${buildDir}/control/deb/prerm")  
112 - postUninstall file("${buildDir}/control/deb/postrm")  
113 -  
114 - user pkgUser  
115 - permissionGroup pkgUser  
116 -  
117 - directory(pkgLogFolder, 0755)  
118 - link("/etc/init.d/${pkgName}", "${pkgInstallFolder}/init/${pkgName}")  
119 - link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")  
120 -}  
@@ -23,7 +23,7 @@ RUN chmod a+x /tmp/*.sh \ @@ -23,7 +23,7 @@ RUN chmod a+x /tmp/*.sh \
23 23
24 RUN yes | dpkg -i /tmp/${pkg.name}.deb 24 RUN yes | dpkg -i /tmp/${pkg.name}.deb
25 25
26 -RUN update-rc.d ${pkg.name} disable 26 +RUN systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :
27 27
28 RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name} 28 RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name}
29 29
@@ -1461,7 +1461,7 @@ @@ -1461,7 +1461,7 @@
1461 }, 1461 },
1462 "enabled": { 1462 "enabled": {
1463 "version": "1.0.2", 1463 "version": "1.0.2",
1464 - "resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz", 1464 + "resolved": "http://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz",
1465 "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=", 1465 "integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=",
1466 "requires": { 1466 "requires": {
1467 "env-variable": "0.0.x" 1467 "env-variable": "0.0.x"
@@ -1740,7 +1740,7 @@ @@ -1740,7 +1740,7 @@
1740 }, 1740 },
1741 "fecha": { 1741 "fecha": {
1742 "version": "2.3.3", 1742 "version": "2.3.3",
1743 - "resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz", 1743 + "resolved": "http://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz",
1744 "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg==" 1744 "integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg=="
1745 }, 1745 },
1746 "file-stream-rotator": { 1746 "file-stream-rotator": {
@@ -1872,14 +1872,12 @@ @@ -1872,14 +1872,12 @@
1872 "balanced-match": { 1872 "balanced-match": {
1873 "version": "1.0.0", 1873 "version": "1.0.0",
1874 "bundled": true, 1874 "bundled": true,
1875 - "dev": true,  
1876 - "optional": true 1875 + "dev": true
1877 }, 1876 },
1878 "brace-expansion": { 1877 "brace-expansion": {
1879 "version": "1.1.11", 1878 "version": "1.1.11",
1880 "bundled": true, 1879 "bundled": true,
1881 "dev": true, 1880 "dev": true,
1882 - "optional": true,  
1883 "requires": { 1881 "requires": {
1884 "balanced-match": "^1.0.0", 1882 "balanced-match": "^1.0.0",
1885 "concat-map": "0.0.1" 1883 "concat-map": "0.0.1"
@@ -1894,20 +1892,17 @@ @@ -1894,20 +1892,17 @@
1894 "code-point-at": { 1892 "code-point-at": {
1895 "version": "1.1.0", 1893 "version": "1.1.0",
1896 "bundled": true, 1894 "bundled": true,
1897 - "dev": true,  
1898 - "optional": true 1895 + "dev": true
1899 }, 1896 },
1900 "concat-map": { 1897 "concat-map": {
1901 "version": "0.0.1", 1898 "version": "0.0.1",
1902 "bundled": true, 1899 "bundled": true,
1903 - "dev": true,  
1904 - "optional": true 1900 + "dev": true
1905 }, 1901 },
1906 "console-control-strings": { 1902 "console-control-strings": {
1907 "version": "1.1.0", 1903 "version": "1.1.0",
1908 "bundled": true, 1904 "bundled": true,
1909 - "dev": true,  
1910 - "optional": true 1905 + "dev": true
1911 }, 1906 },
1912 "core-util-is": { 1907 "core-util-is": {
1913 "version": "1.0.2", 1908 "version": "1.0.2",
@@ -2024,8 +2019,7 @@ @@ -2024,8 +2019,7 @@
2024 "inherits": { 2019 "inherits": {
2025 "version": "2.0.3", 2020 "version": "2.0.3",
2026 "bundled": true, 2021 "bundled": true,
2027 - "dev": true,  
2028 - "optional": true 2022 + "dev": true
2029 }, 2023 },
2030 "ini": { 2024 "ini": {
2031 "version": "1.3.5", 2025 "version": "1.3.5",
@@ -2037,7 +2031,6 @@ @@ -2037,7 +2031,6 @@
2037 "version": "1.0.0", 2031 "version": "1.0.0",
2038 "bundled": true, 2032 "bundled": true,
2039 "dev": true, 2033 "dev": true,
2040 - "optional": true,  
2041 "requires": { 2034 "requires": {
2042 "number-is-nan": "^1.0.0" 2035 "number-is-nan": "^1.0.0"
2043 } 2036 }
@@ -2052,7 +2045,6 @@ @@ -2052,7 +2045,6 @@
2052 "version": "3.0.4", 2045 "version": "3.0.4",
2053 "bundled": true, 2046 "bundled": true,
2054 "dev": true, 2047 "dev": true,
2055 - "optional": true,  
2056 "requires": { 2048 "requires": {
2057 "brace-expansion": "^1.1.7" 2049 "brace-expansion": "^1.1.7"
2058 } 2050 }
@@ -2164,8 +2156,7 @@ @@ -2164,8 +2156,7 @@
2164 "number-is-nan": { 2156 "number-is-nan": {
2165 "version": "1.0.1", 2157 "version": "1.0.1",
2166 "bundled": true, 2158 "bundled": true,
2167 - "dev": true,  
2168 - "optional": true 2159 + "dev": true
2169 }, 2160 },
2170 "object-assign": { 2161 "object-assign": {
2171 "version": "4.1.1", 2162 "version": "4.1.1",
@@ -2298,7 +2289,6 @@ @@ -2298,7 +2289,6 @@
2298 "version": "1.0.2", 2289 "version": "1.0.2",
2299 "bundled": true, 2290 "bundled": true,
2300 "dev": true, 2291 "dev": true,
2301 - "optional": true,  
2302 "requires": { 2292 "requires": {
2303 "code-point-at": "^1.0.0", 2293 "code-point-at": "^1.0.0",
2304 "is-fullwidth-code-point": "^1.0.0", 2294 "is-fullwidth-code-point": "^1.0.0",
@@ -2400,7 +2390,7 @@ @@ -2400,7 +2390,7 @@
2400 }, 2390 },
2401 "get-stream": { 2391 "get-stream": {
2402 "version": "3.0.0", 2392 "version": "3.0.0",
2403 - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", 2393 + "resolved": "http://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz",
2404 "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", 2394 "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=",
2405 "dev": true 2395 "dev": true
2406 }, 2396 },
@@ -2557,7 +2547,7 @@ @@ -2557,7 +2547,7 @@
2557 }, 2547 },
2558 "got": { 2548 "got": {
2559 "version": "6.7.1", 2549 "version": "6.7.1",
2560 - "resolved": "https://registry.npmjs.org/got/-/got-6.7.1.tgz", 2550 + "resolved": "http://registry.npmjs.org/got/-/got-6.7.1.tgz",
2561 "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=", 2551 "integrity": "sha1-JAzQV4WpoY5WHcG0S0HHY+8ejbA=",
2562 "dev": true, 2552 "dev": true,
2563 "requires": { 2553 "requires": {
@@ -2889,7 +2879,7 @@ @@ -2889,7 +2879,7 @@
2889 }, 2879 },
2890 "is-obj": { 2880 "is-obj": {
2891 "version": "1.0.1", 2881 "version": "1.0.1",
2892 - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", 2882 + "resolved": "http://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz",
2893 "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", 2883 "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=",
2894 "dev": true 2884 "dev": true
2895 }, 2885 },
@@ -3251,7 +3241,7 @@ @@ -3251,7 +3241,7 @@
3251 }, 3241 },
3252 "minimist": { 3242 "minimist": {
3253 "version": "1.2.0", 3243 "version": "1.2.0",
3254 - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", 3244 + "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
3255 "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" 3245 "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
3256 }, 3246 },
3257 "mixin-deep": { 3247 "mixin-deep": {
@@ -3277,7 +3267,7 @@ @@ -3277,7 +3267,7 @@
3277 }, 3267 },
3278 "mkdirp": { 3268 "mkdirp": {
3279 "version": "0.5.1", 3269 "version": "0.5.1",
3280 - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 3270 + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
3281 "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 3271 "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
3282 "dev": true, 3272 "dev": true,
3283 "requires": { 3273 "requires": {
@@ -3286,7 +3276,7 @@ @@ -3286,7 +3276,7 @@
3286 "dependencies": { 3276 "dependencies": {
3287 "minimist": { 3277 "minimist": {
3288 "version": "0.0.8", 3278 "version": "0.0.8",
3289 - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 3279 + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
3290 "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 3280 "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
3291 "dev": true 3281 "dev": true
3292 } 3282 }
@@ -3550,7 +3540,7 @@ @@ -3550,7 +3540,7 @@
3550 }, 3540 },
3551 "path-is-absolute": { 3541 "path-is-absolute": {
3552 "version": "1.0.1", 3542 "version": "1.0.1",
3553 - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 3543 + "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
3554 "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 3544 "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
3555 "dev": true 3545 "dev": true
3556 }, 3546 },
@@ -3989,7 +3979,7 @@ @@ -3989,7 +3979,7 @@
3989 }, 3979 },
3990 "safe-regex": { 3980 "safe-regex": {
3991 "version": "1.1.0", 3981 "version": "1.1.0",
3992 - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", 3982 + "resolved": "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz",
3993 "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", 3983 "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=",
3994 "dev": true, 3984 "dev": true,
3995 "requires": { 3985 "requires": {
@@ -4299,7 +4289,7 @@ @@ -4299,7 +4289,7 @@
4299 }, 4289 },
4300 "strip-eof": { 4290 "strip-eof": {
4301 "version": "1.0.0", 4291 "version": "1.0.0",
4302 - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", 4292 + "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
4303 "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", 4293 "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=",
4304 "dev": true 4294 "dev": true
4305 }, 4295 },
@@ -34,10 +34,12 @@ @@ -34,10 +34,12 @@
34 <properties> 34 <properties>
35 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 35 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36 <main.dir>${basedir}/../..</main.dir> 36 <main.dir>${basedir}/../..</main.dir>
37 - <pkg.name>tb-js-executor</pkg.name>  
38 <docker.name>tb-js-executor</docker.name> 37 <docker.name>tb-js-executor</docker.name>
39 - <pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder>  
40 - <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder> 38 + <pkg.name>tb-js-executor</pkg.name>
  39 + <pkg.type>js</pkg.type>
  40 + <pkg.disabled>false</pkg.disabled>
  41 + <pkg.process-resources.phase>process-resources</pkg.process-resources.phase>
  42 + <pkg.package.phase>package</pkg.package.phase>
41 <pkg.linux.dist>${project.build.directory}/package/linux</pkg.linux.dist> 43 <pkg.linux.dist>${project.build.directory}/package/linux</pkg.linux.dist>
42 <pkg.win.dist>${project.build.directory}/package/windows</pkg.win.dist> 44 <pkg.win.dist>${project.build.directory}/package/windows</pkg.win.dist>
43 </properties> 45 </properties>
@@ -87,194 +89,18 @@ @@ -87,194 +89,18 @@
87 <plugin> 89 <plugin>
88 <groupId>org.apache.maven.plugins</groupId> 90 <groupId>org.apache.maven.plugins</groupId>
89 <artifactId>maven-dependency-plugin</artifactId> 91 <artifactId>maven-dependency-plugin</artifactId>
90 - <executions>  
91 - <execution>  
92 - <id>copy-winsw-service</id>  
93 - <phase>package</phase>  
94 - <goals>  
95 - <goal>copy</goal>  
96 - </goals>  
97 - <configuration>  
98 - <artifactItems>  
99 - <artifactItem>  
100 - <groupId>com.sun.winsw</groupId>  
101 - <artifactId>winsw</artifactId>  
102 - <classifier>bin</classifier>  
103 - <type>exe</type>  
104 - <destFileName>service.exe</destFileName>  
105 - </artifactItem>  
106 - </artifactItems>  
107 - <outputDirectory>${pkg.win.dist}</outputDirectory>  
108 - </configuration>  
109 - </execution>  
110 - </executions>  
111 </plugin> 92 </plugin>
112 <plugin> 93 <plugin>
113 <groupId>org.apache.maven.plugins</groupId> 94 <groupId>org.apache.maven.plugins</groupId>
114 <artifactId>maven-resources-plugin</artifactId> 95 <artifactId>maven-resources-plugin</artifactId>
115 - <executions>  
116 - <execution>  
117 - <id>copy-linux-conf</id>  
118 - <phase>process-resources</phase>  
119 - <goals>  
120 - <goal>copy-resources</goal>  
121 - </goals>  
122 - <configuration>  
123 - <outputDirectory>${pkg.linux.dist}/conf</outputDirectory>  
124 - <resources>  
125 - <resource>  
126 - <directory>config</directory>  
127 - <filtering>true</filtering>  
128 - </resource>  
129 - </resources>  
130 - <filters>  
131 - <filter>src/main/filters/unix.properties</filter>  
132 - </filters>  
133 - </configuration>  
134 - </execution>  
135 - <execution>  
136 - <id>copy-linux-init</id>  
137 - <phase>process-resources</phase>  
138 - <goals>  
139 - <goal>copy-resources</goal>  
140 - </goals>  
141 - <configuration>  
142 - <outputDirectory>${pkg.linux.dist}/init</outputDirectory>  
143 - <resources>  
144 - <resource>  
145 - <directory>src/main/scripts/init</directory>  
146 - <filtering>true</filtering>  
147 - </resource>  
148 - </resources>  
149 - <filters>  
150 - <filter>src/main/filters/unix.properties</filter>  
151 - </filters>  
152 - </configuration>  
153 - </execution>  
154 - <execution>  
155 - <id>copy-win-conf</id>  
156 - <phase>process-resources</phase>  
157 - <goals>  
158 - <goal>copy-resources</goal>  
159 - </goals>  
160 - <configuration>  
161 - <outputDirectory>${pkg.win.dist}/conf</outputDirectory>  
162 - <resources>  
163 - <resource>  
164 - <directory>config</directory>  
165 - <excludes>  
166 - <exclude>tb-js-executor.conf</exclude>  
167 - </excludes>  
168 - <filtering>true</filtering>  
169 - </resource>  
170 - </resources>  
171 - <filters>  
172 - <filter>src/main/filters/windows.properties</filter>  
173 - </filters>  
174 - </configuration>  
175 - </execution>  
176 - <execution>  
177 - <id>copy-control</id>  
178 - <phase>process-resources</phase>  
179 - <goals>  
180 - <goal>copy-resources</goal>  
181 - </goals>  
182 - <configuration>  
183 - <outputDirectory>${project.build.directory}/control</outputDirectory>  
184 - <resources>  
185 - <resource>  
186 - <directory>src/main/scripts/control</directory>  
187 - <filtering>true</filtering>  
188 - </resource>  
189 - </resources>  
190 - <filters>  
191 - <filter>src/main/filters/unix.properties</filter>  
192 - </filters>  
193 - </configuration>  
194 - </execution>  
195 - <execution>  
196 - <id>copy-windows-control</id>  
197 - <phase>process-resources</phase>  
198 - <goals>  
199 - <goal>copy-resources</goal>  
200 - </goals>  
201 - <configuration>  
202 - <outputDirectory>${pkg.win.dist}</outputDirectory>  
203 - <resources>  
204 - <resource>  
205 - <directory>src/main/scripts/windows</directory>  
206 - <filtering>true</filtering>  
207 - </resource>  
208 - </resources>  
209 - <filters>  
210 - <filter>src/main/filters/windows.properties</filter>  
211 - </filters>  
212 - </configuration>  
213 - </execution>  
214 - <execution>  
215 - <id>copy-docker-config</id>  
216 - <phase>process-resources</phase>  
217 - <goals>  
218 - <goal>copy-resources</goal>  
219 - </goals>  
220 - <configuration>  
221 - <outputDirectory>${project.build.directory}</outputDirectory>  
222 - <resources>  
223 - <resource>  
224 - <directory>docker</directory>  
225 - <filtering>true</filtering>  
226 - </resource>  
227 - </resources>  
228 - </configuration>  
229 - </execution>  
230 - </executions>  
231 </plugin> 96 </plugin>
232 <plugin> 97 <plugin>
233 <groupId>org.thingsboard</groupId> 98 <groupId>org.thingsboard</groupId>
234 <artifactId>gradle-maven-plugin</artifactId> 99 <artifactId>gradle-maven-plugin</artifactId>
235 - <configuration>  
236 - <tasks>  
237 - <task>build</task>  
238 - <task>buildDeb</task>  
239 - <task>buildRpm</task>  
240 - </tasks>  
241 - <args>  
242 - <arg>-PprojectBuildDir=${project.build.directory}</arg>  
243 - <arg>-PprojectVersion=${project.version}</arg>  
244 - <arg>-PpkgName=${pkg.name}</arg>  
245 - <arg>-PpkgUser=${pkg.user}</arg>  
246 - <arg>-PpkgInstallFolder=${pkg.installFolder}</arg>  
247 - <arg>-PpkgLogFolder=${pkg.unixLogFolder}</arg>  
248 - </args>  
249 - </configuration>  
250 - <executions>  
251 - <execution>  
252 - <phase>package</phase>  
253 - <goals>  
254 - <goal>invoke</goal>  
255 - </goals>  
256 - </execution>  
257 - </executions>  
258 </plugin> 100 </plugin>
259 <plugin> 101 <plugin>
260 <groupId>org.apache.maven.plugins</groupId> 102 <groupId>org.apache.maven.plugins</groupId>
261 <artifactId>maven-assembly-plugin</artifactId> 103 <artifactId>maven-assembly-plugin</artifactId>
262 - <version>3.0.0</version>  
263 - <configuration>  
264 - <finalName>${pkg.name}</finalName>  
265 - <descriptors>  
266 - <descriptor>src/main/assembly/windows.xml</descriptor>  
267 - </descriptors>  
268 - </configuration>  
269 - <executions>  
270 - <execution>  
271 - <id>assembly</id>  
272 - <phase>package</phase>  
273 - <goals>  
274 - <goal>single</goal>  
275 - </goals>  
276 - </execution>  
277 - </executions>  
278 </plugin> 104 </plugin>
279 <plugin> 105 <plugin>
280 <groupId>com.spotify</groupId> 106 <groupId>com.spotify</groupId>
1 -<!--  
2 -  
3 - Copyright © 2016-2020 The Thingsboard Authors  
4 -  
5 - Licensed under the Apache License, Version 2.0 (the "License");  
6 - you may not use this file except in compliance with the License.  
7 - You may obtain a copy of the License at  
8 -  
9 - http://www.apache.org/licenses/LICENSE-2.0  
10 -  
11 - Unless required by applicable law or agreed to in writing, software  
12 - distributed under the License is distributed on an "AS IS" BASIS,  
13 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
14 - See the License for the specific language governing permissions and  
15 - limitations under the License.  
16 -  
17 --->  
18 -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"  
19 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
20 - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">  
21 - <id>windows</id>  
22 -  
23 - <formats>  
24 - <format>zip</format>  
25 - </formats>  
26 -  
27 - <!-- Workaround to create logs directory -->  
28 - <fileSets>  
29 - <fileSet>  
30 - <directory>${pkg.win.dist}</directory>  
31 - <outputDirectory>logs</outputDirectory>  
32 - <excludes>  
33 - <exclude>*/**</exclude>  
34 - </excludes>  
35 - </fileSet>  
36 - <fileSet>  
37 - <directory>${pkg.win.dist}/conf</directory>  
38 - <outputDirectory>conf</outputDirectory>  
39 - <lineEnding>windows</lineEnding>  
40 - </fileSet>  
41 - </fileSets>  
42 -  
43 - <files>  
44 - <file>  
45 - <source>${pkg.win.dist}/bin/${pkg.name}.exe</source>  
46 - <outputDirectory>bin</outputDirectory>  
47 - <destName>${pkg.name}.exe</destName>  
48 - </file>  
49 - <file>  
50 - <source>${pkg.win.dist}/service.exe</source>  
51 - <outputDirectory/>  
52 - <destName>${pkg.name}.exe</destName>  
53 - </file>  
54 - <file>  
55 - <source>${pkg.win.dist}/service.xml</source>  
56 - <outputDirectory/>  
57 - <destName>${pkg.name}.xml</destName>  
58 - <lineEnding>windows</lineEnding>  
59 - </file>  
60 - <file>  
61 - <source>${pkg.win.dist}/install.bat</source>  
62 - <outputDirectory/>  
63 - <lineEnding>windows</lineEnding>  
64 - </file>  
65 - <file>  
66 - <source>${pkg.win.dist}/uninstall.bat</source>  
67 - <outputDirectory/>  
68 - <lineEnding>windows</lineEnding>  
69 - </file>  
70 - </files>  
71 -</assembly>  
1 -#!/bin/sh  
2 -  
3 -update-rc.d -f ${pkg.name} remove  
1 -<!--  
2 -  
3 - Copyright © 2016-2018 The Thingsboard Authors  
4 -  
5 - Licensed under the Apache License, Version 2.0 (the "License");  
6 - you may not use this file except in compliance with the License.  
7 - You may obtain a copy of the License at  
8 -  
9 - http://www.apache.org/licenses/LICENSE-2.0  
10 -  
11 - Unless required by applicable law or agreed to in writing, software  
12 - distributed under the License is distributed on an "AS IS" BASIS,  
13 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
14 - See the License for the specific language governing permissions and  
15 - limitations under the License.  
16 -  
17 --->  
18 -<service>  
19 - <id>${pkg.name}</id>  
20 - <name>${project.name}</name>  
21 - <description>${project.description}</description>  
22 - <workingdirectory>%BASE%\bin</workingdirectory>  
23 - <logpath>${pkg.winWrapperLogFolder}</logpath>  
24 - <logmode>rotate</logmode>  
25 - <env name="NODE_CONFIG_DIR" value="%BASE%\conf" />  
26 - <env name="LOG_FOLDER" value="${pkg.winWrapperLogFolder}" />  
27 - <env name="NODE_ENV" value="production" />  
28 - <executable>%BASE%\bin\${pkg.name}.exe</executable>  
29 -</service>  
@@ -23,7 +23,7 @@ RUN chmod a+x /tmp/*.sh \ @@ -23,7 +23,7 @@ RUN chmod a+x /tmp/*.sh \
23 23
24 RUN yes | dpkg -i /tmp/${pkg.name}.deb 24 RUN yes | dpkg -i /tmp/${pkg.name}.deb
25 25
26 -RUN update-rc.d ${pkg.name} disable 26 +RUN systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :
27 27
28 RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name}.jar 28 RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name}.jar
29 29
@@ -23,7 +23,7 @@ RUN chmod a+x /tmp/*.sh \ @@ -23,7 +23,7 @@ RUN chmod a+x /tmp/*.sh \
23 23
24 RUN yes | dpkg -i /tmp/${pkg.name}.deb 24 RUN yes | dpkg -i /tmp/${pkg.name}.deb
25 25
26 -RUN update-rc.d ${pkg.name} disable 26 +RUN systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :
27 27
28 RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name}.jar 28 RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name}.jar
29 29
@@ -23,7 +23,7 @@ RUN chmod a+x /tmp/*.sh \ @@ -23,7 +23,7 @@ RUN chmod a+x /tmp/*.sh \
23 23
24 RUN yes | dpkg -i /tmp/${pkg.name}.deb 24 RUN yes | dpkg -i /tmp/${pkg.name}.deb
25 25
26 -RUN update-rc.d ${pkg.name} disable 26 +RUN systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :
27 27
28 RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name}.jar 28 RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name}.jar
29 29
@@ -23,7 +23,7 @@ RUN chmod a+x /tmp/*.sh \ @@ -23,7 +23,7 @@ RUN chmod a+x /tmp/*.sh \
23 23
24 RUN yes | dpkg -i /tmp/${pkg.name}.deb 24 RUN yes | dpkg -i /tmp/${pkg.name}.deb
25 25
26 -RUN update-rc.d ${pkg.name} disable 26 +RUN systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :
27 27
28 RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name} 28 RUN chmod 555 ${pkg.installFolder}/bin/${pkg.name}
29 29
@@ -35,9 +35,13 @@ @@ -35,9 +35,13 @@
35 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 35 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36 <main.dir>${basedir}/../..</main.dir> 36 <main.dir>${basedir}/../..</main.dir>
37 <pkg.name>tb-web-ui</pkg.name> 37 <pkg.name>tb-web-ui</pkg.name>
  38 + <pkg.type>js</pkg.type>
38 <docker.name>tb-web-ui</docker.name> 39 <docker.name>tb-web-ui</docker.name>
39 - <pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder>  
40 - <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder> 40 + <pkg.name>tb-web-ui</pkg.name>
  41 + <pkg.type>js</pkg.type>
  42 + <pkg.disabled>false</pkg.disabled>
  43 + <pkg.process-resources.phase>process-resources</pkg.process-resources.phase>
  44 + <pkg.package.phase>package</pkg.package.phase>
41 <pkg.linux.dist>${project.build.directory}/package/linux</pkg.linux.dist> 45 <pkg.linux.dist>${project.build.directory}/package/linux</pkg.linux.dist>
42 <pkg.win.dist>${project.build.directory}/package/windows</pkg.win.dist> 46 <pkg.win.dist>${project.build.directory}/package/windows</pkg.win.dist>
43 </properties> 47 </properties>
@@ -136,170 +140,185 @@ @@ -136,170 +140,185 @@
136 <plugin> 140 <plugin>
137 <groupId>org.apache.maven.plugins</groupId> 141 <groupId>org.apache.maven.plugins</groupId>
138 <artifactId>maven-resources-plugin</artifactId> 142 <artifactId>maven-resources-plugin</artifactId>
139 - <executions>  
140 - <execution>  
141 - <id>copy-linux-conf</id>  
142 - <phase>process-resources</phase>  
143 - <goals>  
144 - <goal>copy-resources</goal>  
145 - </goals>  
146 - <configuration>  
147 - <outputDirectory>${pkg.linux.dist}/conf</outputDirectory>  
148 - <resources>  
149 - <resource>  
150 - <directory>config</directory>  
151 - <filtering>true</filtering>  
152 - </resource>  
153 - </resources>  
154 - <filters>  
155 - <filter>src/main/filters/unix.properties</filter>  
156 - </filters>  
157 - </configuration>  
158 - </execution>  
159 - <execution>  
160 - <id>copy-linux-init</id>  
161 - <phase>process-resources</phase>  
162 - <goals>  
163 - <goal>copy-resources</goal>  
164 - </goals>  
165 - <configuration>  
166 - <outputDirectory>${pkg.linux.dist}/init</outputDirectory>  
167 - <resources>  
168 - <resource>  
169 - <directory>src/main/scripts/init</directory>  
170 - <filtering>true</filtering>  
171 - </resource>  
172 - </resources>  
173 - <filters>  
174 - <filter>src/main/filters/unix.properties</filter>  
175 - </filters>  
176 - </configuration>  
177 - </execution>  
178 - <execution>  
179 - <id>copy-win-conf</id>  
180 - <phase>process-resources</phase>  
181 - <goals>  
182 - <goal>copy-resources</goal>  
183 - </goals>  
184 - <configuration>  
185 - <outputDirectory>${pkg.win.dist}/conf</outputDirectory>  
186 - <resources>  
187 - <resource>  
188 - <directory>config</directory>  
189 - <excludes>  
190 - <exclude>tb-web-ui.conf</exclude>  
191 - </excludes>  
192 - <filtering>true</filtering>  
193 - </resource>  
194 - </resources>  
195 - <filters>  
196 - <filter>src/main/filters/windows.properties</filter>  
197 - </filters>  
198 - </configuration>  
199 - </execution>  
200 - <execution>  
201 - <id>copy-control</id>  
202 - <phase>process-resources</phase>  
203 - <goals>  
204 - <goal>copy-resources</goal>  
205 - </goals>  
206 - <configuration>  
207 - <outputDirectory>${project.build.directory}/control</outputDirectory>  
208 - <resources>  
209 - <resource>  
210 - <directory>src/main/scripts/control</directory>  
211 - <filtering>true</filtering>  
212 - </resource>  
213 - </resources>  
214 - <filters>  
215 - <filter>src/main/filters/unix.properties</filter>  
216 - </filters>  
217 - </configuration>  
218 - </execution>  
219 - <execution>  
220 - <id>copy-windows-control</id>  
221 - <phase>process-resources</phase>  
222 - <goals>  
223 - <goal>copy-resources</goal>  
224 - </goals>  
225 - <configuration>  
226 - <outputDirectory>${pkg.win.dist}</outputDirectory>  
227 - <resources>  
228 - <resource>  
229 - <directory>src/main/scripts/windows</directory>  
230 - <filtering>true</filtering>  
231 - </resource>  
232 - </resources>  
233 - <filters>  
234 - <filter>src/main/filters/windows.properties</filter>  
235 - </filters>  
236 - </configuration>  
237 - </execution>  
238 - <execution>  
239 - <id>copy-docker-config</id>  
240 - <phase>process-resources</phase>  
241 - <goals>  
242 - <goal>copy-resources</goal>  
243 - </goals>  
244 - <configuration>  
245 - <outputDirectory>${project.build.directory}</outputDirectory>  
246 - <resources>  
247 - <resource>  
248 - <directory>docker</directory>  
249 - <filtering>true</filtering>  
250 - </resource>  
251 - </resources>  
252 - </configuration>  
253 - </execution>  
254 - </executions>  
255 </plugin> 143 </plugin>
256 <plugin> 144 <plugin>
257 <groupId>org.thingsboard</groupId> 145 <groupId>org.thingsboard</groupId>
258 <artifactId>gradle-maven-plugin</artifactId> 146 <artifactId>gradle-maven-plugin</artifactId>
259 - <configuration>  
260 - <tasks>  
261 - <task>build</task>  
262 - <task>buildDeb</task>  
263 - <task>buildRpm</task>  
264 - </tasks>  
265 - <args>  
266 - <arg>-PprojectBuildDir=${project.build.directory}</arg>  
267 - <arg>-PprojectVersion=${project.version}</arg>  
268 - <arg>-PpkgName=${pkg.name}</arg>  
269 - <arg>-PpkgUser=${pkg.user}</arg>  
270 - <arg>-PpkgInstallFolder=${pkg.installFolder}</arg>  
271 - <arg>-PpkgLogFolder=${pkg.unixLogFolder}</arg>  
272 - </args>  
273 - </configuration>  
274 - <executions>  
275 - <execution>  
276 - <phase>package</phase>  
277 - <goals>  
278 - <goal>invoke</goal>  
279 - </goals>  
280 - </execution>  
281 - </executions>  
282 </plugin> 147 </plugin>
283 <plugin> 148 <plugin>
284 <groupId>org.apache.maven.plugins</groupId> 149 <groupId>org.apache.maven.plugins</groupId>
285 <artifactId>maven-assembly-plugin</artifactId> 150 <artifactId>maven-assembly-plugin</artifactId>
286 - <version>3.0.0</version>  
287 - <configuration>  
288 - <finalName>${pkg.name}</finalName>  
289 - <descriptors>  
290 - <descriptor>src/main/assembly/windows.xml</descriptor>  
291 - </descriptors>  
292 - </configuration>  
293 - <executions>  
294 - <execution>  
295 - <id>assembly</id>  
296 - <phase>package</phase>  
297 - <goals>  
298 - <goal>single</goal>  
299 - </goals>  
300 - </execution>  
301 - </executions>  
302 </plugin> 151 </plugin>
  152 +<!-- <plugin>-->
  153 +<!-- <groupId>org.apache.maven.plugins</groupId>-->
  154 +<!-- <artifactId>maven-resources-plugin</artifactId>-->
  155 +<!-- <executions>-->
  156 +<!-- <execution>-->
  157 +<!-- <id>copy-linux-conf</id>-->
  158 +<!-- <phase>process-resources</phase>-->
  159 +<!-- <goals>-->
  160 +<!-- <goal>copy-resources</goal>-->
  161 +<!-- </goals>-->
  162 +<!-- <configuration>-->
  163 +<!-- <outputDirectory>${pkg.linux.dist}/conf</outputDirectory>-->
  164 +<!-- <resources>-->
  165 +<!-- <resource>-->
  166 +<!-- <directory>config</directory>-->
  167 +<!-- <filtering>true</filtering>-->
  168 +<!-- </resource>-->
  169 +<!-- </resources>-->
  170 +<!-- <filters>-->
  171 +<!-- <filter>src/main/filters/unix.properties</filter>-->
  172 +<!-- </filters>-->
  173 +<!-- </configuration>-->
  174 +<!-- </execution>-->
  175 +<!-- <execution>-->
  176 +<!-- <id>copy-linux-init</id>-->
  177 +<!-- <phase>process-resources</phase>-->
  178 +<!-- <goals>-->
  179 +<!-- <goal>copy-resources</goal>-->
  180 +<!-- </goals>-->
  181 +<!-- <configuration>-->
  182 +<!-- <outputDirectory>${pkg.linux.dist}/init</outputDirectory>-->
  183 +<!-- <resources>-->
  184 +<!-- <resource>-->
  185 +<!-- <directory>src/main/scripts/init</directory>-->
  186 +<!-- <filtering>true</filtering>-->
  187 +<!-- </resource>-->
  188 +<!-- </resources>-->
  189 +<!-- <filters>-->
  190 +<!-- <filter>src/main/filters/unix.properties</filter>-->
  191 +<!-- </filters>-->
  192 +<!-- </configuration>-->
  193 +<!-- </execution>-->
  194 +<!-- <execution>-->
  195 +<!-- <id>copy-win-conf</id>-->
  196 +<!-- <phase>process-resources</phase>-->
  197 +<!-- <goals>-->
  198 +<!-- <goal>copy-resources</goal>-->
  199 +<!-- </goals>-->
  200 +<!-- <configuration>-->
  201 +<!-- <outputDirectory>${pkg.win.dist}/conf</outputDirectory>-->
  202 +<!-- <resources>-->
  203 +<!-- <resource>-->
  204 +<!-- <directory>config</directory>-->
  205 +<!-- <excludes>-->
  206 +<!-- <exclude>tb-web-ui.conf</exclude>-->
  207 +<!-- </excludes>-->
  208 +<!-- <filtering>true</filtering>-->
  209 +<!-- </resource>-->
  210 +<!-- </resources>-->
  211 +<!-- <filters>-->
  212 +<!-- <filter>src/main/filters/windows.properties</filter>-->
  213 +<!-- </filters>-->
  214 +<!-- </configuration>-->
  215 +<!-- </execution>-->
  216 +<!-- <execution>-->
  217 +<!-- <id>copy-control</id>-->
  218 +<!-- <phase>process-resources</phase>-->
  219 +<!-- <goals>-->
  220 +<!-- <goal>copy-resources</goal>-->
  221 +<!-- </goals>-->
  222 +<!-- <configuration>-->
  223 +<!-- <outputDirectory>${project.build.directory}/control</outputDirectory>-->
  224 +<!-- <resources>-->
  225 +<!-- <resource>-->
  226 +<!-- <directory>src/main/scripts/control</directory>-->
  227 +<!-- <filtering>true</filtering>-->
  228 +<!-- </resource>-->
  229 +<!-- </resources>-->
  230 +<!-- <filters>-->
  231 +<!-- <filter>src/main/filters/unix.properties</filter>-->
  232 +<!-- </filters>-->
  233 +<!-- </configuration>-->
  234 +<!-- </execution>-->
  235 +<!-- <execution>-->
  236 +<!-- <id>copy-windows-control</id>-->
  237 +<!-- <phase>process-resources</phase>-->
  238 +<!-- <goals>-->
  239 +<!-- <goal>copy-resources</goal>-->
  240 +<!-- </goals>-->
  241 +<!-- <configuration>-->
  242 +<!-- <outputDirectory>${pkg.win.dist}</outputDirectory>-->
  243 +<!-- <resources>-->
  244 +<!-- <resource>-->
  245 +<!-- <directory>src/main/scripts/windows</directory>-->
  246 +<!-- <filtering>true</filtering>-->
  247 +<!-- </resource>-->
  248 +<!-- </resources>-->
  249 +<!-- <filters>-->
  250 +<!-- <filter>src/main/filters/windows.properties</filter>-->
  251 +<!-- </filters>-->
  252 +<!-- </configuration>-->
  253 +<!-- </execution>-->
  254 +<!-- <execution>-->
  255 +<!-- <id>copy-docker-config</id>-->
  256 +<!-- <phase>process-resources</phase>-->
  257 +<!-- <goals>-->
  258 +<!-- <goal>copy-resources</goal>-->
  259 +<!-- </goals>-->
  260 +<!-- <configuration>-->
  261 +<!-- <outputDirectory>${project.build.directory}</outputDirectory>-->
  262 +<!-- <resources>-->
  263 +<!-- <resource>-->
  264 +<!-- <directory>docker</directory>-->
  265 +<!-- <filtering>true</filtering>-->
  266 +<!-- </resource>-->
  267 +<!-- </resources>-->
  268 +<!-- </configuration>-->
  269 +<!-- </execution>-->
  270 +<!-- </executions>-->
  271 +<!-- </plugin>-->
  272 +<!-- <plugin>-->
  273 +<!-- <groupId>org.thingsboard</groupId>-->
  274 +<!-- <artifactId>gradle-maven-plugin</artifactId>-->
  275 +<!-- <configuration>-->
  276 +<!-- <gradleProjectDirectory>${basedir}</gradleProjectDirectory>-->
  277 +<!-- <tasks>-->
  278 +<!-- <task>build</task>-->
  279 +<!-- <task>buildDeb</task>-->
  280 +<!-- <task>buildRpm</task>-->
  281 +<!-- <task>renameDeb</task>-->
  282 +<!-- <task>renameRpm</task>-->
  283 +<!-- </tasks>-->
  284 +<!-- <args>-->
  285 +<!-- <arg>-PprojectBuildDir=${project.build.directory}</arg>-->
  286 +<!-- <arg>-PprojectVersion=${project.version}</arg>-->
  287 +<!-- <arg>-PpkgName=${pkg.name}</arg>-->
  288 +<!-- <arg>-PpkgUser=${pkg.user}</arg>-->
  289 +<!-- <arg>-PpkgInstallFolder=${pkg.installFolder}</arg>-->
  290 +<!-- <arg>-PpkgLogFolder=${pkg.unixLogFolder}</arg>-->
  291 +<!-- </args>-->
  292 +<!-- </configuration>-->
  293 +<!-- <executions>-->
  294 +<!-- <execution>-->
  295 +<!-- <phase>package</phase>-->
  296 +<!-- <goals>-->
  297 +<!-- <goal>invoke</goal>-->
  298 +<!-- </goals>-->
  299 +<!-- </execution>-->
  300 +<!-- </executions>-->
  301 +<!-- </plugin>-->
  302 +<!-- <plugin>-->
  303 +<!-- <groupId>org.apache.maven.plugins</groupId>-->
  304 +<!-- <artifactId>maven-assembly-plugin</artifactId>-->
  305 +<!-- <version>3.0.0</version>-->
  306 +<!-- <configuration>-->
  307 +<!-- <finalName>${pkg.name}</finalName>-->
  308 +<!-- <descriptors>-->
  309 +<!-- <descriptor>../../packaging/js/assembly/windows.xml</descriptor>-->
  310 +<!-- </descriptors>-->
  311 +<!-- </configuration>-->
  312 +<!-- <executions>-->
  313 +<!-- <execution>-->
  314 +<!-- <id>assembly</id>-->
  315 +<!-- <phase>package</phase>-->
  316 +<!-- <goals>-->
  317 +<!-- <goal>single</goal>-->
  318 +<!-- </goals>-->
  319 +<!-- </execution>-->
  320 +<!-- </executions>-->
  321 +<!-- </plugin>-->
303 <plugin> 322 <plugin>
304 <groupId>com.spotify</groupId> 323 <groupId>com.spotify</groupId>
305 <artifactId>dockerfile-maven-plugin</artifactId> 324 <artifactId>dockerfile-maven-plugin</artifactId>
1 -pkg.logFolder=${pkg.unixLogFolder}  
1 -pkg.logFolder=${BASE}\\logs  
2 -pkg.winWrapperLogFolder=%BASE%\\logs  
1 -#!/bin/sh  
2 -  
3 -chown -R ${pkg.user}: ${pkg.logFolder}  
4 -chown -R ${pkg.user}: ${pkg.installFolder}  
5 -update-rc.d ${pkg.name} defaults  
6 -  
1 -#!/bin/sh  
2 -  
3 -update-rc.d -f ${pkg.name} remove  
1 -#!/bin/sh  
2 -  
3 -if ! getent group ${pkg.user} >/dev/null; then  
4 - addgroup --system ${pkg.user}  
5 -fi  
6 -  
7 -if ! getent passwd ${pkg.user} >/dev/null; then  
8 - adduser --quiet \  
9 - --system \  
10 - --ingroup ${pkg.user} \  
11 - --quiet \  
12 - --disabled-login \  
13 - --disabled-password \  
14 - --home ${pkg.installFolder} \  
15 - --no-create-home \  
16 - -gecos "Thingsboard application" \  
17 - ${pkg.user}  
18 -fi  
1 -#!/bin/sh  
2 -  
3 -if [ -e /var/run/${pkg.name}/${pkg.name}.pid ]; then  
4 - service ${pkg.name} stop  
5 -fi  
1 -#!/bin/sh  
2 -  
3 -chown -R ${pkg.user}: ${pkg.logFolder}  
4 -chown -R ${pkg.user}: ${pkg.installFolder}  
5 -  
6 -if [ $1 -eq 1 ] ; then  
7 - # Initial installation  
8 - systemctl --no-reload enable ${pkg.name}.service >/dev/null 2>&1 || :  
9 -fi  
1 -#!/bin/sh  
2 -  
3 -if [ $1 -ge 1 ] ; then  
4 - # Package upgrade, not uninstall  
5 - systemctl try-restart ${pkg.name}.service >/dev/null 2>&1 || :  
6 -fi  
1 -#!/bin/sh  
2 -  
3 -getent group ${pkg.user} >/dev/null || groupadd -r ${pkg.user}  
4 -getent passwd ${pkg.user} >/dev/null || \  
5 -useradd -d ${pkg.installFolder} -g ${pkg.user} -M -r ${pkg.user} -s /sbin/nologin \  
6 --c "Thingsboard application"  
1 -#!/bin/sh  
2 -  
3 -if [ $1 -eq 0 ] ; then  
4 - # Package removal, not upgrade  
5 - systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :  
6 -fi  
1 -[Unit]  
2 -Description=${pkg.name}  
3 -After=syslog.target  
4 -  
5 -[Service]  
6 -User=${pkg.user}  
7 -ExecStart=${pkg.installFolder}/init/${pkg.name}  
8 -SuccessExitStatus=143  
9 -  
10 -[Install]  
11 -WantedBy=multi-user.target  
1 -#!/bin/bash  
2 -#  
3 -  
4 -  
5 -### BEGIN INIT INFO  
6 -# Provides: tb-web-ui  
7 -# Required-Start: $remote_fs $syslog $network  
8 -# Required-Stop: $remote_fs $syslog $network  
9 -# Default-Start: 2 3 4 5  
10 -# Default-Stop: 0 1 6  
11 -# Short-Description: ${project.name}  
12 -# Description: ${project.description}  
13 -# chkconfig: 2345 99 01  
14 -### END INIT INFO  
15 -  
16 -[[ -n "$DEBUG" ]] && set -x  
17 -  
18 -# Initialize variables that cannot be provided by a .conf file  
19 -WORKING_DIR="$(pwd)"  
20 -# shellcheck disable=SC2153  
21 -  
22 -mainfile=${pkg.installFolder}/bin/${pkg.name}  
23 -configfile=${pkg.name}.conf  
24 -  
25 -# Follow symlinks to find the real script and detect init.d script  
26 -cd "$(dirname "$0")" || exit 1  
27 -[[ -z "$initfile" ]] && initfile=$(pwd)/$(basename "$0")  
28 -while [[ -L "$initfile" ]]; do  
29 - [[ "$initfile" =~ init\.d ]] && init_script=$(basename "$initfile")  
30 - initfile=$(readlink "$initfile")  
31 - cd "$(dirname "$initfile")" || exit 1  
32 - initfile=$(pwd)/$(basename "$initfile")  
33 -done  
34 -initfolder="$( (cd "$(dirname "initfile")" && pwd -P) )"  
35 -cd "$WORKING_DIR" || exit 1  
36 -  
37 -# Initialize CONF_FOLDER location  
38 -[[ -z "$CONF_FOLDER" ]] && CONF_FOLDER="${pkg.installFolder}/conf"  
39 -  
40 -# shellcheck source=/dev/null  
41 -[[ -r "${CONF_FOLDER}/${configfile}" ]] && source "${CONF_FOLDER}/${configfile}"  
42 -  
43 -# Initialize PID/LOG locations if they weren't provided by the config file  
44 -[[ -z "$PID_FOLDER" ]] && PID_FOLDER="/var/run"  
45 -[[ -z "$LOG_FOLDER" ]] && LOG_FOLDER="${pkg.unixLogFolder}"  
46 -! [[ "$PID_FOLDER" == /* ]] && PID_FOLDER="$(dirname "$mainfile")"/"$PID_FOLDER"  
47 -! [[ "$LOG_FOLDER" == /* ]] && LOG_FOLDER="$(dirname "$mainfile")"/"$LOG_FOLDER"  
48 -! [[ -x "$PID_FOLDER" ]] && PID_FOLDER="/tmp"  
49 -! [[ -x "$LOG_FOLDER" ]] && LOG_FOLDER="/tmp"  
50 -  
51 -# Set up defaults  
52 -[[ -z "$MODE" ]] && MODE="auto" # modes are "auto", "service" or "run"  
53 -[[ -z "$USE_START_STOP_DAEMON" ]] && USE_START_STOP_DAEMON="true"  
54 -  
55 -# Create an identity for log/pid files  
56 -if [[ -z "$identity" ]]; then  
57 - if [[ -n "$init_script" ]]; then  
58 - identity="${init_script}"  
59 - else  
60 - identity=$(basename "${initfile%.*}")_${initfolder//\//}  
61 - fi  
62 -fi  
63 -  
64 -# Initialize log file name if not provided by the config file  
65 -[[ -z "$LOG_FILENAME" ]] && LOG_FILENAME="${identity}.log"  
66 -  
67 -# ANSI Colors  
68 -echoRed() { echo $'\e[0;31m'"$1"$'\e[0m'; }  
69 -echoGreen() { echo $'\e[0;32m'"$1"$'\e[0m'; }  
70 -echoYellow() { echo $'\e[0;33m'"$1"$'\e[0m'; }  
71 -  
72 -# Utility functions  
73 -checkPermissions() {  
74 - touch "$pid_file" &> /dev/null || { echoRed "Operation not permitted (cannot access pid file)"; return 4; }  
75 - touch "$log_file" &> /dev/null || { echoRed "Operation not permitted (cannot access log file)"; return 4; }  
76 -}  
77 -  
78 -isRunning() {  
79 - ps -p "$1" &> /dev/null  
80 -}  
81 -  
82 -await_file() {  
83 - end=$(date +%s)  
84 - let "end+=10"  
85 - while [[ ! -s "$1" ]]  
86 - do  
87 - now=$(date +%s)  
88 - if [[ $now -ge $end ]]; then  
89 - break  
90 - fi  
91 - sleep 1  
92 - done  
93 -}  
94 -  
95 -# Determine the script mode  
96 -action="run"  
97 -if [[ "$MODE" == "auto" && -n "$init_script" ]] || [[ "$MODE" == "service" ]]; then  
98 - action="$1"  
99 - shift  
100 -fi  
101 -  
102 -# Build the pid and log filenames  
103 -if [[ "$identity" == "$init_script" ]] || [[ "$identity" == "$APP_NAME" ]]; then  
104 - PID_FOLDER="$PID_FOLDER/${identity}"  
105 - pid_subfolder=$PID_FOLDER  
106 -fi  
107 -pid_file="$PID_FOLDER/${identity}.pid"  
108 -log_file="$LOG_FOLDER/$LOG_FILENAME"  
109 -  
110 -# Determine the user to run as if we are root  
111 -# shellcheck disable=SC2012  
112 -[[ $(id -u) == "0" ]] && run_user=$(ls -ld "$mainfile" | awk '{print $3}')  
113 -  
114 -arguments=($RUN_ARGS "$@")  
115 -  
116 -# Action functions  
117 -start() {  
118 - if [[ -f "$pid_file" ]]; then  
119 - pid=$(cat "$pid_file")  
120 - isRunning "$pid" && { echoYellow "Already running [$pid]"; return 0; }  
121 - fi  
122 - do_start "$@"  
123 -}  
124 -  
125 -do_start() {  
126 - working_dir=$(dirname "$mainfile")  
127 - pushd "$working_dir" > /dev/null  
128 - mkdir -p "$PID_FOLDER" &> /dev/null  
129 - if [[ -n "$run_user" ]]; then  
130 - checkPermissions || return $?  
131 - if [[ -z "$pid_subfolder" ]]; then  
132 - chown "$run_user" "$pid_subfolder"  
133 - fi  
134 - chown "$run_user" "$pid_file"  
135 - chown "$run_user" "$log_file"  
136 - if [ $USE_START_STOP_DAEMON = true ] && type start-stop-daemon > /dev/null 2>&1; then  
137 - start-stop-daemon --start --quiet \  
138 - --chuid "$run_user" \  
139 - --name "$identity" \  
140 - --make-pidfile --pidfile "$pid_file" \  
141 - --background --no-close \  
142 - --startas "$mainfile" \  
143 - --chdir "$working_dir" \  
144 - -- "${arguments[@]}" \  
145 - >> "$log_file" 2>&1  
146 - await_file "$pid_file"  
147 - else  
148 - su -s /bin/sh -c "$mainfile $(printf "\"%s\" " "${arguments[@]}") >> \"$log_file\" 2>&1 & echo \$!" "$run_user" > "$pid_file"  
149 - fi  
150 - pid=$(cat "$pid_file")  
151 - else  
152 - checkPermissions || return $?  
153 - "$mainfile" "${arguments[@]}" >> "$log_file" 2>&1 &  
154 - pid=$!  
155 - disown $pid  
156 - echo "$pid" > "$pid_file"  
157 - fi  
158 - [[ -z $pid ]] && { echoRed "Failed to start"; return 1; }  
159 - echoGreen "Started [$pid]"  
160 -}  
161 -  
162 -stop() {  
163 - working_dir=$(dirname "$mainfile")  
164 - pushd "$working_dir" > /dev/null  
165 - [[ -f $pid_file ]] || { echoYellow "Not running (pidfile not found)"; return 0; }  
166 - pid=$(cat "$pid_file")  
167 - isRunning "$pid" || { echoYellow "Not running (process ${pid}). Removing stale pid file."; rm -f "$pid_file"; return 0; }  
168 - do_stop "$pid" "$pid_file"  
169 -}  
170 -  
171 -do_stop() {  
172 - kill -2 "$1" &> /dev/null || { echoRed "Unable to kill process $1"; return 1; }  
173 - for i in $(seq 1 60); do  
174 - isRunning "$1" || { echoGreen "Stopped [$1]"; rm -f "$2"; return 0; }  
175 - [[ $i -eq 30 ]] && kill -9 "$1" &> /dev/null  
176 - sleep 1  
177 - done  
178 - echoRed "Unable to kill process $1";  
179 - return 1;  
180 -}  
181 -  
182 -restart() {  
183 - stop && start  
184 -}  
185 -  
186 -orce_reload() {  
187 - working_dir=$(dirname "$mainfile")  
188 - pushd "$working_dir" > /dev/null  
189 - [[ -f $pid_file ]] || { echoRed "Not running (pidfile not found)"; return 7; }  
190 - pid=$(cat "$pid_file")  
191 - rm -f "$pid_file"  
192 - isRunning "$pid" || { echoRed "Not running (process ${pid} not found)"; return 7; }  
193 - do_stop "$pid" "$pid_file"  
194 - do_start  
195 -}  
196 -  
197 -status() {  
198 - working_dir=$(dirname "$mainfile")  
199 - pushd "$working_dir" > /dev/null  
200 - [[ -f "$pid_file" ]] || { echoRed "Not running"; return 3; }  
201 - pid=$(cat "$pid_file")  
202 - isRunning "$pid" || { echoRed "Not running (process ${pid} not found)"; return 1; }  
203 - echoGreen "Running [$pid]"  
204 - return 0  
205 -}  
206 -  
207 -run() {  
208 - pushd "$(dirname "$mainfile")" > /dev/null  
209 - "$mainfile" "${arguments[@]}"  
210 - result=$?  
211 - popd > /dev/null  
212 - return "$result"  
213 -}  
214 -  
215 -# Call the appropriate action function  
216 -case "$action" in  
217 -start)  
218 - start "$@"; exit $?;;  
219 -stop)  
220 - stop "$@"; exit $?;;  
221 -restart)  
222 - restart "$@"; exit $?;;  
223 -force-reload)  
224 - force_reload "$@"; exit $?;;  
225 -status)  
226 - status "$@"; exit $?;;  
227 -run)  
228 - run "$@"; exit $?;;  
229 -*)  
230 - echo "Usage: $0 {start|stop|restart|force-reload|status|run}"; exit 1;  
231 -esac  
232 -  
233 -exit 0  
1 -@REM  
2 -@REM Copyright © 2016-2018 The Thingsboard Authors  
3 -@REM  
4 -@REM Licensed under the Apache License, Version 2.0 (the "License");  
5 -@REM you may not use this file except in compliance with the License.  
6 -@REM You may obtain a copy of the License at  
7 -@REM  
8 -@REM http://www.apache.org/licenses/LICENSE-2.0  
9 -@REM  
10 -@REM Unless required by applicable law or agreed to in writing, software  
11 -@REM distributed under the License is distributed on an "AS IS" BASIS,  
12 -@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
13 -@REM See the License for the specific language governing permissions and  
14 -@REM limitations under the License.  
15 -@REM  
16 -  
17 -@ECHO OFF  
18 -  
19 -setlocal ENABLEEXTENSIONS  
20 -  
21 -@ECHO Installing ${pkg.name} ...  
22 -  
23 -SET BASE=%~dp0  
24 -  
25 -"%BASE%"${pkg.name}.exe install  
26 -  
27 -@ECHO ${pkg.name} installed successfully!  
28 -  
29 -GOTO END  
30 -  
31 -:END  
1 -@REM  
2 -@REM Copyright © 2016-2018 The Thingsboard Authors  
3 -@REM  
4 -@REM Licensed under the Apache License, Version 2.0 (the "License");  
5 -@REM you may not use this file except in compliance with the License.  
6 -@REM You may obtain a copy of the License at  
7 -@REM  
8 -@REM http://www.apache.org/licenses/LICENSE-2.0  
9 -@REM  
10 -@REM Unless required by applicable law or agreed to in writing, software  
11 -@REM distributed under the License is distributed on an "AS IS" BASIS,  
12 -@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
13 -@REM See the License for the specific language governing permissions and  
14 -@REM limitations under the License.  
15 -@REM  
16 -  
17 -@ECHO OFF  
18 -  
19 -@ECHO Stopping ${pkg.name} ...  
20 -net stop ${pkg.name}  
21 -  
22 -@ECHO Uninstalling ${pkg.name} ...  
23 -"%~dp0"${pkg.name}.exe uninstall  
24 -  
25 -@ECHO DONE.  
@@ -22,7 +22,6 @@ @@ -22,7 +22,6 @@
22 <version>2.5.1-SNAPSHOT</version> 22 <version>2.5.1-SNAPSHOT</version>
23 <artifactId>thingsboard</artifactId> 23 <artifactId>thingsboard</artifactId>
24 </parent> 24 </parent>
25 - <groupId>org.thingsboard</groupId>  
26 <artifactId>netty-mqtt</artifactId> 25 <artifactId>netty-mqtt</artifactId>
27 <version>2.5.1-SNAPSHOT</version> 26 <version>2.5.1-SNAPSHOT</version>
28 <packaging>jar</packaging> 27 <packaging>jar</packaging>
packaging/java/assembly/windows.xml renamed from application/src/main/assembly/windows.xml
packaging/java/build.gradle renamed from application/build.gradle
@@ -17,7 +17,7 @@ import org.apache.tools.ant.filters.ReplaceTokens @@ -17,7 +17,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
17 17
18 buildscript { 18 buildscript {
19 ext { 19 ext {
20 - osPackageVersion = "3.8.0" 20 + osPackageVersion = "8.3.0"
21 } 21 }
22 repositories { 22 repositories {
23 jcenter() 23 jcenter()
@@ -43,8 +43,8 @@ ospackage { @@ -43,8 +43,8 @@ ospackage {
43 43
44 into pkgInstallFolder 44 into pkgInstallFolder
45 45
46 - user pkgName  
47 - permissionGroup pkgName 46 + user pkgUser
  47 + permissionGroup pkgUser
48 48
49 // Copy the actual .jar file 49 // Copy the actual .jar file
50 from(mainJar) { 50 from(mainJar) {
@@ -56,23 +56,25 @@ ospackage { @@ -56,23 +56,25 @@ ospackage {
56 into "bin" 56 into "bin"
57 } 57 }
58 58
59 - // Copy the install files  
60 - from("target/bin/install/install.sh") {  
61 - fileMode 0775  
62 - into "bin/install"  
63 - } 59 + if("${pkgCopyInstallScripts}".equalsIgnoreCase("true")) {
  60 + // Copy the install files
  61 + from("${buildDir}/bin/install/install.sh") {
  62 + fileMode 0775
  63 + into "bin/install"
  64 + }
64 65
65 - from("target/bin/install/upgrade.sh") {  
66 - fileMode 0775  
67 - into "bin/install"  
68 - } 66 + from("${buildDir}/bin/install/upgrade.sh") {
  67 + fileMode 0775
  68 + into "bin/install"
  69 + }
69 70
70 - from("target/bin/install/logback.xml") {  
71 - into "bin/install" 71 + from("${buildDir}/bin/install/logback.xml") {
  72 + into "bin/install"
  73 + }
72 } 74 }
73 75
74 // Copy the config files 76 // Copy the config files
75 - from("target/conf") { 77 + from("${buildDir}/conf") {
76 exclude "${pkgName}.conf" 78 exclude "${pkgName}.conf"
77 fileType CONFIG | NOREPLACE 79 fileType CONFIG | NOREPLACE
78 fileMode 0754 80 fileMode 0754
@@ -80,14 +82,14 @@ ospackage { @@ -80,14 +82,14 @@ ospackage {
80 } 82 }
81 83
82 // Copy the data files 84 // Copy the data files
83 - from("target/data") { 85 + from("${buildDir}/data") {
84 fileType CONFIG | NOREPLACE 86 fileType CONFIG | NOREPLACE
85 fileMode 0754 87 fileMode 0754
86 into "data" 88 into "data"
87 } 89 }
88 90
89 // Copy the extensions files 91 // Copy the extensions files
90 - from("target/extensions") { 92 + from("${buildDir}/extensions") {
91 into "extensions" 93 into "extensions"
92 } 94 }
93 } 95 }
@@ -97,12 +99,12 @@ buildRpm { @@ -97,12 +99,12 @@ buildRpm {
97 99
98 arch = NOARCH 100 arch = NOARCH
99 101
100 - version = projectVersion.replace('-', '')  
101 - archiveName = "${pkgName}.rpm" 102 + archiveVersion = projectVersion.replace('-', '')
  103 + archiveFileName = "${pkgName}.rpm"
102 104
103 requires("java-1.8.0") 105 requires("java-1.8.0")
104 106
105 - from("target/conf") { 107 + from("${buildDir}/conf") {
106 include "${pkgName}.conf" 108 include "${pkgName}.conf"
107 filter(ReplaceTokens, tokens: ['pkg.platform': 'rpm']) 109 filter(ReplaceTokens, tokens: ['pkg.platform': 'rpm'])
108 fileType CONFIG | NOREPLACE 110 fileType CONFIG | NOREPLACE
@@ -115,17 +117,19 @@ buildRpm { @@ -115,17 +117,19 @@ buildRpm {
115 preUninstall file("${buildDir}/control/rpm/prerm") 117 preUninstall file("${buildDir}/control/rpm/prerm")
116 postUninstall file("${buildDir}/control/rpm/postrm") 118 postUninstall file("${buildDir}/control/rpm/postrm")
117 119
118 - user pkgName  
119 - permissionGroup pkgName 120 + user pkgUser
  121 + permissionGroup pkgUser
120 122
121 // Copy the system unit files 123 // Copy the system unit files
122 - from("${buildDir}/control/${pkgName}.service") { 124 + from("${buildDir}/control/template.service") {
123 addParentDirs = false 125 addParentDirs = false
124 fileMode 0644 126 fileMode 0644
125 into "/usr/lib/systemd/system" 127 into "/usr/lib/systemd/system"
  128 + rename { String filename ->
  129 + "${pkgName}.service"
  130 + }
126 } 131 }
127 132
128 - directory(pkgLogFolder, 0755)  
129 link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml") 133 link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml")
130 link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf") 134 link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")
131 } 135 }
@@ -135,11 +139,11 @@ buildDeb { @@ -135,11 +139,11 @@ buildDeb {
135 139
136 arch = "all" 140 arch = "all"
137 141
138 - archiveName = "${pkgName}.deb" 142 + archiveFileName = "${pkgName}.deb"
139 143
140 requires("openjdk-8-jre").or("java8-runtime").or("oracle-java8-installer").or("openjdk-8-jre-headless") 144 requires("openjdk-8-jre").or("java8-runtime").or("oracle-java8-installer").or("openjdk-8-jre-headless")
141 145
142 - from("target/conf") { 146 + from("${buildDir}/conf") {
143 include "${pkgName}.conf" 147 include "${pkgName}.conf"
144 filter(ReplaceTokens, tokens: ['pkg.platform': 'deb']) 148 filter(ReplaceTokens, tokens: ['pkg.platform': 'deb'])
145 fileType CONFIG | NOREPLACE 149 fileType CONFIG | NOREPLACE
@@ -157,18 +161,39 @@ buildDeb { @@ -157,18 +161,39 @@ buildDeb {
157 preUninstall file("${buildDir}/control/deb/prerm") 161 preUninstall file("${buildDir}/control/deb/prerm")
158 postUninstall file("${buildDir}/control/deb/postrm") 162 postUninstall file("${buildDir}/control/deb/postrm")
159 163
160 - user pkgName  
161 - permissionGroup pkgName 164 + user pkgUser
  165 + permissionGroup pkgUser
162 166
163 // Copy the system unit files 167 // Copy the system unit files
164 - from("${buildDir}/control/${pkgName}.service") { 168 + from("${buildDir}/control/template.service") {
165 addParentDirs = false 169 addParentDirs = false
166 fileMode 0644 170 fileMode 0644
167 into "/lib/systemd/system" 171 into "/lib/systemd/system"
  172 + rename { String filename ->
  173 + "${pkgName}.service"
  174 + }
168 } 175 }
169 176
170 - directory(pkgLogFolder, 0755)  
171 - link("/etc/init.d/${pkgName}", "${pkgInstallFolder}/bin/${pkgName}.jar")  
172 link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml") 177 link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml")
173 link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf") 178 link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")
174 } 179 }
  180 +
  181 +task renameDeb(type: Copy) {
  182 + from("${buildDir}/") {
  183 + include '*.deb'
  184 + destinationDir file("${buildDir}/")
  185 + rename { String filename ->
  186 + "${pkgName}.deb"
  187 + }
  188 + }
  189 +}
  190 +
  191 +task renameRpm(type: Copy) {
  192 + from("${buildDir}/") {
  193 + include '*.rpm'
  194 + destinationDir file("${buildDir}/")
  195 + rename { String filename ->
  196 + "${pkgName}.rpm"
  197 + }
  198 + }
  199 +}
packaging/java/filters/unix.properties renamed from application/src/main/filters/unix.properties
packaging/java/filters/windows.properties renamed from application/src/main/filters/windows.properties
packaging/java/scripts/control/deb/postinst renamed from application/src/main/scripts/control/deb/postinst
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 set -e 3 set -e
4 4
  5 +mkdir -m 0755 -p ${pkg.logFolder}
5 chown -R ${pkg.user}: ${pkg.logFolder} 6 chown -R ${pkg.user}: ${pkg.logFolder}
6 chown -R ${pkg.user}: ${pkg.installFolder} 7 chown -R ${pkg.user}: ${pkg.installFolder}
7 systemctl --no-reload enable ${pkg.name}.service >/dev/null 2>&1 || : 8 systemctl --no-reload enable ${pkg.name}.service >/dev/null 2>&1 || :
packaging/java/scripts/control/deb/postrm renamed from application/src/main/scripts/control/deb/postrm
packaging/java/scripts/control/deb/preinst renamed from application/src/main/scripts/control/deb/preinst
packaging/java/scripts/control/deb/prerm renamed from application/src/main/scripts/control/deb/prerm
packaging/java/scripts/control/rpm/postinst renamed from application/src/main/scripts/control/rpm/postinst
1 #!/bin/sh 1 #!/bin/sh
2 2
  3 +mkdir -m 0755 -p ${pkg.logFolder}
3 chown -R ${pkg.user}: ${pkg.logFolder} 4 chown -R ${pkg.user}: ${pkg.logFolder}
4 chown -R ${pkg.user}: ${pkg.installFolder} 5 chown -R ${pkg.user}: ${pkg.installFolder}
5 6
packaging/java/scripts/control/rpm/postrm renamed from application/src/main/scripts/control/rpm/postrm
packaging/java/scripts/control/rpm/preinst renamed from application/src/main/scripts/control/rpm/preinst
packaging/java/scripts/control/rpm/prerm renamed from application/src/main/scripts/control/rpm/prerm
packaging/java/scripts/control/template.service renamed from application/src/main/scripts/control/thingsboard.service
packaging/java/scripts/install/install.sh renamed from application/src/main/scripts/install/install.sh
packaging/java/scripts/install/install_dev_db.sh renamed from application/src/main/scripts/install/install_dev_db.sh
packaging/java/scripts/install/logback.xml renamed from application/src/main/scripts/install/logback.xml
packaging/java/scripts/install/upgrade.sh renamed from application/src/main/scripts/install/upgrade.sh
packaging/java/scripts/install/upgrade_dev_db.sh renamed from application/src/main/scripts/install/upgrade_dev_db.sh
packaging/java/scripts/windows/install.bat renamed from application/src/main/scripts/windows/install.bat
packaging/java/scripts/windows/install_dev_db.bat renamed from application/src/main/scripts/windows/install_dev_db.bat
packaging/java/scripts/windows/service.xml renamed from application/src/main/scripts/windows/service.xml
packaging/java/scripts/windows/uninstall.bat renamed from application/src/main/scripts/windows/uninstall.bat
packaging/java/scripts/windows/upgrade.bat renamed from application/src/main/scripts/windows/upgrade.bat
packaging/js/assembly/windows.xml renamed from msa/web-ui/src/main/assembly/windows.xml
packaging/js/build.gradle renamed from msa/web-ui/build.gradle
@@ -17,7 +17,7 @@ import org.apache.tools.ant.filters.ReplaceTokens @@ -17,7 +17,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
17 17
18 buildscript { 18 buildscript {
19 ext { 19 ext {
20 - osPackageVersion = "3.8.0" 20 + osPackageVersion = "8.3.0"
21 } 21 }
22 repositories { 22 repositories {
23 jcenter() 23 jcenter()
@@ -47,26 +47,29 @@ ospackage { @@ -47,26 +47,29 @@ ospackage {
47 permissionGroup pkgUser 47 permissionGroup pkgUser
48 48
49 // Copy the executable file 49 // Copy the executable file
50 - from("target/package/linux/bin/${pkgName}") { 50 + from("${buildDir}/package/linux/bin/${pkgName}") {
51 fileMode 0500 51 fileMode 0500
52 into "bin" 52 into "bin"
53 } 53 }
54 54
55 // Copy the init file 55 // Copy the init file
56 - from("target/package/linux/init/${pkgName}") { 56 + from("${buildDir}/package/linux/init/template") {
57 fileMode 0500 57 fileMode 0500
58 into "init" 58 into "init"
  59 + rename { String filename ->
  60 + "${pkgName}"
  61 + }
59 } 62 }
60 63
61 // Copy the config files 64 // Copy the config files
62 - from("target/package/linux/conf") { 65 + from("${buildDir}/package/linux/conf") {
63 fileType CONFIG | NOREPLACE 66 fileType CONFIG | NOREPLACE
64 fileMode 0754 67 fileMode 0754
65 into "conf" 68 into "conf"
66 } 69 }
67 70
68 // Copy web files 71 // Copy web files
69 - from("target/web") { 72 + from("${buildDir}/web") {
70 into "web" 73 into "web"
71 } 74 }
72 75
@@ -77,8 +80,8 @@ buildRpm { @@ -77,8 +80,8 @@ buildRpm {
77 80
78 arch = X86_64 81 arch = X86_64
79 82
80 - version = projectVersion.replace('-', '')  
81 - archiveName = "${pkgName}.rpm" 83 + archiveVersion = projectVersion.replace('-', '')
  84 + archiveFileName = "${pkgName}.rpm"
82 85
83 preInstall file("${buildDir}/control/rpm/preinst") 86 preInstall file("${buildDir}/control/rpm/preinst")
84 postInstall file("${buildDir}/control/rpm/postinst") 87 postInstall file("${buildDir}/control/rpm/postinst")
@@ -89,13 +92,15 @@ buildRpm { @@ -89,13 +92,15 @@ buildRpm {
89 permissionGroup pkgUser 92 permissionGroup pkgUser
90 93
91 // Copy the system unit files 94 // Copy the system unit files
92 - from("${buildDir}/control/${pkgName}.service") { 95 + from("${buildDir}/control/template.service") {
93 addParentDirs = false 96 addParentDirs = false
94 fileMode 0644 97 fileMode 0644
95 into "/usr/lib/systemd/system" 98 into "/usr/lib/systemd/system"
  99 + rename { String filename ->
  100 + "${pkgName}.service"
  101 + }
96 } 102 }
97 103
98 - directory(pkgLogFolder, 0755)  
99 link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf") 104 link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")
100 } 105 }
101 106
@@ -104,7 +109,7 @@ buildDeb { @@ -104,7 +109,7 @@ buildDeb {
104 109
105 arch = "amd64" 110 arch = "amd64"
106 111
107 - archiveName = "${pkgName}.deb" 112 + archiveFileName = "${pkgName}.deb"
108 113
109 configurationFile("${pkgInstallFolder}/conf/${pkgName}.conf") 114 configurationFile("${pkgInstallFolder}/conf/${pkgName}.conf")
110 configurationFile("${pkgInstallFolder}/conf/custom-environment-variables.yml") 115 configurationFile("${pkgInstallFolder}/conf/custom-environment-variables.yml")
@@ -119,7 +124,35 @@ buildDeb { @@ -119,7 +124,35 @@ buildDeb {
119 user pkgUser 124 user pkgUser
120 permissionGroup pkgUser 125 permissionGroup pkgUser
121 126
122 - directory(pkgLogFolder, 0755)  
123 - link("/etc/init.d/${pkgName}", "${pkgInstallFolder}/init/${pkgName}") 127 + // Copy the system unit files
  128 + from("${buildDir}/control/template.service") {
  129 + addParentDirs = false
  130 + fileMode 0644
  131 + into "/lib/systemd/system"
  132 + rename { String filename ->
  133 + "${pkgName}.service"
  134 + }
  135 + }
  136 +
124 link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf") 137 link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")
125 } 138 }
  139 +
  140 +task renameDeb(type: Copy) {
  141 + from("${buildDir}/") {
  142 + include '*.deb'
  143 + destinationDir file("${buildDir}/")
  144 + rename { String filename ->
  145 + "${pkgName}.deb"
  146 + }
  147 + }
  148 +}
  149 +
  150 +task renameRpm(type: Copy) {
  151 + from("${buildDir}/") {
  152 + include '*.rpm'
  153 + destinationDir file("${buildDir}/")
  154 + rename { String filename ->
  155 + "${pkgName}.rpm"
  156 + }
  157 + }
  158 +}
packaging/js/filters/unix.properties renamed from msa/js-executor/src/main/filters/unix.properties
packaging/js/filters/windows.properties renamed from msa/js-executor/src/main/filters/windows.properties
packaging/js/scripts/control/deb/postinst renamed from msa/js-executor/src/main/scripts/control/deb/postinst
1 #!/bin/sh 1 #!/bin/sh
2 2
  3 +mkdir -m 0755 -p ${pkg.logFolder}
3 chown -R ${pkg.user}: ${pkg.logFolder} 4 chown -R ${pkg.user}: ${pkg.logFolder}
4 chown -R ${pkg.user}: ${pkg.installFolder} 5 chown -R ${pkg.user}: ${pkg.installFolder}
5 -update-rc.d ${pkg.name} defaults 6 +
  7 +systemctl --no-reload enable ${pkg.name}.service >/dev/null 2>&1 || :
6 8
  1 +#!/bin/sh
  2 +
  3 +set -e
  4 +
  5 +systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :
  6 +
  7 +exit 0
  8 +
packaging/js/scripts/control/deb/preinst renamed from msa/js-executor/src/main/scripts/control/deb/preinst
packaging/js/scripts/control/deb/prerm renamed from msa/js-executor/src/main/scripts/control/deb/prerm
packaging/js/scripts/control/rpm/postinst renamed from msa/js-executor/src/main/scripts/control/rpm/postinst
1 #!/bin/sh 1 #!/bin/sh
2 2
  3 +mkdir -m 0755 -p ${pkg.logFolder}
3 chown -R ${pkg.user}: ${pkg.logFolder} 4 chown -R ${pkg.user}: ${pkg.logFolder}
4 chown -R ${pkg.user}: ${pkg.installFolder} 5 chown -R ${pkg.user}: ${pkg.installFolder}
5 6
packaging/js/scripts/control/rpm/postrm renamed from msa/js-executor/src/main/scripts/control/rpm/postrm
packaging/js/scripts/control/rpm/preinst renamed from msa/js-executor/src/main/scripts/control/rpm/preinst
packaging/js/scripts/control/rpm/prerm renamed from msa/js-executor/src/main/scripts/control/rpm/prerm
packaging/js/scripts/control/template.service renamed from msa/js-executor/src/main/scripts/control/tb-js-executor.service
packaging/js/scripts/init/template renamed from msa/js-executor/src/main/scripts/init/tb-js-executor
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 3
4 4
5 ### BEGIN INIT INFO 5 ### BEGIN INIT INFO
6 -# Provides: tb-js-executor 6 +# Provides: ${pkg.name}
7 # Required-Start: $remote_fs $syslog $network 7 # Required-Start: $remote_fs $syslog $network
8 # Required-Stop: $remote_fs $syslog $network 8 # Required-Stop: $remote_fs $syslog $network
9 # Default-Start: 2 3 4 5 9 # Default-Start: 2 3 4 5
packaging/js/scripts/windows/install.bat renamed from msa/js-executor/src/main/scripts/windows/install.bat
packaging/js/scripts/windows/service.xml renamed from msa/web-ui/src/main/scripts/windows/service.xml
packaging/js/scripts/windows/uninstall.bat renamed from msa/js-executor/src/main/scripts/windows/uninstall.bat
@@ -29,7 +29,13 @@ @@ -29,7 +29,13 @@
29 29
30 <properties> 30 <properties>
31 <main.dir>${basedir}</main.dir> 31 <main.dir>${basedir}</main.dir>
  32 + <pkg.disabled>true</pkg.disabled>
  33 + <pkg.process-resources.phase>none</pkg.process-resources.phase>
  34 + <pkg.package.phase>none</pkg.package.phase>
32 <pkg.user>thingsboard</pkg.user> 35 <pkg.user>thingsboard</pkg.user>
  36 + <pkg.implementationTitle>${project.name}</pkg.implementationTitle>
  37 + <pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder>
  38 + <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder>
33 <spring-boot.version>2.2.6.RELEASE</spring-boot.version> 39 <spring-boot.version>2.2.6.RELEASE</spring-boot.version>
34 <spring-oauth2.version>2.1.2.RELEASE</spring-oauth2.version> 40 <spring-oauth2.version>2.1.2.RELEASE</spring-oauth2.version>
35 <spring.version>5.2.6.RELEASE</spring.version> 41 <spring.version>5.2.6.RELEASE</spring.version>
@@ -133,6 +139,394 @@ @@ -133,6 +139,394 @@
133 <downloadJavadocs>true</downloadJavadocs> 139 <downloadJavadocs>true</downloadJavadocs>
134 </properties> 140 </properties>
135 </profile> 141 </profile>
  142 +
  143 + <profile>
  144 + <id>packaging</id>
  145 + <activation>
  146 + <activeByDefault>true</activeByDefault>
  147 + </activation>
  148 + <build>
  149 + <pluginManagement>
  150 + <plugins>
  151 + <plugin>
  152 + <groupId>org.apache.maven.plugins</groupId>
  153 + <artifactId>maven-resources-plugin</artifactId>
  154 + <executions>
  155 + <execution>
  156 + <id>copy-conf</id>
  157 + <phase>${pkg.process-resources.phase}</phase>
  158 + <goals>
  159 + <goal>copy-resources</goal>
  160 + </goals>
  161 + <configuration>
  162 + <outputDirectory>${project.build.directory}/conf</outputDirectory>
  163 + <resources>
  164 + <resource>
  165 + <directory>src/main/resources</directory>
  166 + <excludes>
  167 + <exclude>logback.xml</exclude>
  168 + </excludes>
  169 + <filtering>false</filtering>
  170 + </resource>
  171 + </resources>
  172 + </configuration>
  173 + </execution>
  174 + <execution>
  175 + <id>copy-service-conf</id>
  176 + <phase>${pkg.process-resources.phase}</phase>
  177 + <goals>
  178 + <goal>copy-resources</goal>
  179 + </goals>
  180 + <configuration>
  181 + <outputDirectory>${project.build.directory}/conf</outputDirectory>
  182 + <resources>
  183 + <resource>
  184 + <directory>src/main/conf</directory>
  185 + <filtering>true</filtering>
  186 + </resource>
  187 + </resources>
  188 + <filters>
  189 + <filter>${main.dir}/packaging/${pkg.type}/filters/unix.properties</filter>
  190 + </filters>
  191 + </configuration>
  192 + </execution>
  193 + <execution>
  194 + <id>copy-linux-conf</id>
  195 + <phase>${pkg.process-resources.phase}</phase>
  196 + <goals>
  197 + <goal>copy-resources</goal>
  198 + </goals>
  199 + <configuration>
  200 + <outputDirectory>${pkg.linux.dist}/conf</outputDirectory>
  201 + <resources>
  202 + <resource>
  203 + <directory>config</directory>
  204 + <filtering>true</filtering>
  205 + </resource>
  206 + </resources>
  207 + <filters>
  208 + <filter>${main.dir}/packaging/${pkg.type}/filters/unix.properties</filter>
  209 + </filters>
  210 + </configuration>
  211 + </execution>
  212 + <execution>
  213 + <id>copy-linux-init</id>
  214 + <phase>${pkg.process-resources.phase}</phase>
  215 + <goals>
  216 + <goal>copy-resources</goal>
  217 + </goals>
  218 + <configuration>
  219 + <outputDirectory>${pkg.linux.dist}/init</outputDirectory>
  220 + <resources>
  221 + <resource>
  222 + <directory>${main.dir}/packaging/${pkg.type}/scripts/init</directory>
  223 + <filtering>true</filtering>
  224 + </resource>
  225 + </resources>
  226 + <filters>
  227 + <filter>${main.dir}/packaging/${pkg.type}/filters/unix.properties</filter>
  228 + </filters>
  229 + </configuration>
  230 + </execution>
  231 + <execution>
  232 + <id>copy-win-conf</id>
  233 + <phase>${pkg.process-resources.phase}</phase>
  234 + <goals>
  235 + <goal>copy-resources</goal>
  236 + </goals>
  237 + <configuration>
  238 + <outputDirectory>${pkg.win.dist}/conf</outputDirectory>
  239 + <resources>
  240 + <resource>
  241 + <directory>src/main/resources</directory>
  242 + <excludes>
  243 + <exclude>logback.xml</exclude>
  244 + </excludes>
  245 + <filtering>false</filtering>
  246 + </resource>
  247 + <resource>
  248 + <directory>src/main/conf</directory>
  249 + <excludes>
  250 + <exclude>${pkg.name}.conf</exclude>
  251 + </excludes>
  252 + <filtering>true</filtering>
  253 + </resource>
  254 + </resources>
  255 + <filters>
  256 + <filter>${main.dir}/packaging/${pkg.type}/filters/windows.properties</filter>
  257 + </filters>
  258 + </configuration>
  259 + </execution>
  260 + <execution>
  261 + <id>copy-control</id>
  262 + <phase>${pkg.process-resources.phase}</phase>
  263 + <goals>
  264 + <goal>copy-resources</goal>
  265 + </goals>
  266 + <configuration>
  267 + <outputDirectory>${project.build.directory}/control</outputDirectory>
  268 + <resources>
  269 + <resource>
  270 + <directory>${main.dir}/packaging/${pkg.type}/scripts/control</directory>
  271 + <filtering>true</filtering>
  272 + </resource>
  273 + </resources>
  274 + <filters>
  275 + <filter>${main.dir}/packaging/${pkg.type}/filters/unix.properties</filter>
  276 + </filters>
  277 + </configuration>
  278 + </execution>
  279 + <execution>
  280 + <id>copy-install</id>
  281 + <phase>${pkg.process-resources.phase}</phase>
  282 + <goals>
  283 + <goal>copy-resources</goal>
  284 + </goals>
  285 + <configuration>
  286 + <outputDirectory>${project.build.directory}/bin/install</outputDirectory>
  287 + <resources>
  288 + <resource>
  289 + <directory>${main.dir}/packaging/${pkg.type}/scripts/install</directory>
  290 + <includes>
  291 + <include>**/*.sh</include>
  292 + <include>**/*.xml</include>
  293 + </includes>
  294 + <filtering>true</filtering>
  295 + </resource>
  296 + </resources>
  297 + <filters>
  298 + <filter>${main.dir}/packaging/${pkg.type}/filters/unix.properties</filter>
  299 + </filters>
  300 + </configuration>
  301 + </execution>
  302 + <execution>
  303 + <id>copy-windows-control</id>
  304 + <phase>${pkg.process-resources.phase}</phase>
  305 + <goals>
  306 + <goal>copy-resources</goal>
  307 + </goals>
  308 + <configuration>
  309 + <outputDirectory>${pkg.win.dist}</outputDirectory>
  310 + <resources>
  311 + <resource>
  312 + <directory>${main.dir}/packaging/${pkg.type}/scripts/windows</directory>
  313 + <filtering>true</filtering>
  314 + </resource>
  315 + </resources>
  316 + <filters>
  317 + <filter>${main.dir}/packaging/${pkg.type}/filters/windows.properties</filter>
  318 + </filters>
  319 + </configuration>
  320 + </execution>
  321 + <execution>
  322 + <id>copy-windows-install</id>
  323 + <phase>${pkg.process-resources.phase}</phase>
  324 + <goals>
  325 + <goal>copy-resources</goal>
  326 + </goals>
  327 + <configuration>
  328 + <outputDirectory>${pkg.win.dist}/install</outputDirectory>
  329 + <resources>
  330 + <resource>
  331 + <directory>${main.dir}/packaging/${pkg.type}/scripts/install</directory>
  332 + <includes>
  333 + <include>logback.xml</include>
  334 + </includes>
  335 + <filtering>true</filtering>
  336 + </resource>
  337 + </resources>
  338 + <filters>
  339 + <filter>${main.dir}/packaging/${pkg.type}/filters/windows.properties</filter>
  340 + </filters>
  341 + </configuration>
  342 + </execution>
  343 + <execution>
  344 + <id>copy-data</id>
  345 + <phase>${pkg.process-resources.phase}</phase>
  346 + <goals>
  347 + <goal>copy-resources</goal>
  348 + </goals>
  349 + <configuration>
  350 + <outputDirectory>${project.build.directory}/data</outputDirectory>
  351 + <resources>
  352 + <resource>
  353 + <directory>src/main/data</directory>
  354 + </resource>
  355 + <resource>
  356 + <directory>../dao/src/main/resources</directory>
  357 + <includes>
  358 + <include>**/*.cql</include>
  359 + <include>**/*.sql</include>
  360 + </includes>
  361 + <filtering>false</filtering>
  362 + </resource>
  363 + </resources>
  364 + </configuration>
  365 + </execution>
  366 + <execution>
  367 + <id>copy-docker-config</id>
  368 + <phase>${pkg.process-resources.phase}</phase>
  369 + <goals>
  370 + <goal>copy-resources</goal>
  371 + </goals>
  372 + <configuration>
  373 + <outputDirectory>${project.build.directory}</outputDirectory>
  374 + <resources>
  375 + <resource>
  376 + <directory>docker</directory>
  377 + <filtering>true</filtering>
  378 + </resource>
  379 + </resources>
  380 + </configuration>
  381 + </execution>
  382 + </executions>
  383 + </plugin>
  384 + <plugin>
  385 + <groupId>org.apache.maven.plugins</groupId>
  386 + <artifactId>maven-dependency-plugin</artifactId>
  387 + <executions>
  388 + <execution>
  389 + <id>copy-winsw-service</id>
  390 + <phase>${pkg.package.phase}</phase>
  391 + <goals>
  392 + <goal>copy</goal>
  393 + </goals>
  394 + <configuration>
  395 + <artifactItems>
  396 + <artifactItem>
  397 + <groupId>com.sun.winsw</groupId>
  398 + <artifactId>winsw</artifactId>
  399 + <classifier>bin</classifier>
  400 + <type>exe</type>
  401 + <destFileName>service.exe</destFileName>
  402 + </artifactItem>
  403 + </artifactItems>
  404 + <outputDirectory>${pkg.win.dist}</outputDirectory>
  405 + </configuration>
  406 + </execution>
  407 + </executions>
  408 + </plugin>
  409 + <plugin>
  410 + <groupId>org.apache.maven.plugins</groupId>
  411 + <artifactId>maven-jar-plugin</artifactId>
  412 + <configuration>
  413 + <excludes>
  414 + <exclude>**/logback.xml</exclude>
  415 + </excludes>
  416 + <archive>
  417 + <manifestEntries>
  418 + <Implementation-Title>${pkg.implementationTitle}</Implementation-Title>
  419 + <Implementation-Version>${project.version}</Implementation-Version>
  420 + </manifestEntries>
  421 + </archive>
  422 + </configuration>
  423 + </plugin>
  424 + <plugin>
  425 + <groupId>org.springframework.boot</groupId>
  426 + <artifactId>spring-boot-maven-plugin</artifactId>
  427 + <configuration>
  428 + <skip>${pkg.disabled}</skip>
  429 + <mainClass>${pkg.mainClass}</mainClass>
  430 + <classifier>boot</classifier>
  431 + <layout>ZIP</layout>
  432 + <executable>true</executable>
  433 + <excludeDevtools>true</excludeDevtools>
  434 + <embeddedLaunchScriptProperties>
  435 + <confFolder>${pkg.installFolder}/conf</confFolder>
  436 + <logFolder>${pkg.unixLogFolder}</logFolder>
  437 + <logFilename>${pkg.name}.out</logFilename>
  438 + <initInfoProvides>${pkg.name}</initInfoProvides>
  439 + </embeddedLaunchScriptProperties>
  440 + </configuration>
  441 + <executions>
  442 + <execution>
  443 + <goals>
  444 + <goal>repackage</goal>
  445 + </goals>
  446 + </execution>
  447 + </executions>
  448 + </plugin>
  449 + <plugin>
  450 + <groupId>org.thingsboard</groupId>
  451 + <artifactId>gradle-maven-plugin</artifactId>
  452 + <configuration>
  453 + <gradleProjectDirectory>${main.dir}/packaging/${pkg.type}</gradleProjectDirectory>
  454 + <tasks>
  455 + <task>build</task>
  456 + <task>buildDeb</task>
  457 + <task>buildRpm</task>
  458 + <task>renameDeb</task>
  459 + <task>renameRpm</task>
  460 + </tasks>
  461 + <args>
  462 + <arg>-PpackagingDir=${main.dir}/packaging</arg>
  463 + <arg>-PprojectBuildDir=${basedir}/target</arg>
  464 + <arg>-PprojectVersion=${project.version}</arg>
  465 + <arg>
  466 + -PmainJar=${project.build.directory}/${project.build.finalName}-boot.${project.packaging}
  467 + </arg>
  468 + <arg>-PpkgName=${pkg.name}</arg>
  469 + <arg>-PpkgUser=${pkg.user}</arg>
  470 + <arg>-PpkgInstallFolder=${pkg.installFolder}</arg>
  471 + <arg>-PpkgCopyInstallScripts=${pkg.copyInstallScripts}</arg>
  472 + <arg>-PpkgLogFolder=${pkg.unixLogFolder}</arg>
  473 + <arg>--warning-mode</arg>
  474 + <arg>all</arg>
  475 + </args>
  476 + </configuration>
  477 + <executions>
  478 + <execution>
  479 + <phase>${pkg.package.phase}</phase>
  480 + <goals>
  481 + <goal>invoke</goal>
  482 + </goals>
  483 + </execution>
  484 + </executions>
  485 + </plugin>
  486 + <plugin>
  487 + <groupId>org.apache.maven.plugins</groupId>
  488 + <artifactId>maven-assembly-plugin</artifactId>
  489 + <configuration>
  490 + <finalName>${pkg.name}</finalName>
  491 + <descriptors>
  492 + <descriptor>${main.dir}/packaging/${pkg.type}/assembly/windows.xml</descriptor>
  493 + </descriptors>
  494 + </configuration>
  495 + <executions>
  496 + <execution>
  497 + <id>assembly</id>
  498 + <phase>${pkg.package.phase}</phase>
  499 + <goals>
  500 + <goal>single</goal>
  501 + </goals>
  502 + </execution>
  503 + </executions>
  504 + </plugin>
  505 + <plugin>
  506 + <groupId>org.apache.maven.plugins</groupId>
  507 + <artifactId>maven-install-plugin</artifactId>
  508 + <configuration>
  509 + <file>${project.build.directory}/${pkg.name}.deb</file>
  510 + <artifactId>${project.artifactId}</artifactId>
  511 + <groupId>${project.groupId}</groupId>
  512 + <version>${project.version}</version>
  513 + <classifier>deb</classifier>
  514 + <packaging>deb</packaging>
  515 + </configuration>
  516 + <executions>
  517 + <execution>
  518 + <id>install-deb</id>
  519 + <phase>${pkg.package.phase}</phase>
  520 + <goals>
  521 + <goal>install-file</goal>
  522 + </goals>
  523 + </execution>
  524 + </executions>
  525 + </plugin>
  526 + </plugins>
  527 + </pluginManagement>
  528 + </build>
  529 + </profile>
136 </profiles> 530 </profiles>
137 531
138 <build> 532 <build>
@@ -182,7 +576,7 @@ @@ -182,7 +576,7 @@
182 <plugin> 576 <plugin>
183 <groupId>org.thingsboard</groupId> 577 <groupId>org.thingsboard</groupId>
184 <artifactId>gradle-maven-plugin</artifactId> 578 <artifactId>gradle-maven-plugin</artifactId>
185 - <version>1.0.9</version> 579 + <version>1.0.10</version>
186 </plugin> 580 </plugin>
187 <plugin> 581 <plugin>
188 <groupId>org.apache.maven.plugins</groupId> 582 <groupId>org.apache.maven.plugins</groupId>
@@ -321,6 +715,12 @@ @@ -321,6 +715,12 @@
321 <exclude>src/vendor/**</exclude> 715 <exclude>src/vendor/**</exclude>
322 <exclude>src/font/**</exclude> 716 <exclude>src/font/**</exclude>
323 <exclude>src/sh/**</exclude> 717 <exclude>src/sh/**</exclude>
  718 + <exclude>packaging/*/scripts/control/**</exclude>
  719 + <exclude>packaging/*/scripts/windows/**</exclude>
  720 + <exclude>packaging/*/scripts/init/**</exclude>
  721 + <exclude>**/*.log</exclude>
  722 + <exclude>**/*.current</exclude>
  723 + <exclude>.instance_id</exclude>
324 <exclude>src/main/scripts/control/**</exclude> 724 <exclude>src/main/scripts/control/**</exclude>
325 <exclude>src/main/scripts/windows/**</exclude> 725 <exclude>src/main/scripts/windows/**</exclude>
326 <exclude>src/main/resources/public/static/rulenode/**</exclude> 726 <exclude>src/main/resources/public/static/rulenode/**</exclude>
@@ -970,11 +1370,6 @@ @@ -970,11 +1370,6 @@
970 <version>${commons-collections.version}</version> 1370 <version>${commons-collections.version}</version>
971 </dependency> 1371 </dependency>
972 <dependency> 1372 <dependency>
973 - <groupId>org.yaml</groupId>  
974 - <artifactId>snakeyaml</artifactId>  
975 - <version>${snakeyaml.version}</version>  
976 - </dependency>  
977 - <dependency>  
978 <groupId>org.apache.struts</groupId> 1373 <groupId>org.apache.struts</groupId>
979 <artifactId>struts-core</artifactId> 1374 <artifactId>struts-core</artifactId>
980 <version>${struts.version}</version> 1375 <version>${struts.version}</version>
@@ -989,7 +1384,6 @@ @@ -989,7 +1384,6 @@
989 <artifactId>struts-tiles</artifactId> 1384 <artifactId>struts-tiles</artifactId>
990 <version>${struts.version}</version> 1385 <version>${struts.version}</version>
991 </dependency> 1386 </dependency>
992 -  
993 </dependencies> 1387 </dependencies>
994 </dependencyManagement> 1388 </dependencyManagement>
995 1389
@@ -1032,5 +1426,4 @@ @@ -1032,5 +1426,4 @@
1032 <url>https://oss.sonatype.org/content/groups/public</url> 1426 <url>https://oss.sonatype.org/content/groups/public</url>
1033 </repository> 1427 </repository>
1034 </repositories> 1428 </repositories>
1035 -  
1036 </project> 1429 </project>
@@ -155,31 +155,6 @@ @@ -155,31 +155,6 @@
155 <groupId>org.codehaus.mojo</groupId> 155 <groupId>org.codehaus.mojo</groupId>
156 <artifactId>build-helper-maven-plugin</artifactId> 156 <artifactId>build-helper-maven-plugin</artifactId>
157 </plugin> 157 </plugin>
158 - <plugin>  
159 - <groupId>org.springframework.boot</groupId>  
160 - <artifactId>spring-boot-maven-plugin</artifactId>  
161 - <configuration>  
162 - <mainClass>org.thingsboard.server.dao.queue.QueueBenchmark</mainClass>  
163 - <classifier>boot</classifier>  
164 - <layout>ZIP</layout>  
165 - <executable>true</executable>  
166 - <excludeDevtools>true</excludeDevtools>  
167 - <!--<embeddedLaunchScriptProperties>-->  
168 - <!--<confFolder>${pkg.installFolder}/conf</confFolder>-->  
169 - <!--<logFolder>${pkg.unixLogFolder}</logFolder>-->  
170 - <!--<logFilename>${pkg.name}.out</logFilename>-->  
171 - <!--<initInfoProvides>${pkg.name}</initInfoProvides>-->  
172 - <!--</embeddedLaunchScriptProperties>-->  
173 - </configuration>  
174 - <executions>  
175 - <execution>  
176 - <goals>  
177 - <goal>repackage</goal>  
178 - </goals>  
179 - </execution>  
180 - </executions>  
181 - </plugin>  
182 -  
183 </plugins> 158 </plugins>
184 </build> 159 </build>
185 160
@@ -70,7 +70,7 @@ public class TbMsgTimeseriesNode implements TbNode { @@ -70,7 +70,7 @@ public class TbMsgTimeseriesNode implements TbNode {
70 } catch (NumberFormatException e) { 70 } catch (NumberFormatException e) {
71 } 71 }
72 } else { 72 } else {
73 - ts = System.currentTimeMillis(); 73 + ts = msg.getTs();
74 } 74 }
75 String src = msg.getData(); 75 String src = msg.getData();
76 Map<Long, List<KvEntry>> tsKvMap = JsonConverter.convertToTelemetry(new JsonParser().parse(src), ts); 76 Map<Long, List<KvEntry>> tsKvMap = JsonConverter.convertToTelemetry(new JsonParser().parse(src), ts);
1 -/**  
2 - * Copyright © 2016-2020 The Thingsboard Authors  
3 - *  
4 - * Licensed under the Apache License, Version 2.0 (the "License");  
5 - * you may not use this file except in compliance with the License.  
6 - * You may obtain a copy of the License at  
7 - *  
8 - * http://www.apache.org/licenses/LICENSE-2.0  
9 - *  
10 - * Unless required by applicable law or agreed to in writing, software  
11 - * distributed under the License is distributed on an "AS IS" BASIS,  
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
13 - * See the License for the specific language governing permissions and  
14 - * limitations under the License.  
15 - */  
16 -import org.apache.tools.ant.filters.ReplaceTokens  
17 -  
18 -buildscript {  
19 - ext {  
20 - osPackageVersion = "3.8.0"  
21 - }  
22 - repositories {  
23 - jcenter()  
24 - }  
25 - dependencies {  
26 - classpath("com.netflix.nebula:gradle-ospackage-plugin:${osPackageVersion}")  
27 - }  
28 -}  
29 -  
30 -apply plugin: "nebula.ospackage"  
31 -  
32 -buildDir = projectBuildDir  
33 -version = projectVersion  
34 -distsDirName = "./"  
35 -  
36 -// OS Package plugin configuration  
37 -ospackage {  
38 - packageName = pkgName  
39 - version = "${project.version}"  
40 - release = 1  
41 - os = LINUX  
42 - type = BINARY  
43 -  
44 - into pkgInstallFolder  
45 -  
46 - user pkgName  
47 - permissionGroup pkgName  
48 -  
49 - // Copy the actual .jar file  
50 - from(mainJar) {  
51 - // Strip the version from the jar filename  
52 - rename { String fileName ->  
53 - "${pkgName}.jar"  
54 - }  
55 - fileMode 0500  
56 - into "bin"  
57 - }  
58 -  
59 - // Copy the config files  
60 - from("target/conf") {  
61 - exclude "${pkgName}.conf"  
62 - fileType CONFIG | NOREPLACE  
63 - fileMode 0754  
64 - into "conf"  
65 - }  
66 -  
67 -}  
68 -  
69 -// Configure our RPM build task  
70 -buildRpm {  
71 -  
72 - arch = NOARCH  
73 -  
74 - version = projectVersion.replace('-', '')  
75 - archiveName = "${pkgName}.rpm"  
76 -  
77 - requires("java-1.8.0")  
78 -  
79 - from("target/conf") {  
80 - include "${pkgName}.conf"  
81 - filter(ReplaceTokens, tokens: ['pkg.platform': 'rpm'])  
82 - fileType CONFIG | NOREPLACE  
83 - fileMode 0754  
84 - into "${pkgInstallFolder}/conf"  
85 - }  
86 -  
87 - preInstall file("${buildDir}/control/rpm/preinst")  
88 - postInstall file("${buildDir}/control/rpm/postinst")  
89 - preUninstall file("${buildDir}/control/rpm/prerm")  
90 - postUninstall file("${buildDir}/control/rpm/postrm")  
91 -  
92 - user pkgName  
93 - permissionGroup pkgName  
94 -  
95 - // Copy the system unit files  
96 - from("${buildDir}/control/${pkgName}.service") {  
97 - addParentDirs = false  
98 - fileMode 0644  
99 - into "/usr/lib/systemd/system"  
100 - }  
101 -  
102 - directory(pkgLogFolder, 0755)  
103 - link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml")  
104 - link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")  
105 -}  
106 -  
107 -// Same as the buildRpm task  
108 -buildDeb {  
109 -  
110 - arch = "all"  
111 -  
112 - archiveName = "${pkgName}.deb"  
113 -  
114 - requires("openjdk-8-jre").or("java8-runtime").or("oracle-java8-installer").or("openjdk-8-jre-headless")  
115 -  
116 - from("target/conf") {  
117 - include "${pkgName}.conf"  
118 - filter(ReplaceTokens, tokens: ['pkg.platform': 'deb'])  
119 - fileType CONFIG | NOREPLACE  
120 - fileMode 0754  
121 - into "${pkgInstallFolder}/conf"  
122 - }  
123 -  
124 - configurationFile("${pkgInstallFolder}/conf/${pkgName}.conf")  
125 - configurationFile("${pkgInstallFolder}/conf/${pkgName}.yml")  
126 - configurationFile("${pkgInstallFolder}/conf/logback.xml")  
127 -  
128 - preInstall file("${buildDir}/control/deb/preinst")  
129 - postInstall file("${buildDir}/control/deb/postinst")  
130 - preUninstall file("${buildDir}/control/deb/prerm")  
131 - postUninstall file("${buildDir}/control/deb/postrm")  
132 -  
133 - user pkgName  
134 - permissionGroup pkgName  
135 -  
136 - directory(pkgLogFolder, 0755)  
137 - link("/etc/init.d/${pkgName}", "${pkgInstallFolder}/bin/${pkgName}.jar")  
138 - link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml")  
139 - link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")  
140 -}  
@@ -33,10 +33,15 @@ @@ -33,10 +33,15 @@
33 <properties> 33 <properties>
34 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 34 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
35 <main.dir>${basedir}/../..</main.dir> 35 <main.dir>${basedir}/../..</main.dir>
  36 + <pkg.type>java</pkg.type>
  37 + <pkg.disabled>false</pkg.disabled>
  38 + <pkg.process-resources.phase>process-resources</pkg.process-resources.phase>
  39 + <pkg.package.phase>package</pkg.package.phase>
36 <pkg.name>tb-coap-transport</pkg.name> 40 <pkg.name>tb-coap-transport</pkg.name>
37 - <pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder>  
38 - <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder> 41 + <pkg.copyInstallScripts>false</pkg.copyInstallScripts>
39 <pkg.win.dist>${project.build.directory}/windows</pkg.win.dist> 42 <pkg.win.dist>${project.build.directory}/windows</pkg.win.dist>
  43 + <pkg.implementationTitle>ThingsBoard CoAP Transport Service</pkg.implementationTitle>
  44 + <pkg.mainClass>org.thingsboard.server.coap.ThingsboardCoapTransportApplication</pkg.mainClass>
40 </properties> 45 </properties>
41 46
42 <dependencies> 47 <dependencies>
@@ -87,244 +92,30 @@ @@ -87,244 +92,30 @@
87 <plugin> 92 <plugin>
88 <groupId>org.apache.maven.plugins</groupId> 93 <groupId>org.apache.maven.plugins</groupId>
89 <artifactId>maven-resources-plugin</artifactId> 94 <artifactId>maven-resources-plugin</artifactId>
90 - <executions>  
91 - <execution>  
92 - <id>copy-conf</id>  
93 - <phase>process-resources</phase>  
94 - <goals>  
95 - <goal>copy-resources</goal>  
96 - </goals>  
97 - <configuration>  
98 - <outputDirectory>${project.build.directory}/conf</outputDirectory>  
99 - <resources>  
100 - <resource>  
101 - <directory>src/main/resources</directory>  
102 - <excludes>  
103 - <exclude>logback.xml</exclude>  
104 - </excludes>  
105 - <filtering>false</filtering>  
106 - </resource>  
107 - </resources>  
108 - </configuration>  
109 - </execution>  
110 - <execution>  
111 - <id>copy-service-conf</id>  
112 - <phase>process-resources</phase>  
113 - <goals>  
114 - <goal>copy-resources</goal>  
115 - </goals>  
116 - <configuration>  
117 - <outputDirectory>${project.build.directory}/conf</outputDirectory>  
118 - <resources>  
119 - <resource>  
120 - <directory>src/main/conf</directory>  
121 - <filtering>true</filtering>  
122 - </resource>  
123 - </resources>  
124 - <filters>  
125 - <filter>src/main/filters/unix.properties</filter>  
126 - </filters>  
127 - </configuration>  
128 - </execution>  
129 - <execution>  
130 - <id>copy-win-conf</id>  
131 - <phase>process-resources</phase>  
132 - <goals>  
133 - <goal>copy-resources</goal>  
134 - </goals>  
135 - <configuration>  
136 - <outputDirectory>${pkg.win.dist}/conf</outputDirectory>  
137 - <resources>  
138 - <resource>  
139 - <directory>src/main/resources</directory>  
140 - <excludes>  
141 - <exclude>logback.xml</exclude>  
142 - </excludes>  
143 - <filtering>false</filtering>  
144 - </resource>  
145 - <resource>  
146 - <directory>src/main/conf</directory>  
147 - <excludes>  
148 - <exclude>tb-coap-transport.conf</exclude>  
149 - </excludes>  
150 - <filtering>true</filtering>  
151 - </resource>  
152 - </resources>  
153 - <filters>  
154 - <filter>src/main/filters/windows.properties</filter>  
155 - </filters>  
156 - </configuration>  
157 - </execution>  
158 - <execution>  
159 - <id>copy-control</id>  
160 - <phase>process-resources</phase>  
161 - <goals>  
162 - <goal>copy-resources</goal>  
163 - </goals>  
164 - <configuration>  
165 - <outputDirectory>${project.build.directory}/control</outputDirectory>  
166 - <resources>  
167 - <resource>  
168 - <directory>src/main/scripts/control</directory>  
169 - <filtering>true</filtering>  
170 - </resource>  
171 - </resources>  
172 - <filters>  
173 - <filter>src/main/filters/unix.properties</filter>  
174 - </filters>  
175 - </configuration>  
176 - </execution>  
177 - <execution>  
178 - <id>copy-windows-control</id>  
179 - <phase>process-resources</phase>  
180 - <goals>  
181 - <goal>copy-resources</goal>  
182 - </goals>  
183 - <configuration>  
184 - <outputDirectory>${pkg.win.dist}</outputDirectory>  
185 - <resources>  
186 - <resource>  
187 - <directory>src/main/scripts/windows</directory>  
188 - <filtering>true</filtering>  
189 - </resource>  
190 - </resources>  
191 - <filters>  
192 - <filter>src/main/filters/windows.properties</filter>  
193 - </filters>  
194 - </configuration>  
195 - </execution>  
196 - </executions>  
197 </plugin> 95 </plugin>
198 <plugin> 96 <plugin>
199 <groupId>org.apache.maven.plugins</groupId> 97 <groupId>org.apache.maven.plugins</groupId>
200 <artifactId>maven-dependency-plugin</artifactId> 98 <artifactId>maven-dependency-plugin</artifactId>
201 - <executions>  
202 - <execution>  
203 - <id>copy-winsw-service</id>  
204 - <phase>package</phase>  
205 - <goals>  
206 - <goal>copy</goal>  
207 - </goals>  
208 - <configuration>  
209 - <artifactItems>  
210 - <artifactItem>  
211 - <groupId>com.sun.winsw</groupId>  
212 - <artifactId>winsw</artifactId>  
213 - <classifier>bin</classifier>  
214 - <type>exe</type>  
215 - <destFileName>service.exe</destFileName>  
216 - </artifactItem>  
217 - </artifactItems>  
218 - <outputDirectory>${pkg.win.dist}</outputDirectory>  
219 - </configuration>  
220 - </execution>  
221 - </executions>  
222 </plugin> 99 </plugin>
223 <plugin> 100 <plugin>
224 <groupId>org.apache.maven.plugins</groupId> 101 <groupId>org.apache.maven.plugins</groupId>
225 <artifactId>maven-jar-plugin</artifactId> 102 <artifactId>maven-jar-plugin</artifactId>
226 - <configuration>  
227 - <excludes>  
228 - <exclude>**/logback.xml</exclude>  
229 - </excludes>  
230 - <archive>  
231 - <manifestEntries>  
232 - <Implementation-Title>ThingsBoard CoAP Transport Service</Implementation-Title>  
233 - <Implementation-Version>${project.version}</Implementation-Version>  
234 - </manifestEntries>  
235 - </archive>  
236 - </configuration>  
237 </plugin> 103 </plugin>
238 <plugin> 104 <plugin>
239 <groupId>org.springframework.boot</groupId> 105 <groupId>org.springframework.boot</groupId>
240 <artifactId>spring-boot-maven-plugin</artifactId> 106 <artifactId>spring-boot-maven-plugin</artifactId>
241 - <configuration>  
242 - <mainClass>org.thingsboard.server.coap.ThingsboardCoapTransportApplication</mainClass>  
243 - <classifier>boot</classifier>  
244 - <layout>ZIP</layout>  
245 - <executable>true</executable>  
246 - <excludeDevtools>true</excludeDevtools>  
247 - <embeddedLaunchScriptProperties>  
248 - <confFolder>${pkg.installFolder}/conf</confFolder>  
249 - <logFolder>${pkg.unixLogFolder}</logFolder>  
250 - <logFilename>${pkg.name}.out</logFilename>  
251 - <initInfoProvides>${pkg.name}</initInfoProvides>  
252 - </embeddedLaunchScriptProperties>  
253 - </configuration>  
254 - <executions>  
255 - <execution>  
256 - <goals>  
257 - <goal>repackage</goal>  
258 - </goals>  
259 - </execution>  
260 - </executions>  
261 </plugin> 107 </plugin>
262 <plugin> 108 <plugin>
263 <groupId>org.thingsboard</groupId> 109 <groupId>org.thingsboard</groupId>
264 <artifactId>gradle-maven-plugin</artifactId> 110 <artifactId>gradle-maven-plugin</artifactId>
265 - <configuration>  
266 - <tasks>  
267 - <task>build</task>  
268 - <task>buildDeb</task>  
269 - <task>buildRpm</task>  
270 - </tasks>  
271 - <args>  
272 - <arg>-PprojectBuildDir=${project.build.directory}</arg>  
273 - <arg>-PprojectVersion=${project.version}</arg>  
274 - <arg>-PmainJar=${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</arg>  
275 - <arg>-PpkgName=${pkg.name}</arg>  
276 - <arg>-PpkgInstallFolder=${pkg.installFolder}</arg>  
277 - <arg>-PpkgLogFolder=${pkg.unixLogFolder}</arg>  
278 - </args>  
279 - </configuration>  
280 - <executions>  
281 - <execution>  
282 - <phase>package</phase>  
283 - <goals>  
284 - <goal>invoke</goal>  
285 - </goals>  
286 - </execution>  
287 - </executions>  
288 </plugin> 111 </plugin>
289 <plugin> 112 <plugin>
290 <groupId>org.apache.maven.plugins</groupId> 113 <groupId>org.apache.maven.plugins</groupId>
291 <artifactId>maven-assembly-plugin</artifactId> 114 <artifactId>maven-assembly-plugin</artifactId>
292 - <configuration>  
293 - <finalName>${pkg.name}</finalName>  
294 - <descriptors>  
295 - <descriptor>src/main/assembly/windows.xml</descriptor>  
296 - </descriptors>  
297 - </configuration>  
298 - <executions>  
299 - <execution>  
300 - <id>assembly</id>  
301 - <phase>package</phase>  
302 - <goals>  
303 - <goal>single</goal>  
304 - </goals>  
305 - </execution>  
306 - </executions>  
307 </plugin> 115 </plugin>
308 <plugin> 116 <plugin>
309 <groupId>org.apache.maven.plugins</groupId> 117 <groupId>org.apache.maven.plugins</groupId>
310 <artifactId>maven-install-plugin</artifactId> 118 <artifactId>maven-install-plugin</artifactId>
311 - <configuration>  
312 - <file>${project.build.directory}/${pkg.name}.deb</file>  
313 - <artifactId>${project.artifactId}</artifactId>  
314 - <groupId>${project.groupId}</groupId>  
315 - <version>${project.version}</version>  
316 - <classifier>deb</classifier>  
317 - <packaging>deb</packaging>  
318 - </configuration>  
319 - <executions>  
320 - <execution>  
321 - <id>install-deb</id>  
322 - <phase>package</phase>  
323 - <goals>  
324 - <goal>install-file</goal>  
325 - </goals>  
326 - </execution>  
327 - </executions>  
328 </plugin> 119 </plugin>
329 </plugins> 120 </plugins>
330 </build> 121 </build>
1 -<!--  
2 -  
3 - Copyright © 2016-2020 The Thingsboard Authors  
4 -  
5 - Licensed under the Apache License, Version 2.0 (the "License");  
6 - you may not use this file except in compliance with the License.  
7 - You may obtain a copy of the License at  
8 -  
9 - http://www.apache.org/licenses/LICENSE-2.0  
10 -  
11 - Unless required by applicable law or agreed to in writing, software  
12 - distributed under the License is distributed on an "AS IS" BASIS,  
13 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
14 - See the License for the specific language governing permissions and  
15 - limitations under the License.  
16 -  
17 --->  
18 -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"  
19 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
20 - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">  
21 - <id>windows</id>  
22 -  
23 - <formats>  
24 - <format>zip</format>  
25 - </formats>  
26 -  
27 - <!-- Workaround to create logs directory -->  
28 - <fileSets>  
29 - <fileSet>  
30 - <directory>${pkg.win.dist}</directory>  
31 - <outputDirectory>logs</outputDirectory>  
32 - <excludes>  
33 - <exclude>*/**</exclude>  
34 - </excludes>  
35 - </fileSet>  
36 - <fileSet>  
37 - <directory>${pkg.win.dist}/conf</directory>  
38 - <outputDirectory>conf</outputDirectory>  
39 - <lineEnding>windows</lineEnding>  
40 - </fileSet>  
41 - </fileSets>  
42 -  
43 - <files>  
44 - <file>  
45 - <source>${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</source>  
46 - <outputDirectory>lib</outputDirectory>  
47 - <destName>${pkg.name}.jar</destName>  
48 - </file>  
49 - <file>  
50 - <source>${pkg.win.dist}/service.exe</source>  
51 - <outputDirectory/>  
52 - <destName>${pkg.name}.exe</destName>  
53 - </file>  
54 - <file>  
55 - <source>${pkg.win.dist}/service.xml</source>  
56 - <outputDirectory/>  
57 - <destName>${pkg.name}.xml</destName>  
58 - <lineEnding>windows</lineEnding>  
59 - </file>  
60 - <file>  
61 - <source>${pkg.win.dist}/install.bat</source>  
62 - <outputDirectory/>  
63 - <lineEnding>windows</lineEnding>  
64 - </file>  
65 - <file>  
66 - <source>${pkg.win.dist}/uninstall.bat</source>  
67 - <outputDirectory/>  
68 - <lineEnding>windows</lineEnding>  
69 - </file>  
70 - </files>  
71 -</assembly>  
1 -pkg.logFolder=${pkg.unixLogFolder}  
1 -pkg.logFolder=${BASE}\\logs  
2 -pkg.winWrapperLogFolder=%BASE%\\logs  
1 -#!/bin/sh  
2 -  
3 -chown -R ${pkg.user}: ${pkg.logFolder}  
4 -chown -R ${pkg.user}: ${pkg.installFolder}  
5 -update-rc.d ${pkg.name} defaults  
6 -  
1 -#!/bin/sh  
2 -  
3 -update-rc.d -f ${pkg.name} remove  
1 -#!/bin/sh  
2 -  
3 -if ! getent group ${pkg.user} >/dev/null; then  
4 - addgroup --system ${pkg.user}  
5 -fi  
6 -  
7 -if ! getent passwd ${pkg.user} >/dev/null; then  
8 - adduser --quiet \  
9 - --system \  
10 - --ingroup ${pkg.user} \  
11 - --quiet \  
12 - --disabled-login \  
13 - --disabled-password \  
14 - --home ${pkg.installFolder} \  
15 - --no-create-home \  
16 - -gecos "Thingsboard application" \  
17 - ${pkg.user}  
18 -fi  
1 -#!/bin/sh  
2 -  
3 -if [ -e /var/run/${pkg.name}/${pkg.name}.pid ]; then  
4 - service ${pkg.name} stop  
5 -fi  
1 -#!/bin/sh  
2 -  
3 -chown -R ${pkg.user}: ${pkg.logFolder}  
4 -chown -R ${pkg.user}: ${pkg.installFolder}  
5 -  
6 -if [ $1 -eq 1 ] ; then  
7 - # Initial installation  
8 - systemctl --no-reload enable ${pkg.name}.service >/dev/null 2>&1 || :  
9 -fi  
1 -#!/bin/sh  
2 -  
3 -if [ $1 -ge 1 ] ; then  
4 - # Package upgrade, not uninstall  
5 - systemctl try-restart ${pkg.name}.service >/dev/null 2>&1 || :  
6 -fi  
1 -#!/bin/sh  
2 -  
3 -getent group ${pkg.user} >/dev/null || groupadd -r ${pkg.user}  
4 -getent passwd ${pkg.user} >/dev/null || \  
5 -useradd -d ${pkg.installFolder} -g ${pkg.user} -M -r ${pkg.user} -s /sbin/nologin \  
6 --c "Thingsboard application"  
1 -#!/bin/sh  
2 -  
3 -if [ $1 -eq 0 ] ; then  
4 - # Package removal, not upgrade  
5 - systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :  
6 -fi  
1 -[Unit]  
2 -Description=${pkg.name}  
3 -After=syslog.target  
4 -  
5 -[Service]  
6 -User=${pkg.user}  
7 -ExecStart=${pkg.installFolder}/bin/${pkg.name}.jar  
8 -SuccessExitStatus=143  
9 -  
10 -[Install]  
11 -WantedBy=multi-user.target  
1 -@ECHO OFF  
2 -  
3 -setlocal ENABLEEXTENSIONS  
4 -  
5 -@ECHO Detecting Java version installed.  
6 -:CHECK_JAVA  
7 -for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j%%k"  
8 -@ECHO CurrentVersion %jver%  
9 -  
10 -if %jver% NEQ 18 GOTO JAVA_NOT_INSTALLED  
11 -  
12 -:JAVA_INSTALLED  
13 -  
14 -@ECHO Java 1.8 found!  
15 -@ECHO Installing ${pkg.name} ...  
16 -  
17 -"%BASE%"${pkg.name}.exe install  
18 -  
19 -@ECHO ${pkg.name} installed successfully!  
20 -  
21 -GOTO END  
22 -  
23 -:JAVA_NOT_INSTALLED  
24 -@ECHO Java 1.8 is not installed. Only Java 1.8 is supported  
25 -@ECHO Please go to https://adoptopenjdk.net/index.html and install Java 1.8. Then retry installation.  
26 -PAUSE  
27 -GOTO END  
28 -  
29 -:END  
30 -  
31 -  
1 -<service>  
2 - <id>${pkg.name}</id>  
3 - <name>${project.name}</name>  
4 - <description>${project.description}</description>  
5 - <workingdirectory>%BASE%\conf</workingdirectory>  
6 - <logpath>${pkg.winWrapperLogFolder}</logpath>  
7 - <logmode>rotate</logmode>  
8 - <env name="LOADER_PATH" value="%BASE%\conf" />  
9 - <executable>java</executable>  
10 - <startargument>-Xloggc:%BASE%\logs\gc.log</startargument>  
11 - <startargument>-XX:+HeapDumpOnOutOfMemoryError</startargument>  
12 - <startargument>-XX:+PrintGCDetails</startargument>  
13 - <startargument>-XX:+PrintGCDateStamps</startargument>  
14 - <startargument>-XX:+PrintHeapAtGC</startargument>  
15 - <startargument>-XX:+PrintTenuringDistribution</startargument>  
16 - <startargument>-XX:+PrintGCApplicationStoppedTime</startargument>  
17 - <startargument>-XX:+UseGCLogFileRotation</startargument>  
18 - <startargument>-XX:NumberOfGCLogFiles=10</startargument>  
19 - <startargument>-XX:GCLogFileSize=10M</startargument>  
20 - <startargument>-XX:-UseBiasedLocking</startargument>  
21 - <startargument>-XX:+UseTLAB</startargument>  
22 - <startargument>-XX:+ResizeTLAB</startargument>  
23 - <startargument>-XX:+PerfDisableSharedMem</startargument>  
24 - <startargument>-XX:+UseCondCardMark</startargument>  
25 - <startargument>-XX:CMSWaitDuration=10000</startargument>  
26 - <startargument>-XX:+UseParNewGC</startargument>  
27 - <startargument>-XX:+UseConcMarkSweepGC</startargument>  
28 - <startargument>-XX:+CMSParallelRemarkEnabled</startargument>  
29 - <startargument>-XX:+CMSParallelInitialMarkEnabled</startargument>  
30 - <startargument>-XX:+CMSEdenChunksRecordAlways</startargument>  
31 - <startargument>-XX:CMSInitiatingOccupancyFraction=75</startargument>  
32 - <startargument>-XX:+UseCMSInitiatingOccupancyOnly</startargument>  
33 - <startargument>-jar</startargument>  
34 - <startargument>%BASE%\lib\${pkg.name}.jar</startargument>  
35 -  
36 -</service>  
1 -@ECHO OFF  
2 -  
3 -@ECHO Stopping ${pkg.name} ...  
4 -net stop ${pkg.name}  
5 -  
6 -@ECHO Uninstalling ${pkg.name} ...  
7 -"%~dp0"${pkg.name}.exe uninstall  
8 -  
9 -@ECHO DONE.  
1 -/**  
2 - * Copyright © 2016-2020 The Thingsboard Authors  
3 - *  
4 - * Licensed under the Apache License, Version 2.0 (the "License");  
5 - * you may not use this file except in compliance with the License.  
6 - * You may obtain a copy of the License at  
7 - *  
8 - * http://www.apache.org/licenses/LICENSE-2.0  
9 - *  
10 - * Unless required by applicable law or agreed to in writing, software  
11 - * distributed under the License is distributed on an "AS IS" BASIS,  
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
13 - * See the License for the specific language governing permissions and  
14 - * limitations under the License.  
15 - */  
16 -import org.apache.tools.ant.filters.ReplaceTokens  
17 -  
18 -buildscript {  
19 - ext {  
20 - osPackageVersion = "3.8.0"  
21 - }  
22 - repositories {  
23 - jcenter()  
24 - }  
25 - dependencies {  
26 - classpath("com.netflix.nebula:gradle-ospackage-plugin:${osPackageVersion}")  
27 - }  
28 -}  
29 -  
30 -apply plugin: "nebula.ospackage"  
31 -  
32 -buildDir = projectBuildDir  
33 -version = projectVersion  
34 -distsDirName = "./"  
35 -  
36 -// OS Package plugin configuration  
37 -ospackage {  
38 - packageName = pkgName  
39 - version = "${project.version}"  
40 - release = 1  
41 - os = LINUX  
42 - type = BINARY  
43 -  
44 - into pkgInstallFolder  
45 -  
46 - user pkgName  
47 - permissionGroup pkgName  
48 -  
49 - // Copy the actual .jar file  
50 - from(mainJar) {  
51 - // Strip the version from the jar filename  
52 - rename { String fileName ->  
53 - "${pkgName}.jar"  
54 - }  
55 - fileMode 0500  
56 - into "bin"  
57 - }  
58 -  
59 - // Copy the config files  
60 - from("target/conf") {  
61 - exclude "${pkgName}.conf"  
62 - fileType CONFIG | NOREPLACE  
63 - fileMode 0754  
64 - into "conf"  
65 - }  
66 -  
67 -}  
68 -  
69 -// Configure our RPM build task  
70 -buildRpm {  
71 -  
72 - arch = NOARCH  
73 -  
74 - version = projectVersion.replace('-', '')  
75 - archiveName = "${pkgName}.rpm"  
76 -  
77 - requires("java-1.8.0")  
78 -  
79 - from("target/conf") {  
80 - include "${pkgName}.conf"  
81 - filter(ReplaceTokens, tokens: ['pkg.platform': 'rpm'])  
82 - fileType CONFIG | NOREPLACE  
83 - fileMode 0754  
84 - into "${pkgInstallFolder}/conf"  
85 - }  
86 -  
87 - preInstall file("${buildDir}/control/rpm/preinst")  
88 - postInstall file("${buildDir}/control/rpm/postinst")  
89 - preUninstall file("${buildDir}/control/rpm/prerm")  
90 - postUninstall file("${buildDir}/control/rpm/postrm")  
91 -  
92 - user pkgName  
93 - permissionGroup pkgName  
94 -  
95 - // Copy the system unit files  
96 - from("${buildDir}/control/${pkgName}.service") {  
97 - addParentDirs = false  
98 - fileMode 0644  
99 - into "/usr/lib/systemd/system"  
100 - }  
101 -  
102 - directory(pkgLogFolder, 0755)  
103 - link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml")  
104 - link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")  
105 -}  
106 -  
107 -// Same as the buildRpm task  
108 -buildDeb {  
109 -  
110 - arch = "all"  
111 -  
112 - archiveName = "${pkgName}.deb"  
113 -  
114 - requires("openjdk-8-jre").or("java8-runtime").or("oracle-java8-installer").or("openjdk-8-jre-headless")  
115 -  
116 - from("target/conf") {  
117 - include "${pkgName}.conf"  
118 - filter(ReplaceTokens, tokens: ['pkg.platform': 'deb'])  
119 - fileType CONFIG | NOREPLACE  
120 - fileMode 0754  
121 - into "${pkgInstallFolder}/conf"  
122 - }  
123 -  
124 - configurationFile("${pkgInstallFolder}/conf/${pkgName}.conf")  
125 - configurationFile("${pkgInstallFolder}/conf/${pkgName}.yml")  
126 - configurationFile("${pkgInstallFolder}/conf/logback.xml")  
127 -  
128 - preInstall file("${buildDir}/control/deb/preinst")  
129 - postInstall file("${buildDir}/control/deb/postinst")  
130 - preUninstall file("${buildDir}/control/deb/prerm")  
131 - postUninstall file("${buildDir}/control/deb/postrm")  
132 -  
133 - user pkgName  
134 - permissionGroup pkgName  
135 -  
136 - directory(pkgLogFolder, 0755)  
137 - link("/etc/init.d/${pkgName}", "${pkgInstallFolder}/bin/${pkgName}.jar")  
138 - link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml")  
139 - link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")  
140 -}  
@@ -33,10 +33,15 @@ @@ -33,10 +33,15 @@
33 <properties> 33 <properties>
34 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 34 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
35 <main.dir>${basedir}/../..</main.dir> 35 <main.dir>${basedir}/../..</main.dir>
  36 + <pkg.type>java</pkg.type>
  37 + <pkg.disabled>false</pkg.disabled>
  38 + <pkg.process-resources.phase>process-resources</pkg.process-resources.phase>
  39 + <pkg.package.phase>package</pkg.package.phase>
36 <pkg.name>tb-http-transport</pkg.name> 40 <pkg.name>tb-http-transport</pkg.name>
37 - <pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder>  
38 - <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder> 41 + <pkg.copyInstallScripts>false</pkg.copyInstallScripts>
39 <pkg.win.dist>${project.build.directory}/windows</pkg.win.dist> 42 <pkg.win.dist>${project.build.directory}/windows</pkg.win.dist>
  43 + <pkg.implementationTitle>ThingsBoard HTTP Transport Service</pkg.implementationTitle>
  44 + <pkg.mainClass>org.thingsboard.server.http.ThingsboardHttpTransportApplication</pkg.mainClass>
40 </properties> 45 </properties>
41 46
42 <dependencies> 47 <dependencies>
@@ -87,244 +92,30 @@ @@ -87,244 +92,30 @@
87 <plugin> 92 <plugin>
88 <groupId>org.apache.maven.plugins</groupId> 93 <groupId>org.apache.maven.plugins</groupId>
89 <artifactId>maven-resources-plugin</artifactId> 94 <artifactId>maven-resources-plugin</artifactId>
90 - <executions>  
91 - <execution>  
92 - <id>copy-conf</id>  
93 - <phase>process-resources</phase>  
94 - <goals>  
95 - <goal>copy-resources</goal>  
96 - </goals>  
97 - <configuration>  
98 - <outputDirectory>${project.build.directory}/conf</outputDirectory>  
99 - <resources>  
100 - <resource>  
101 - <directory>src/main/resources</directory>  
102 - <excludes>  
103 - <exclude>logback.xml</exclude>  
104 - </excludes>  
105 - <filtering>false</filtering>  
106 - </resource>  
107 - </resources>  
108 - </configuration>  
109 - </execution>  
110 - <execution>  
111 - <id>copy-service-conf</id>  
112 - <phase>process-resources</phase>  
113 - <goals>  
114 - <goal>copy-resources</goal>  
115 - </goals>  
116 - <configuration>  
117 - <outputDirectory>${project.build.directory}/conf</outputDirectory>  
118 - <resources>  
119 - <resource>  
120 - <directory>src/main/conf</directory>  
121 - <filtering>true</filtering>  
122 - </resource>  
123 - </resources>  
124 - <filters>  
125 - <filter>src/main/filters/unix.properties</filter>  
126 - </filters>  
127 - </configuration>  
128 - </execution>  
129 - <execution>  
130 - <id>copy-win-conf</id>  
131 - <phase>process-resources</phase>  
132 - <goals>  
133 - <goal>copy-resources</goal>  
134 - </goals>  
135 - <configuration>  
136 - <outputDirectory>${pkg.win.dist}/conf</outputDirectory>  
137 - <resources>  
138 - <resource>  
139 - <directory>src/main/resources</directory>  
140 - <excludes>  
141 - <exclude>logback.xml</exclude>  
142 - </excludes>  
143 - <filtering>false</filtering>  
144 - </resource>  
145 - <resource>  
146 - <directory>src/main/conf</directory>  
147 - <excludes>  
148 - <exclude>tb-http-transport.conf</exclude>  
149 - </excludes>  
150 - <filtering>true</filtering>  
151 - </resource>  
152 - </resources>  
153 - <filters>  
154 - <filter>src/main/filters/windows.properties</filter>  
155 - </filters>  
156 - </configuration>  
157 - </execution>  
158 - <execution>  
159 - <id>copy-control</id>  
160 - <phase>process-resources</phase>  
161 - <goals>  
162 - <goal>copy-resources</goal>  
163 - </goals>  
164 - <configuration>  
165 - <outputDirectory>${project.build.directory}/control</outputDirectory>  
166 - <resources>  
167 - <resource>  
168 - <directory>src/main/scripts/control</directory>  
169 - <filtering>true</filtering>  
170 - </resource>  
171 - </resources>  
172 - <filters>  
173 - <filter>src/main/filters/unix.properties</filter>  
174 - </filters>  
175 - </configuration>  
176 - </execution>  
177 - <execution>  
178 - <id>copy-windows-control</id>  
179 - <phase>process-resources</phase>  
180 - <goals>  
181 - <goal>copy-resources</goal>  
182 - </goals>  
183 - <configuration>  
184 - <outputDirectory>${pkg.win.dist}</outputDirectory>  
185 - <resources>  
186 - <resource>  
187 - <directory>src/main/scripts/windows</directory>  
188 - <filtering>true</filtering>  
189 - </resource>  
190 - </resources>  
191 - <filters>  
192 - <filter>src/main/filters/windows.properties</filter>  
193 - </filters>  
194 - </configuration>  
195 - </execution>  
196 - </executions>  
197 </plugin> 95 </plugin>
198 <plugin> 96 <plugin>
199 <groupId>org.apache.maven.plugins</groupId> 97 <groupId>org.apache.maven.plugins</groupId>
200 <artifactId>maven-dependency-plugin</artifactId> 98 <artifactId>maven-dependency-plugin</artifactId>
201 - <executions>  
202 - <execution>  
203 - <id>copy-winsw-service</id>  
204 - <phase>package</phase>  
205 - <goals>  
206 - <goal>copy</goal>  
207 - </goals>  
208 - <configuration>  
209 - <artifactItems>  
210 - <artifactItem>  
211 - <groupId>com.sun.winsw</groupId>  
212 - <artifactId>winsw</artifactId>  
213 - <classifier>bin</classifier>  
214 - <type>exe</type>  
215 - <destFileName>service.exe</destFileName>  
216 - </artifactItem>  
217 - </artifactItems>  
218 - <outputDirectory>${pkg.win.dist}</outputDirectory>  
219 - </configuration>  
220 - </execution>  
221 - </executions>  
222 </plugin> 99 </plugin>
223 <plugin> 100 <plugin>
224 <groupId>org.apache.maven.plugins</groupId> 101 <groupId>org.apache.maven.plugins</groupId>
225 <artifactId>maven-jar-plugin</artifactId> 102 <artifactId>maven-jar-plugin</artifactId>
226 - <configuration>  
227 - <excludes>  
228 - <exclude>**/logback.xml</exclude>  
229 - </excludes>  
230 - <archive>  
231 - <manifestEntries>  
232 - <Implementation-Title>ThingsBoard HTTP Transport Service</Implementation-Title>  
233 - <Implementation-Version>${project.version}</Implementation-Version>  
234 - </manifestEntries>  
235 - </archive>  
236 - </configuration>  
237 </plugin> 103 </plugin>
238 <plugin> 104 <plugin>
239 <groupId>org.springframework.boot</groupId> 105 <groupId>org.springframework.boot</groupId>
240 <artifactId>spring-boot-maven-plugin</artifactId> 106 <artifactId>spring-boot-maven-plugin</artifactId>
241 - <configuration>  
242 - <mainClass>org.thingsboard.server.http.ThingsboardHttpTransportApplication</mainClass>  
243 - <classifier>boot</classifier>  
244 - <layout>ZIP</layout>  
245 - <executable>true</executable>  
246 - <excludeDevtools>true</excludeDevtools>  
247 - <embeddedLaunchScriptProperties>  
248 - <confFolder>${pkg.installFolder}/conf</confFolder>  
249 - <logFolder>${pkg.unixLogFolder}</logFolder>  
250 - <logFilename>${pkg.name}.out</logFilename>  
251 - <initInfoProvides>${pkg.name}</initInfoProvides>  
252 - </embeddedLaunchScriptProperties>  
253 - </configuration>  
254 - <executions>  
255 - <execution>  
256 - <goals>  
257 - <goal>repackage</goal>  
258 - </goals>  
259 - </execution>  
260 - </executions>  
261 </plugin> 107 </plugin>
262 <plugin> 108 <plugin>
263 <groupId>org.thingsboard</groupId> 109 <groupId>org.thingsboard</groupId>
264 <artifactId>gradle-maven-plugin</artifactId> 110 <artifactId>gradle-maven-plugin</artifactId>
265 - <configuration>  
266 - <tasks>  
267 - <task>build</task>  
268 - <task>buildDeb</task>  
269 - <task>buildRpm</task>  
270 - </tasks>  
271 - <args>  
272 - <arg>-PprojectBuildDir=${project.build.directory}</arg>  
273 - <arg>-PprojectVersion=${project.version}</arg>  
274 - <arg>-PmainJar=${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</arg>  
275 - <arg>-PpkgName=${pkg.name}</arg>  
276 - <arg>-PpkgInstallFolder=${pkg.installFolder}</arg>  
277 - <arg>-PpkgLogFolder=${pkg.unixLogFolder}</arg>  
278 - </args>  
279 - </configuration>  
280 - <executions>  
281 - <execution>  
282 - <phase>package</phase>  
283 - <goals>  
284 - <goal>invoke</goal>  
285 - </goals>  
286 - </execution>  
287 - </executions>  
288 </plugin> 111 </plugin>
289 <plugin> 112 <plugin>
290 <groupId>org.apache.maven.plugins</groupId> 113 <groupId>org.apache.maven.plugins</groupId>
291 <artifactId>maven-assembly-plugin</artifactId> 114 <artifactId>maven-assembly-plugin</artifactId>
292 - <configuration>  
293 - <finalName>${pkg.name}</finalName>  
294 - <descriptors>  
295 - <descriptor>src/main/assembly/windows.xml</descriptor>  
296 - </descriptors>  
297 - </configuration>  
298 - <executions>  
299 - <execution>  
300 - <id>assembly</id>  
301 - <phase>package</phase>  
302 - <goals>  
303 - <goal>single</goal>  
304 - </goals>  
305 - </execution>  
306 - </executions>  
307 </plugin> 115 </plugin>
308 <plugin> 116 <plugin>
309 <groupId>org.apache.maven.plugins</groupId> 117 <groupId>org.apache.maven.plugins</groupId>
310 <artifactId>maven-install-plugin</artifactId> 118 <artifactId>maven-install-plugin</artifactId>
311 - <configuration>  
312 - <file>${project.build.directory}/${pkg.name}.deb</file>  
313 - <artifactId>${project.artifactId}</artifactId>  
314 - <groupId>${project.groupId}</groupId>  
315 - <version>${project.version}</version>  
316 - <classifier>deb</classifier>  
317 - <packaging>deb</packaging>  
318 - </configuration>  
319 - <executions>  
320 - <execution>  
321 - <id>install-deb</id>  
322 - <phase>package</phase>  
323 - <goals>  
324 - <goal>install-file</goal>  
325 - </goals>  
326 - </execution>  
327 - </executions>  
328 </plugin> 119 </plugin>
329 </plugins> 120 </plugins>
330 </build> 121 </build>
1 -<!--  
2 -  
3 - Copyright © 2016-2020 The Thingsboard Authors  
4 -  
5 - Licensed under the Apache License, Version 2.0 (the "License");  
6 - you may not use this file except in compliance with the License.  
7 - You may obtain a copy of the License at  
8 -  
9 - http://www.apache.org/licenses/LICENSE-2.0  
10 -  
11 - Unless required by applicable law or agreed to in writing, software  
12 - distributed under the License is distributed on an "AS IS" BASIS,  
13 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
14 - See the License for the specific language governing permissions and  
15 - limitations under the License.  
16 -  
17 --->  
18 -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"  
19 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
20 - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">  
21 - <id>windows</id>  
22 -  
23 - <formats>  
24 - <format>zip</format>  
25 - </formats>  
26 -  
27 - <!-- Workaround to create logs directory -->  
28 - <fileSets>  
29 - <fileSet>  
30 - <directory>${pkg.win.dist}</directory>  
31 - <outputDirectory>logs</outputDirectory>  
32 - <excludes>  
33 - <exclude>*/**</exclude>  
34 - </excludes>  
35 - </fileSet>  
36 - <fileSet>  
37 - <directory>${pkg.win.dist}/conf</directory>  
38 - <outputDirectory>conf</outputDirectory>  
39 - <lineEnding>windows</lineEnding>  
40 - </fileSet>  
41 - </fileSets>  
42 -  
43 - <files>  
44 - <file>  
45 - <source>${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</source>  
46 - <outputDirectory>lib</outputDirectory>  
47 - <destName>${pkg.name}.jar</destName>  
48 - </file>  
49 - <file>  
50 - <source>${pkg.win.dist}/service.exe</source>  
51 - <outputDirectory/>  
52 - <destName>${pkg.name}.exe</destName>  
53 - </file>  
54 - <file>  
55 - <source>${pkg.win.dist}/service.xml</source>  
56 - <outputDirectory/>  
57 - <destName>${pkg.name}.xml</destName>  
58 - <lineEnding>windows</lineEnding>  
59 - </file>  
60 - <file>  
61 - <source>${pkg.win.dist}/install.bat</source>  
62 - <outputDirectory/>  
63 - <lineEnding>windows</lineEnding>  
64 - </file>  
65 - <file>  
66 - <source>${pkg.win.dist}/uninstall.bat</source>  
67 - <outputDirectory/>  
68 - <lineEnding>windows</lineEnding>  
69 - </file>  
70 - </files>  
71 -</assembly>  
1 -pkg.logFolder=${pkg.unixLogFolder}  
1 -pkg.logFolder=${BASE}\\logs  
2 -pkg.winWrapperLogFolder=%BASE%\\logs  
1 -#!/bin/sh  
2 -  
3 -chown -R ${pkg.user}: ${pkg.logFolder}  
4 -chown -R ${pkg.user}: ${pkg.installFolder}  
5 -update-rc.d ${pkg.name} defaults  
6 -  
1 -#!/bin/sh  
2 -  
3 -update-rc.d -f ${pkg.name} remove  
1 -#!/bin/sh  
2 -  
3 -if ! getent group ${pkg.user} >/dev/null; then  
4 - addgroup --system ${pkg.user}  
5 -fi  
6 -  
7 -if ! getent passwd ${pkg.user} >/dev/null; then  
8 - adduser --quiet \  
9 - --system \  
10 - --ingroup ${pkg.user} \  
11 - --quiet \  
12 - --disabled-login \  
13 - --disabled-password \  
14 - --home ${pkg.installFolder} \  
15 - --no-create-home \  
16 - -gecos "Thingsboard application" \  
17 - ${pkg.user}  
18 -fi  
1 -#!/bin/sh  
2 -  
3 -if [ -e /var/run/${pkg.name}/${pkg.name}.pid ]; then  
4 - service ${pkg.name} stop  
5 -fi  
1 -#!/bin/sh  
2 -  
3 -chown -R ${pkg.user}: ${pkg.logFolder}  
4 -chown -R ${pkg.user}: ${pkg.installFolder}  
5 -  
6 -if [ $1 -eq 1 ] ; then  
7 - # Initial installation  
8 - systemctl --no-reload enable ${pkg.name}.service >/dev/null 2>&1 || :  
9 -fi  
1 -#!/bin/sh  
2 -  
3 -if [ $1 -ge 1 ] ; then  
4 - # Package upgrade, not uninstall  
5 - systemctl try-restart ${pkg.name}.service >/dev/null 2>&1 || :  
6 -fi  
1 -#!/bin/sh  
2 -  
3 -getent group ${pkg.user} >/dev/null || groupadd -r ${pkg.user}  
4 -getent passwd ${pkg.user} >/dev/null || \  
5 -useradd -d ${pkg.installFolder} -g ${pkg.user} -M -r ${pkg.user} -s /sbin/nologin \  
6 --c "Thingsboard application"  
1 -#!/bin/sh  
2 -  
3 -if [ $1 -eq 0 ] ; then  
4 - # Package removal, not upgrade  
5 - systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :  
6 -fi  
1 -[Unit]  
2 -Description=${pkg.name}  
3 -After=syslog.target  
4 -  
5 -[Service]  
6 -User=${pkg.user}  
7 -ExecStart=${pkg.installFolder}/bin/${pkg.name}.jar  
8 -SuccessExitStatus=143  
9 -  
10 -[Install]  
11 -WantedBy=multi-user.target  
1 -@ECHO OFF  
2 -  
3 -setlocal ENABLEEXTENSIONS  
4 -  
5 -@ECHO Detecting Java version installed.  
6 -:CHECK_JAVA  
7 -for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j%%k"  
8 -@ECHO CurrentVersion %jver%  
9 -  
10 -if %jver% NEQ 18 GOTO JAVA_NOT_INSTALLED  
11 -  
12 -:JAVA_INSTALLED  
13 -  
14 -@ECHO Java 1.8 found!  
15 -@ECHO Installing ${pkg.name} ...  
16 -  
17 -"%BASE%"${pkg.name}.exe install  
18 -  
19 -@ECHO ${pkg.name} installed successfully!  
20 -  
21 -GOTO END  
22 -  
23 -:JAVA_NOT_INSTALLED  
24 -@ECHO Java 1.8 is not installed. Only Java 1.8 is supported  
25 -@ECHO Please go to https://adoptopenjdk.net/index.html and install Java 1.8. Then retry installation.  
26 -PAUSE  
27 -GOTO END  
28 -  
29 -:END  
30 -  
31 -  
1 -<service>  
2 - <id>${pkg.name}</id>  
3 - <name>${project.name}</name>  
4 - <description>${project.description}</description>  
5 - <workingdirectory>%BASE%\conf</workingdirectory>  
6 - <logpath>${pkg.winWrapperLogFolder}</logpath>  
7 - <logmode>rotate</logmode>  
8 - <env name="LOADER_PATH" value="%BASE%\conf" />  
9 - <executable>java</executable>  
10 - <startargument>-Xloggc:%BASE%\logs\gc.log</startargument>  
11 - <startargument>-XX:+HeapDumpOnOutOfMemoryError</startargument>  
12 - <startargument>-XX:+PrintGCDetails</startargument>  
13 - <startargument>-XX:+PrintGCDateStamps</startargument>  
14 - <startargument>-XX:+PrintHeapAtGC</startargument>  
15 - <startargument>-XX:+PrintTenuringDistribution</startargument>  
16 - <startargument>-XX:+PrintGCApplicationStoppedTime</startargument>  
17 - <startargument>-XX:+UseGCLogFileRotation</startargument>  
18 - <startargument>-XX:NumberOfGCLogFiles=10</startargument>  
19 - <startargument>-XX:GCLogFileSize=10M</startargument>  
20 - <startargument>-XX:-UseBiasedLocking</startargument>  
21 - <startargument>-XX:+UseTLAB</startargument>  
22 - <startargument>-XX:+ResizeTLAB</startargument>  
23 - <startargument>-XX:+PerfDisableSharedMem</startargument>  
24 - <startargument>-XX:+UseCondCardMark</startargument>  
25 - <startargument>-XX:CMSWaitDuration=10000</startargument>  
26 - <startargument>-XX:+UseParNewGC</startargument>  
27 - <startargument>-XX:+UseConcMarkSweepGC</startargument>  
28 - <startargument>-XX:+CMSParallelRemarkEnabled</startargument>  
29 - <startargument>-XX:+CMSParallelInitialMarkEnabled</startargument>  
30 - <startargument>-XX:+CMSEdenChunksRecordAlways</startargument>  
31 - <startargument>-XX:CMSInitiatingOccupancyFraction=75</startargument>  
32 - <startargument>-XX:+UseCMSInitiatingOccupancyOnly</startargument>  
33 - <startargument>-jar</startargument>  
34 - <startargument>%BASE%\lib\${pkg.name}.jar</startargument>  
35 -  
36 -</service>  
1 -@ECHO OFF  
2 -  
3 -@ECHO Stopping ${pkg.name} ...  
4 -net stop ${pkg.name}  
5 -  
6 -@ECHO Uninstalling ${pkg.name} ...  
7 -"%~dp0"${pkg.name}.exe uninstall  
8 -  
9 -@ECHO DONE.  
1 -/**  
2 - * Copyright © 2016-2020 The Thingsboard Authors  
3 - *  
4 - * Licensed under the Apache License, Version 2.0 (the "License");  
5 - * you may not use this file except in compliance with the License.  
6 - * You may obtain a copy of the License at  
7 - *  
8 - * http://www.apache.org/licenses/LICENSE-2.0  
9 - *  
10 - * Unless required by applicable law or agreed to in writing, software  
11 - * distributed under the License is distributed on an "AS IS" BASIS,  
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
13 - * See the License for the specific language governing permissions and  
14 - * limitations under the License.  
15 - */  
16 -import org.apache.tools.ant.filters.ReplaceTokens  
17 -  
18 -buildscript {  
19 - ext {  
20 - osPackageVersion = "3.8.0"  
21 - }  
22 - repositories {  
23 - jcenter()  
24 - }  
25 - dependencies {  
26 - classpath("com.netflix.nebula:gradle-ospackage-plugin:${osPackageVersion}")  
27 - }  
28 -}  
29 -  
30 -apply plugin: "nebula.ospackage"  
31 -  
32 -buildDir = projectBuildDir  
33 -version = projectVersion  
34 -distsDirName = "./"  
35 -  
36 -// OS Package plugin configuration  
37 -ospackage {  
38 - packageName = pkgName  
39 - version = "${project.version}"  
40 - release = 1  
41 - os = LINUX  
42 - type = BINARY  
43 -  
44 - into pkgInstallFolder  
45 -  
46 - user pkgName  
47 - permissionGroup pkgName  
48 -  
49 - // Copy the actual .jar file  
50 - from(mainJar) {  
51 - // Strip the version from the jar filename  
52 - rename { String fileName ->  
53 - "${pkgName}.jar"  
54 - }  
55 - fileMode 0500  
56 - into "bin"  
57 - }  
58 -  
59 - // Copy the config files  
60 - from("target/conf") {  
61 - exclude "${pkgName}.conf"  
62 - fileType CONFIG | NOREPLACE  
63 - fileMode 0754  
64 - into "conf"  
65 - }  
66 -  
67 -}  
68 -  
69 -// Configure our RPM build task  
70 -buildRpm {  
71 -  
72 - arch = NOARCH  
73 -  
74 - version = projectVersion.replace('-', '')  
75 - archiveName = "${pkgName}.rpm"  
76 -  
77 - requires("java-1.8.0")  
78 -  
79 - from("target/conf") {  
80 - include "${pkgName}.conf"  
81 - filter(ReplaceTokens, tokens: ['pkg.platform': 'rpm'])  
82 - fileType CONFIG | NOREPLACE  
83 - fileMode 0754  
84 - into "${pkgInstallFolder}/conf"  
85 - }  
86 -  
87 - preInstall file("${buildDir}/control/rpm/preinst")  
88 - postInstall file("${buildDir}/control/rpm/postinst")  
89 - preUninstall file("${buildDir}/control/rpm/prerm")  
90 - postUninstall file("${buildDir}/control/rpm/postrm")  
91 -  
92 - user pkgName  
93 - permissionGroup pkgName  
94 -  
95 - // Copy the system unit files  
96 - from("${buildDir}/control/${pkgName}.service") {  
97 - addParentDirs = false  
98 - fileMode 0644  
99 - into "/usr/lib/systemd/system"  
100 - }  
101 -  
102 - directory(pkgLogFolder, 0755)  
103 - link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml")  
104 - link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")  
105 -}  
106 -  
107 -// Same as the buildRpm task  
108 -buildDeb {  
109 -  
110 - arch = "all"  
111 -  
112 - archiveName = "${pkgName}.deb"  
113 -  
114 - requires("openjdk-8-jre").or("java8-runtime").or("oracle-java8-installer").or("openjdk-8-jre-headless")  
115 -  
116 - from("target/conf") {  
117 - include "${pkgName}.conf"  
118 - filter(ReplaceTokens, tokens: ['pkg.platform': 'deb'])  
119 - fileType CONFIG | NOREPLACE  
120 - fileMode 0754  
121 - into "${pkgInstallFolder}/conf"  
122 - }  
123 -  
124 - configurationFile("${pkgInstallFolder}/conf/${pkgName}.conf")  
125 - configurationFile("${pkgInstallFolder}/conf/${pkgName}.yml")  
126 - configurationFile("${pkgInstallFolder}/conf/logback.xml")  
127 -  
128 - preInstall file("${buildDir}/control/deb/preinst")  
129 - postInstall file("${buildDir}/control/deb/postinst")  
130 - preUninstall file("${buildDir}/control/deb/prerm")  
131 - postUninstall file("${buildDir}/control/deb/postrm")  
132 -  
133 - user pkgName  
134 - permissionGroup pkgName  
135 -  
136 - directory(pkgLogFolder, 0755)  
137 - link("/etc/init.d/${pkgName}", "${pkgInstallFolder}/bin/${pkgName}.jar")  
138 - link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml")  
139 - link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")  
140 -}  
@@ -33,10 +33,15 @@ @@ -33,10 +33,15 @@
33 <properties> 33 <properties>
34 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 34 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
35 <main.dir>${basedir}/../..</main.dir> 35 <main.dir>${basedir}/../..</main.dir>
  36 + <pkg.type>java</pkg.type>
  37 + <pkg.disabled>false</pkg.disabled>
  38 + <pkg.process-resources.phase>process-resources</pkg.process-resources.phase>
  39 + <pkg.package.phase>package</pkg.package.phase>
36 <pkg.name>tb-mqtt-transport</pkg.name> 40 <pkg.name>tb-mqtt-transport</pkg.name>
37 - <pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder>  
38 - <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder> 41 + <pkg.copyInstallScripts>false</pkg.copyInstallScripts>
39 <pkg.win.dist>${project.build.directory}/windows</pkg.win.dist> 42 <pkg.win.dist>${project.build.directory}/windows</pkg.win.dist>
  43 + <pkg.implementationTitle>ThingsBoard MQTT Transport Service</pkg.implementationTitle>
  44 + <pkg.mainClass>org.thingsboard.server.mqtt.ThingsboardMqttTransportApplication</pkg.mainClass>
40 </properties> 45 </properties>
41 46
42 <dependencies> 47 <dependencies>
@@ -87,244 +92,30 @@ @@ -87,244 +92,30 @@
87 <plugin> 92 <plugin>
88 <groupId>org.apache.maven.plugins</groupId> 93 <groupId>org.apache.maven.plugins</groupId>
89 <artifactId>maven-resources-plugin</artifactId> 94 <artifactId>maven-resources-plugin</artifactId>
90 - <executions>  
91 - <execution>  
92 - <id>copy-conf</id>  
93 - <phase>process-resources</phase>  
94 - <goals>  
95 - <goal>copy-resources</goal>  
96 - </goals>  
97 - <configuration>  
98 - <outputDirectory>${project.build.directory}/conf</outputDirectory>  
99 - <resources>  
100 - <resource>  
101 - <directory>src/main/resources</directory>  
102 - <excludes>  
103 - <exclude>logback.xml</exclude>  
104 - </excludes>  
105 - <filtering>false</filtering>  
106 - </resource>  
107 - </resources>  
108 - </configuration>  
109 - </execution>  
110 - <execution>  
111 - <id>copy-service-conf</id>  
112 - <phase>process-resources</phase>  
113 - <goals>  
114 - <goal>copy-resources</goal>  
115 - </goals>  
116 - <configuration>  
117 - <outputDirectory>${project.build.directory}/conf</outputDirectory>  
118 - <resources>  
119 - <resource>  
120 - <directory>src/main/conf</directory>  
121 - <filtering>true</filtering>  
122 - </resource>  
123 - </resources>  
124 - <filters>  
125 - <filter>src/main/filters/unix.properties</filter>  
126 - </filters>  
127 - </configuration>  
128 - </execution>  
129 - <execution>  
130 - <id>copy-win-conf</id>  
131 - <phase>process-resources</phase>  
132 - <goals>  
133 - <goal>copy-resources</goal>  
134 - </goals>  
135 - <configuration>  
136 - <outputDirectory>${pkg.win.dist}/conf</outputDirectory>  
137 - <resources>  
138 - <resource>  
139 - <directory>src/main/resources</directory>  
140 - <excludes>  
141 - <exclude>logback.xml</exclude>  
142 - </excludes>  
143 - <filtering>false</filtering>  
144 - </resource>  
145 - <resource>  
146 - <directory>src/main/conf</directory>  
147 - <excludes>  
148 - <exclude>tb-mqtt-transport.conf</exclude>  
149 - </excludes>  
150 - <filtering>true</filtering>  
151 - </resource>  
152 - </resources>  
153 - <filters>  
154 - <filter>src/main/filters/windows.properties</filter>  
155 - </filters>  
156 - </configuration>  
157 - </execution>  
158 - <execution>  
159 - <id>copy-control</id>  
160 - <phase>process-resources</phase>  
161 - <goals>  
162 - <goal>copy-resources</goal>  
163 - </goals>  
164 - <configuration>  
165 - <outputDirectory>${project.build.directory}/control</outputDirectory>  
166 - <resources>  
167 - <resource>  
168 - <directory>src/main/scripts/control</directory>  
169 - <filtering>true</filtering>  
170 - </resource>  
171 - </resources>  
172 - <filters>  
173 - <filter>src/main/filters/unix.properties</filter>  
174 - </filters>  
175 - </configuration>  
176 - </execution>  
177 - <execution>  
178 - <id>copy-windows-control</id>  
179 - <phase>process-resources</phase>  
180 - <goals>  
181 - <goal>copy-resources</goal>  
182 - </goals>  
183 - <configuration>  
184 - <outputDirectory>${pkg.win.dist}</outputDirectory>  
185 - <resources>  
186 - <resource>  
187 - <directory>src/main/scripts/windows</directory>  
188 - <filtering>true</filtering>  
189 - </resource>  
190 - </resources>  
191 - <filters>  
192 - <filter>src/main/filters/windows.properties</filter>  
193 - </filters>  
194 - </configuration>  
195 - </execution>  
196 - </executions>  
197 </plugin> 95 </plugin>
198 <plugin> 96 <plugin>
199 <groupId>org.apache.maven.plugins</groupId> 97 <groupId>org.apache.maven.plugins</groupId>
200 <artifactId>maven-dependency-plugin</artifactId> 98 <artifactId>maven-dependency-plugin</artifactId>
201 - <executions>  
202 - <execution>  
203 - <id>copy-winsw-service</id>  
204 - <phase>package</phase>  
205 - <goals>  
206 - <goal>copy</goal>  
207 - </goals>  
208 - <configuration>  
209 - <artifactItems>  
210 - <artifactItem>  
211 - <groupId>com.sun.winsw</groupId>  
212 - <artifactId>winsw</artifactId>  
213 - <classifier>bin</classifier>  
214 - <type>exe</type>  
215 - <destFileName>service.exe</destFileName>  
216 - </artifactItem>  
217 - </artifactItems>  
218 - <outputDirectory>${pkg.win.dist}</outputDirectory>  
219 - </configuration>  
220 - </execution>  
221 - </executions>  
222 </plugin> 99 </plugin>
223 <plugin> 100 <plugin>
224 <groupId>org.apache.maven.plugins</groupId> 101 <groupId>org.apache.maven.plugins</groupId>
225 <artifactId>maven-jar-plugin</artifactId> 102 <artifactId>maven-jar-plugin</artifactId>
226 - <configuration>  
227 - <excludes>  
228 - <exclude>**/logback.xml</exclude>  
229 - </excludes>  
230 - <archive>  
231 - <manifestEntries>  
232 - <Implementation-Title>ThingsBoard MQTT Transport Service</Implementation-Title>  
233 - <Implementation-Version>${project.version}</Implementation-Version>  
234 - </manifestEntries>  
235 - </archive>  
236 - </configuration>  
237 </plugin> 103 </plugin>
238 <plugin> 104 <plugin>
239 <groupId>org.springframework.boot</groupId> 105 <groupId>org.springframework.boot</groupId>
240 <artifactId>spring-boot-maven-plugin</artifactId> 106 <artifactId>spring-boot-maven-plugin</artifactId>
241 - <configuration>  
242 - <mainClass>org.thingsboard.server.mqtt.ThingsboardMqttTransportApplication</mainClass>  
243 - <classifier>boot</classifier>  
244 - <layout>ZIP</layout>  
245 - <executable>true</executable>  
246 - <excludeDevtools>true</excludeDevtools>  
247 - <embeddedLaunchScriptProperties>  
248 - <confFolder>${pkg.installFolder}/conf</confFolder>  
249 - <logFolder>${pkg.unixLogFolder}</logFolder>  
250 - <logFilename>${pkg.name}.out</logFilename>  
251 - <initInfoProvides>${pkg.name}</initInfoProvides>  
252 - </embeddedLaunchScriptProperties>  
253 - </configuration>  
254 - <executions>  
255 - <execution>  
256 - <goals>  
257 - <goal>repackage</goal>  
258 - </goals>  
259 - </execution>  
260 - </executions>  
261 </plugin> 107 </plugin>
262 <plugin> 108 <plugin>
263 <groupId>org.thingsboard</groupId> 109 <groupId>org.thingsboard</groupId>
264 <artifactId>gradle-maven-plugin</artifactId> 110 <artifactId>gradle-maven-plugin</artifactId>
265 - <configuration>  
266 - <tasks>  
267 - <task>build</task>  
268 - <task>buildDeb</task>  
269 - <task>buildRpm</task>  
270 - </tasks>  
271 - <args>  
272 - <arg>-PprojectBuildDir=${project.build.directory}</arg>  
273 - <arg>-PprojectVersion=${project.version}</arg>  
274 - <arg>-PmainJar=${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</arg>  
275 - <arg>-PpkgName=${pkg.name}</arg>  
276 - <arg>-PpkgInstallFolder=${pkg.installFolder}</arg>  
277 - <arg>-PpkgLogFolder=${pkg.unixLogFolder}</arg>  
278 - </args>  
279 - </configuration>  
280 - <executions>  
281 - <execution>  
282 - <phase>package</phase>  
283 - <goals>  
284 - <goal>invoke</goal>  
285 - </goals>  
286 - </execution>  
287 - </executions>  
288 </plugin> 111 </plugin>
289 <plugin> 112 <plugin>
290 <groupId>org.apache.maven.plugins</groupId> 113 <groupId>org.apache.maven.plugins</groupId>
291 <artifactId>maven-assembly-plugin</artifactId> 114 <artifactId>maven-assembly-plugin</artifactId>
292 - <configuration>  
293 - <finalName>${pkg.name}</finalName>  
294 - <descriptors>  
295 - <descriptor>src/main/assembly/windows.xml</descriptor>  
296 - </descriptors>  
297 - </configuration>  
298 - <executions>  
299 - <execution>  
300 - <id>assembly</id>  
301 - <phase>package</phase>  
302 - <goals>  
303 - <goal>single</goal>  
304 - </goals>  
305 - </execution>  
306 - </executions>  
307 </plugin> 115 </plugin>
308 <plugin> 116 <plugin>
309 <groupId>org.apache.maven.plugins</groupId> 117 <groupId>org.apache.maven.plugins</groupId>
310 <artifactId>maven-install-plugin</artifactId> 118 <artifactId>maven-install-plugin</artifactId>
311 - <configuration>  
312 - <file>${project.build.directory}/${pkg.name}.deb</file>  
313 - <artifactId>${project.artifactId}</artifactId>  
314 - <groupId>${project.groupId}</groupId>  
315 - <version>${project.version}</version>  
316 - <classifier>deb</classifier>  
317 - <packaging>deb</packaging>  
318 - </configuration>  
319 - <executions>  
320 - <execution>  
321 - <id>install-deb</id>  
322 - <phase>package</phase>  
323 - <goals>  
324 - <goal>install-file</goal>  
325 - </goals>  
326 - </execution>  
327 - </executions>  
328 </plugin> 119 </plugin>
329 </plugins> 120 </plugins>
330 </build> 121 </build>
1 -<!--  
2 -  
3 - Copyright © 2016-2020 The Thingsboard Authors  
4 -  
5 - Licensed under the Apache License, Version 2.0 (the "License");  
6 - you may not use this file except in compliance with the License.  
7 - You may obtain a copy of the License at  
8 -  
9 - http://www.apache.org/licenses/LICENSE-2.0  
10 -  
11 - Unless required by applicable law or agreed to in writing, software  
12 - distributed under the License is distributed on an "AS IS" BASIS,  
13 - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
14 - See the License for the specific language governing permissions and  
15 - limitations under the License.  
16 -  
17 --->  
18 -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"  
19 - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
20 - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">  
21 - <id>windows</id>  
22 -  
23 - <formats>  
24 - <format>zip</format>  
25 - </formats>  
26 -  
27 - <!-- Workaround to create logs directory -->  
28 - <fileSets>  
29 - <fileSet>  
30 - <directory>${pkg.win.dist}</directory>  
31 - <outputDirectory>logs</outputDirectory>  
32 - <excludes>  
33 - <exclude>*/**</exclude>  
34 - </excludes>  
35 - </fileSet>  
36 - <fileSet>  
37 - <directory>${pkg.win.dist}/conf</directory>  
38 - <outputDirectory>conf</outputDirectory>  
39 - <lineEnding>windows</lineEnding>  
40 - </fileSet>  
41 - </fileSets>  
42 -  
43 - <files>  
44 - <file>  
45 - <source>${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</source>  
46 - <outputDirectory>lib</outputDirectory>  
47 - <destName>${pkg.name}.jar</destName>  
48 - </file>  
49 - <file>  
50 - <source>${pkg.win.dist}/service.exe</source>  
51 - <outputDirectory/>  
52 - <destName>${pkg.name}.exe</destName>  
53 - </file>  
54 - <file>  
55 - <source>${pkg.win.dist}/service.xml</source>  
56 - <outputDirectory/>  
57 - <destName>${pkg.name}.xml</destName>  
58 - <lineEnding>windows</lineEnding>  
59 - </file>  
60 - <file>  
61 - <source>${pkg.win.dist}/install.bat</source>  
62 - <outputDirectory/>  
63 - <lineEnding>windows</lineEnding>  
64 - </file>  
65 - <file>  
66 - <source>${pkg.win.dist}/uninstall.bat</source>  
67 - <outputDirectory/>  
68 - <lineEnding>windows</lineEnding>  
69 - </file>  
70 - </files>  
71 -</assembly>  
1 -pkg.logFolder=${pkg.unixLogFolder}  
1 -pkg.logFolder=${BASE}\\logs  
2 -pkg.winWrapperLogFolder=%BASE%\\logs  
1 -#!/bin/sh  
2 -  
3 -chown -R ${pkg.user}: ${pkg.logFolder}  
4 -chown -R ${pkg.user}: ${pkg.installFolder}  
5 -update-rc.d ${pkg.name} defaults  
6 -  
1 -#!/bin/sh  
2 -  
3 -update-rc.d -f ${pkg.name} remove  
1 -#!/bin/sh  
2 -  
3 -if ! getent group ${pkg.user} >/dev/null; then  
4 - addgroup --system ${pkg.user}  
5 -fi  
6 -  
7 -if ! getent passwd ${pkg.user} >/dev/null; then  
8 - adduser --quiet \  
9 - --system \  
10 - --ingroup ${pkg.user} \  
11 - --quiet \  
12 - --disabled-login \  
13 - --disabled-password \  
14 - --home ${pkg.installFolder} \  
15 - --no-create-home \  
16 - -gecos "Thingsboard application" \  
17 - ${pkg.user}  
18 -fi  
1 -#!/bin/sh  
2 -  
3 -if [ -e /var/run/${pkg.name}/${pkg.name}.pid ]; then  
4 - service ${pkg.name} stop  
5 -fi  
1 -#!/bin/sh  
2 -  
3 -chown -R ${pkg.user}: ${pkg.logFolder}  
4 -chown -R ${pkg.user}: ${pkg.installFolder}  
5 -  
6 -if [ $1 -eq 1 ] ; then  
7 - # Initial installation  
8 - systemctl --no-reload enable ${pkg.name}.service >/dev/null 2>&1 || :  
9 -fi  
1 -#!/bin/sh  
2 -  
3 -if [ $1 -ge 1 ] ; then  
4 - # Package upgrade, not uninstall  
5 - systemctl try-restart ${pkg.name}.service >/dev/null 2>&1 || :  
6 -fi  
1 -#!/bin/sh  
2 -  
3 -getent group ${pkg.user} >/dev/null || groupadd -r ${pkg.user}  
4 -getent passwd ${pkg.user} >/dev/null || \  
5 -useradd -d ${pkg.installFolder} -g ${pkg.user} -M -r ${pkg.user} -s /sbin/nologin \  
6 --c "Thingsboard application"  
1 -#!/bin/sh  
2 -  
3 -if [ $1 -eq 0 ] ; then  
4 - # Package removal, not upgrade  
5 - systemctl --no-reload disable --now ${pkg.name}.service > /dev/null 2>&1 || :  
6 -fi  
1 -[Unit]  
2 -Description=${pkg.name}  
3 -After=syslog.target  
4 -  
5 -[Service]  
6 -User=${pkg.user}  
7 -ExecStart=${pkg.installFolder}/bin/${pkg.name}.jar  
8 -SuccessExitStatus=143  
9 -  
10 -[Install]  
11 -WantedBy=multi-user.target  
1 -@ECHO OFF  
2 -  
3 -setlocal ENABLEEXTENSIONS  
4 -  
5 -@ECHO Detecting Java version installed.  
6 -:CHECK_JAVA  
7 -for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j%%k"  
8 -@ECHO CurrentVersion %jver%  
9 -  
10 -if %jver% NEQ 18 GOTO JAVA_NOT_INSTALLED  
11 -  
12 -:JAVA_INSTALLED  
13 -  
14 -@ECHO Java 1.8 found!  
15 -@ECHO Installing ${pkg.name} ...  
16 -  
17 -"%BASE%"${pkg.name}.exe install  
18 -  
19 -@ECHO ${pkg.name} installed successfully!  
20 -  
21 -GOTO END  
22 -  
23 -:JAVA_NOT_INSTALLED  
24 -@ECHO Java 1.8 is not installed. Only Java 1.8 is supported  
25 -@ECHO Please go to https://adoptopenjdk.net/index.html and install Java 1.8. Then retry installation.  
26 -PAUSE  
27 -GOTO END  
28 -  
29 -:END  
30 -  
31 -  
1 -<service>  
2 - <id>${pkg.name}</id>  
3 - <name>${project.name}</name>  
4 - <description>${project.description}</description>  
5 - <workingdirectory>%BASE%\conf</workingdirectory>  
6 - <logpath>${pkg.winWrapperLogFolder}</logpath>  
7 - <logmode>rotate</logmode>  
8 - <env name="LOADER_PATH" value="%BASE%\conf" />  
9 - <executable>java</executable>  
10 - <startargument>-Xloggc:%BASE%\logs\gc.log</startargument>  
11 - <startargument>-XX:+HeapDumpOnOutOfMemoryError</startargument>  
12 - <startargument>-XX:+PrintGCDetails</startargument>  
13 - <startargument>-XX:+PrintGCDateStamps</startargument>  
14 - <startargument>-XX:+PrintHeapAtGC</startargument>  
15 - <startargument>-XX:+PrintTenuringDistribution</startargument>  
16 - <startargument>-XX:+PrintGCApplicationStoppedTime</startargument>  
17 - <startargument>-XX:+UseGCLogFileRotation</startargument>  
18 - <startargument>-XX:NumberOfGCLogFiles=10</startargument>  
19 - <startargument>-XX:GCLogFileSize=10M</startargument>  
20 - <startargument>-XX:-UseBiasedLocking</startargument>  
21 - <startargument>-XX:+UseTLAB</startargument>  
22 - <startargument>-XX:+ResizeTLAB</startargument>  
23 - <startargument>-XX:+PerfDisableSharedMem</startargument>  
24 - <startargument>-XX:+UseCondCardMark</startargument>  
25 - <startargument>-XX:CMSWaitDuration=10000</startargument>  
26 - <startargument>-XX:+UseParNewGC</startargument>  
27 - <startargument>-XX:+UseConcMarkSweepGC</startargument>  
28 - <startargument>-XX:+CMSParallelRemarkEnabled</startargument>  
29 - <startargument>-XX:+CMSParallelInitialMarkEnabled</startargument>  
30 - <startargument>-XX:+CMSEdenChunksRecordAlways</startargument>  
31 - <startargument>-XX:CMSInitiatingOccupancyFraction=75</startargument>  
32 - <startargument>-XX:+UseCMSInitiatingOccupancyOnly</startargument>  
33 - <startargument>-jar</startargument>  
34 - <startargument>%BASE%\lib\${pkg.name}.jar</startargument>  
35 -  
36 -</service>  
1 -@ECHO OFF  
2 -  
3 -@ECHO Stopping ${pkg.name} ...  
4 -net stop ${pkg.name}  
5 -  
6 -@ECHO Uninstalling ${pkg.name} ...  
7 -"%~dp0"${pkg.name}.exe uninstall  
8 -  
9 -@ECHO DONE.  
@@ -397,7 +397,7 @@ export default class TbCanvasDigitalGauge { @@ -397,7 +397,7 @@ export default class TbCanvasDigitalGauge {
397 } 397 }
398 var value = tvPair[1]; 398 var value = tvPair[1];
399 if(value !== this.gauge.value) { 399 if(value !== this.gauge.value) {
400 - if (!this.ctx.settings.animation) { 400 + if (!this.ctx.settings.animation || this.ctx.isMobile) {
401 this.gauge._value = value; 401 this.gauge._value = value;
402 } 402 }
403 this.gauge.value = value; 403 this.gauge.value = value;