Commit 9e0b94b9d84dcfed465c3456476c86dac1387849

Authored by Igor Kulikov
Committed by GitHub
1 parent 0ffac9c2

TB-40: Windows installation package for thingsboard application (#45)

... ... @@ -28,14 +28,17 @@
28 28 <packaging>jar</packaging>
29 29
30 30 <name>Thingsboard Server Application</name>
31   - <url>http://thingsboard.org</url>
  31 + <url>https://thingsboard.io</url>
  32 + <description>Open-source IoT Platform - Device management, data collection, processing and visualization
  33 + </description>
32 34
33 35 <properties>
34 36 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
35 37 <main.dir>${basedir}/..</main.dir>
36 38 <pkg.name>thingsboard</pkg.name>
37   - <pkg.logFolder>/var/log/${pkg.name}</pkg.logFolder>
  39 + <pkg.unixLogFolder>/var/log/${pkg.name}</pkg.unixLogFolder>
38 40 <pkg.installFolder>/usr/share/${pkg.name}</pkg.installFolder>
  41 + <pkg.win.dist>${project.build.directory}/windows</pkg.win.dist>
39 42 </properties>
40 43
41 44 <dependencies>
... ... @@ -197,6 +200,13 @@
197 200 <artifactId>springfox-swagger2</artifactId>
198 201 </dependency>
199 202 <dependency>
  203 + <groupId>com.sun.winsw</groupId>
  204 + <artifactId>winsw</artifactId>
  205 + <classifier>bin</classifier>
  206 + <type>exe</type>
  207 + <scope>provided</scope>
  208 + </dependency>
  209 + <dependency>
200 210 <groupId>org.thingsboard</groupId>
201 211 <artifactId>tools</artifactId>
202 212 <scope>test</scope>
... ... @@ -291,6 +301,38 @@
291 301 <filtering>true</filtering>
292 302 </resource>
293 303 </resources>
  304 + <filters>
  305 + <filter>src/main/filters/unix.properties</filter>
  306 + </filters>
  307 + </configuration>
  308 + </execution>
  309 + <execution>
  310 + <id>copy-win-conf</id>
  311 + <phase>process-resources</phase>
  312 + <goals>
  313 + <goal>copy-resources</goal>
  314 + </goals>
  315 + <configuration>
  316 + <outputDirectory>${pkg.win.dist}/conf</outputDirectory>
  317 + <resources>
  318 + <resource>
  319 + <directory>src/main/resources</directory>
  320 + <excludes>
  321 + <exclude>logback.xml</exclude>
  322 + </excludes>
  323 + <filtering>false</filtering>
  324 + </resource>
  325 + <resource>
  326 + <directory>src/main/conf</directory>
  327 + <excludes>
  328 + <exclude>thingsboard.conf</exclude>
  329 + </excludes>
  330 + <filtering>true</filtering>
  331 + </resource>
  332 + </resources>
  333 + <filters>
  334 + <filter>src/main/filters/windows.properties</filter>
  335 + </filters>
294 336 </configuration>
295 337 </execution>
296 338 <execution>
... ... @@ -307,6 +349,28 @@
307 349 <filtering>true</filtering>
308 350 </resource>
309 351 </resources>
  352 + <filters>
  353 + <filter>src/main/filters/unix.properties</filter>
  354 + </filters>
  355 + </configuration>
  356 + </execution>
  357 + <execution>
  358 + <id>copy-windows-control</id>
  359 + <phase>process-resources</phase>
  360 + <goals>
  361 + <goal>copy-resources</goal>
  362 + </goals>
  363 + <configuration>
  364 + <outputDirectory>${pkg.win.dist}</outputDirectory>
  365 + <resources>
  366 + <resource>
  367 + <directory>src/main/scripts/windows</directory>
  368 + <filtering>true</filtering>
  369 + </resource>
  370 + </resources>
  371 + <filters>
  372 + <filter>src/main/filters/windows.properties</filter>
  373 + </filters>
310 374 </configuration>
311 375 </execution>
312 376 <execution>
... ... @@ -361,6 +425,25 @@
361 425 </artifactItems>
362 426 </configuration>
363 427 </execution>
  428 + <execution>
  429 + <id>copy-winsw-service</id>
  430 + <phase>package</phase>
  431 + <goals>
  432 + <goal>copy</goal>
  433 + </goals>
  434 + <configuration>
  435 + <artifactItems>
  436 + <artifactItem>
  437 + <groupId>com.sun.winsw</groupId>
  438 + <artifactId>winsw</artifactId>
  439 + <classifier>bin</classifier>
  440 + <type>exe</type>
  441 + <destFileName>service.exe</destFileName>
  442 + </artifactItem>
  443 + </artifactItems>
  444 + <outputDirectory>${pkg.win.dist}</outputDirectory>
  445 + </configuration>
  446 + </execution>
364 447 </executions>
365 448 </plugin>
366 449 <plugin>
... ... @@ -385,7 +468,7 @@
385 468 <excludeDevtools>true</excludeDevtools>
386 469 <embeddedLaunchScriptProperties>
387 470 <confFolder>${pkg.installFolder}/conf</confFolder>
388   - <logFolder>${pkg.logFolder}</logFolder>
  471 + <logFolder>${pkg.unixLogFolder}</logFolder>
389 472 <logFilename>${pkg.name}.out</logFilename>
390 473 </embeddedLaunchScriptProperties>
391 474 </configuration>
... ... @@ -412,7 +495,7 @@
412 495 <arg>-PmainJar=${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</arg>
413 496 <arg>-PpkgName=${pkg.name}</arg>
414 497 <arg>-PpkgInstallFolder=${pkg.installFolder}</arg>
415   - <arg>-PpkgLogFolder=${pkg.logFolder}</arg>
  498 + <arg>-PpkgLogFolder=${pkg.unixLogFolder}</arg>
416 499 </args>
417 500 </configuration>
418 501 <executions>
... ... @@ -425,6 +508,25 @@
425 508 </executions>
426 509 </plugin>
427 510 <plugin>
  511 + <groupId>org.apache.maven.plugins</groupId>
  512 + <artifactId>maven-assembly-plugin</artifactId>
  513 + <configuration>
  514 + <finalName>${pkg.name}</finalName>
  515 + <descriptors>
  516 + <descriptor>src/main/assembly/windows.xml</descriptor>
  517 + </descriptors>
  518 + </configuration>
  519 + <executions>
  520 + <execution>
  521 + <id>assembly</id>
  522 + <phase>package</phase>
  523 + <goals>
  524 + <goal>single</goal>
  525 + </goals>
  526 + </execution>
  527 + </executions>
  528 + </plugin>
  529 + <plugin>
428 530 <groupId>org.xolstice.maven.plugins</groupId>
429 531 <artifactId>protobuf-maven-plugin</artifactId>
430 532 </plugin>
... ... @@ -434,4 +536,14 @@
434 536 </plugin>
435 537 </plugins>
436 538 </build>
  539 + <repositories>
  540 + <repository>
  541 + <id>jenkins</id>
  542 + <name>Jenkins Repository</name>
  543 + <url>http://repo.jenkins-ci.org/releases</url>
  544 + <snapshots>
  545 + <enabled>false</enabled>
  546 + </snapshots>
  547 + </repository>
  548 + </repositories>
437 549 </project>
... ...
  1 +<!--
  2 +
  3 + Copyright © 2016-2017 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 + <fileSet>
  42 + <directory>${project.build.directory}/extensions</directory>
  43 + <outputDirectory>extensions</outputDirectory>
  44 + </fileSet>
  45 + <fileSet>
  46 + <directory>${project.build.directory}/data</directory>
  47 + <outputDirectory>data</outputDirectory>
  48 + </fileSet>
  49 + </fileSets>
  50 +
  51 + <files>
  52 + <file>
  53 + <source>${project.build.directory}/${project.build.finalName}-boot.${project.packaging}</source>
  54 + <outputDirectory>lib</outputDirectory>
  55 + <destName>${pkg.name}.jar</destName>
  56 + </file>
  57 + <file>
  58 + <source>${pkg.win.dist}/service.exe</source>
  59 + <outputDirectory/>
  60 + <destName>${pkg.name}.exe</destName>
  61 + </file>
  62 + <file>
  63 + <source>${pkg.win.dist}/service.xml</source>
  64 + <outputDirectory/>
  65 + <destName>${pkg.name}.xml</destName>
  66 + <lineEnding>windows</lineEnding>
  67 + </file>
  68 + <file>
  69 + <source>${pkg.win.dist}/install.bat</source>
  70 + <outputDirectory/>
  71 + <lineEnding>windows</lineEnding>
  72 + </file>
  73 + <file>
  74 + <source>${pkg.win.dist}/uninstall.bat</source>
  75 + <outputDirectory/>
  76 + <lineEnding>windows</lineEnding>
  77 + </file>
  78 + </files>
  79 +</assembly>
... ...
  1 +pkg.logFolder=${pkg.unixLogFolder}
\ No newline at end of file
... ...
  1 +pkg.logFolder=${BASE}\\logs
  2 +pkg.winWrapperLogFolder=%BASE%\\logs
... ...
  1 +@ECHO OFF
  2 +
  3 +setlocal ENABLEEXTENSIONS
  4 +
  5 +IF %PROCESSOR_ARCHITECTURE%==AMD64 GOTO CHECK_JAVA_64
  6 +IF %PROCESSOR_ARCHITECTURE%==x86 GOTO CHECK_JAVA_32
  7 +
  8 +@ECHO Detecting Java version installed.
  9 +:CHECK_JAVA_64
  10 +@ECHO Detecting if it is 64 bit machine
  11 +set KEY_NAME="HKEY_LOCAL_MACHINE\Software\Wow6432Node\JavaSoft\Java Runtime Environment"
  12 +set VALUE_NAME=CurrentVersion
  13 +
  14 +FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
  15 + set ValueName=%%A
  16 + set ValueType=%%B
  17 + set ValueValue=%%C
  18 +)
  19 +@ECHO CurrentVersion %ValueValue%
  20 +
  21 +SET KEY_NAME="%KEY_NAME:~1,-1%\%ValueValue%"
  22 +SET VALUE_NAME=JavaHome
  23 +
  24 +if defined ValueName (
  25 + FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
  26 + set ValueName2=%%A
  27 + set ValueType2=%%B
  28 + set JRE_PATH2=%%C
  29 +
  30 + if defined ValueName2 (
  31 + set ValueName = %ValueName2%
  32 + set ValueType = %ValueType2%
  33 + set ValueValue = %JRE_PATH2%
  34 + )
  35 + )
  36 +)
  37 +
  38 +IF NOT "%JRE_PATH2%" == "" GOTO JAVA_INSTALLED
  39 +IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED
  40 +
  41 +:CHECK_JAVA_32
  42 +@ECHO Detecting if it is 32 bit machine
  43 +set KEY_NAME="HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment"
  44 +set VALUE_NAME=CurrentVersion
  45 +
  46 +FOR /F "usebackq skip=2 tokens=1-3" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
  47 + set ValueName=%%A
  48 + set ValueType=%%B
  49 + set ValueValue=%%C
  50 +)
  51 +@ECHO CurrentVersion %ValueValue%
  52 +
  53 +SET KEY_NAME="%KEY_NAME:~1,-1%\%ValueValue%"
  54 +SET VALUE_NAME=JavaHome
  55 +
  56 +if defined ValueName (
  57 + FOR /F "usebackq skip=2 tokens=1,2*" %%A IN (`REG QUERY %KEY_NAME% /v %VALUE_NAME% 2^>nul`) DO (
  58 + set ValueName2=%%A
  59 + set ValueType2=%%B
  60 + set JRE_PATH2=%%C
  61 +
  62 + if defined ValueName2 (
  63 + set ValueName = %ValueName2%
  64 + set ValueType = %ValueType2%
  65 + set ValueValue = %JRE_PATH2%
  66 + )
  67 + )
  68 +)
  69 +
  70 +IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED
  71 +
  72 +:JAVA_INSTALLED
  73 +
  74 +@ECHO Java 1.8 found!
  75 +@ECHO Installing ${pkg.name} ...
  76 +${pkg.name}.exe install
  77 +
  78 +@ECHO DONE.
  79 +
  80 +GOTO END
  81 +
  82 +:JAVA_NOT_INSTALLED
  83 +@ECHO Java 1.8 or above is not installed
  84 +@ECHO Please go to https://java.com/ and install Java. Then retry installation.
  85 +PAUSE
  86 +GOTO END
  87 +
  88 +:END
  89 +
  90 +
... ...
  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,%BASE%\extensions" />
  9 + <executable>java</executable>
  10 + <startargument>-jar</startargument>
  11 + <startargument>%BASE%\lib\${pkg.name}.jar</startargument>
  12 +</service>
... ...
  1 +@ECHO OFF
  2 +
  3 +@ECHO Stopping ${pkg.name} ...
  4 +net stop ${pkg.name}
  5 +
  6 +@ECHO Uninstalling ${pkg.name} ...
  7 +${pkg.name}.exe uninstall
  8 +
  9 +@ECHO DONE.
\ No newline at end of file
... ...
... ... @@ -24,12 +24,12 @@
24 24 <packaging>pom</packaging>
25 25
26 26 <name>Thingsboard</name>
27   - <url>http://thingsboard.io</url>
  27 + <url>https://thingsboard.io</url>
28 28 <inceptionYear>2016</inceptionYear>
29 29
30 30 <properties>
31 31 <main.dir>${basedir}</main.dir>
32   - <spring-boot.version>1.4.2.RELEASE</spring-boot.version>
  32 + <spring-boot.version>1.4.3.RELEASE</spring-boot.version>
33 33 <spring.version>4.3.4.RELEASE</spring.version>
34 34 <spring-security.version>4.2.0.RELEASE</spring-security.version>
35 35 <jjwt.version>0.7.0</jjwt.version>
... ... @@ -70,6 +70,7 @@
70 70 <jar-plugin.version>3.0.2</jar-plugin.version>
71 71 <springfox-swagger.version>2.6.1</springfox-swagger.version>
72 72 <bouncycastle.version>1.56</bouncycastle.version>
  73 + <winsw.version>2.0.1</winsw.version>
73 74 </properties>
74 75
75 76 <modules>
... ... @@ -128,6 +129,11 @@
128 129 <version>3.0.2</version>
129 130 </plugin>
130 131 <plugin>
  132 + <groupId>org.apache.maven.plugins</groupId>
  133 + <artifactId>maven-assembly-plugin</artifactId>
  134 + <version>3.0.0</version>
  135 + </plugin>
  136 + <plugin>
131 137 <groupId>org.springframework.boot</groupId>
132 138 <artifactId>spring-boot-maven-plugin</artifactId>
133 139 <version>${spring-boot.version}</version>
... ... @@ -264,6 +270,7 @@
264 270 <exclude>src/font/**</exclude>
265 271 <exclude>src/sh/**</exclude>
266 272 <exclude>src/main/scripts/control/**</exclude>
  273 + <exclude>src/main/scripts/windows/**</exclude>
267 274 </excludes>
268 275 <mapping>
269 276 <proto>JAVADOC_STYLE</proto>
... ... @@ -700,6 +707,14 @@
700 707 <artifactId>bcpkix-jdk15on</artifactId>
701 708 <version>${bouncycastle.version}</version>
702 709 </dependency>
  710 + <dependency>
  711 + <groupId>com.sun.winsw</groupId>
  712 + <artifactId>winsw</artifactId>
  713 + <version>${winsw.version}</version>
  714 + <classifier>bin</classifier>
  715 + <type>exe</type>
  716 + <scope>provided</scope>
  717 + </dependency>
703 718 </dependencies>
704 719 </dependencyManagement>
705 720
... ...