Commit 2543063e4afc1e6346e7c88c9617b1d07d4650f5

Authored by Igor Kulikov
Committed by GitHub
2 parents f682e492 83f5e81b

Merge pull request #198 from thingsboard/feature/TB-65

TB-65: ThingsBoard installation and upgrade support
... ... @@ -418,6 +418,28 @@
418 418 </configuration>
419 419 </execution>
420 420 <execution>
  421 + <id>copy-windows-install</id>
  422 + <phase>process-resources</phase>
  423 + <goals>
  424 + <goal>copy-resources</goal>
  425 + </goals>
  426 + <configuration>
  427 + <outputDirectory>${pkg.win.dist}/install</outputDirectory>
  428 + <resources>
  429 + <resource>
  430 + <directory>src/main/scripts/install</directory>
  431 + <includes>
  432 + <include>logback.xml</include>
  433 + </includes>
  434 + <filtering>true</filtering>
  435 + </resource>
  436 + </resources>
  437 + <filters>
  438 + <filter>src/main/filters/windows.properties</filter>
  439 + </filters>
  440 + </configuration>
  441 + </execution>
  442 + <execution>
421 443 <id>copy-data</id>
422 444 <phase>process-resources</phase>
423 445 <goals>
... ... @@ -503,6 +525,9 @@
503 525 <groupId>org.apache.maven.plugins</groupId>
504 526 <artifactId>maven-jar-plugin</artifactId>
505 527 <configuration>
  528 + <excludes>
  529 + <exclude>**/logback.xml</exclude>
  530 + </excludes>
506 531 <archive>
507 532 <manifestEntries>
508 533 <Implementation-Title>ThingsBoard</Implementation-Title>
... ...
... ... @@ -34,6 +34,11 @@
34 34 </excludes>
35 35 </fileSet>
36 36 <fileSet>
  37 + <directory>${pkg.win.dist}/install</directory>
  38 + <outputDirectory>install</outputDirectory>
  39 + <lineEnding>windows</lineEnding>
  40 + </fileSet>
  41 + <fileSet>
37 42 <directory>${pkg.win.dist}/conf</directory>
38 43 <outputDirectory>conf</outputDirectory>
39 44 <lineEnding>windows</lineEnding>
... ... @@ -75,5 +80,10 @@
75 80 <outputDirectory/>
76 81 <lineEnding>windows</lineEnding>
77 82 </file>
  83 + <file>
  84 + <source>${pkg.win.dist}/upgrade.bat</source>
  85 + <outputDirectory/>
  86 + <lineEnding>windows</lineEnding>
  87 + </file>
78 88 </files>
79 89 </assembly>
... ...
... ... @@ -69,9 +69,34 @@ IF "%JRE_PATH2%" == "" GOTO JAVA_NOT_INSTALLED
69 69
70 70 @ECHO Java 1.8 found!
71 71 @ECHO Installing ${pkg.name} ...
72   -%~dp0${pkg.name}.exe install
73 72
74   -@ECHO DONE.
  73 +SET loadDemo=false
  74 +
  75 +if "%1" == "--loadDemo" (
  76 + SET loadDemo=true
  77 +)
  78 +
  79 +SET BASE=%~dp0
  80 +SET LOADER_PATH=%BASE%\conf,%BASE%\extensions
  81 +SET jarfile=%BASE%\lib\${pkg.name}.jar
  82 +SET installDir=%BASE%\data
  83 +
  84 +java -cp %jarfile% -Dloader.main=org.thingsboard.server.ThingsboardInstallApplication^
  85 + -Dinstall.data_dir=%installDir%^
  86 + -Dinstall.load_demo=%loadDemo%^
  87 + -Dspring.jpa.hibernate.ddl-auto=none^
  88 + -Dinstall.upgrade=false^
  89 + -Dlogging.config=%BASE%\install\logback.xml^
  90 + org.springframework.boot.loader.PropertiesLauncher
  91 +
  92 +if errorlevel 1 (
  93 + @echo ThingsBoard installation failed!
  94 + exit /b %errorlevel%
  95 +)
  96 +
  97 +%BASE%${pkg.name}.exe install
  98 +
  99 +@ECHO ThingsBoard installed successfully!
75 100
76 101 GOTO END
77 102
... ...
  1 +@ECHO OFF
  2 +
  3 +setlocal ENABLEEXTENSIONS
  4 +
  5 +@ECHO Upgrading ${pkg.name} ...
  6 +
  7 +SET BASE=%~dp0
  8 +
  9 +:loop
  10 +IF NOT "%1"=="" (
  11 + IF "%1"=="--fromVersion" (
  12 + SET fromVersion=%2
  13 + )
  14 + SHIFT
  15 + GOTO :loop
  16 +)
  17 +
  18 +if not defined fromVersion (
  19 + echo "--fromVersion parameter is invalid or unspecified!"
  20 + echo "Usage: upgrade.bat --fromVersion {VERSION}"
  21 + exit /b 1
  22 +)
  23 +
  24 +SET LOADER_PATH=%BASE%\conf,%BASE%\extensions
  25 +SET jarfile=%BASE%\lib\${pkg.name}.jar
  26 +SET installDir=%BASE%\data
  27 +
  28 +java -cp %jarfile% -Dloader.main=org.thingsboard.server.ThingsboardInstallApplication^
  29 + -Dinstall.data_dir=%installDir%^
  30 + -Dspring.jpa.hibernate.ddl-auto=none^
  31 + -Dinstall.upgrade=true^
  32 + -Dinstall.upgrade.from_version=%fromVersion%^
  33 + -Dlogging.config=%BASE%\install\logback.xml^
  34 + org.springframework.boot.loader.PropertiesLauncher
  35 +
  36 +if errorlevel 1 (
  37 + @echo ThingsBoard upgrade failed!
  38 + exit /b %errorlevel%
  39 +)
  40 +
  41 +@ECHO ThingsBoard upgraded successfully!
  42 +
  43 +GOTO END
  44 +
  45 +:END
... ...