-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.bat
132 lines (110 loc) · 3.97 KB
/
install.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
::==============================================================================
:: author :Tapan Chandra
:: contact :[email protected]
:: title :Hawtio Standalone Installer
:: description :This script will execute release related actions
:: date :20161025
:: version :0.1
:: dependencies :NSSM - https://nssm.cc/
:: curl - https://curl.haxx.se/
:: hawtio - http://hawt.io/
:: sleep.exe - http://www.sleepcmd.com/
::==============================================================================
@echo off
echo *****************************************
echo Hawtio Standalone Installer, Version 0.1
echo Hawtio version 1.4.66
echo NSSM version 2.24
echo *****************************************
if not defined JAVA_HOME (
echo.
echo JAVA_HOME Environment variable has not been defined. Hawtio requires atleast version 7.
echo Exiting...
exit 1
)
if not exist install.properties (
echo.
echo Could not find install.properties file.
echo Exiting...
exit 1
)
::Read from properties file
SET INSTALLER_HOME=%~dp0
FOR /F "tokens=1,2 delims==" %%G IN (install.properties) DO (set %%G=%%H)
If "%1" == "ExecuteCodeWithElevatedPrivileges" goto :ExecuteCodeWithElevatedPrivileges
::Create Install directory
mkdir %install_location%
mkdir %install_location%\bin
mkdir %install_location%\lib
mkdir %install_location%\data
::Copy artifacts
echo f | xcopy /f /Y install.properties %install_location%\data\installed.properties
echo f | xcopy /f /Y lib\hawtio-app-1.4.66.jar %install_location%\lib\hawtio-app-1.4.66.jar
echo f | xcopy /f /Y lib\nssm.exe %install_location%\lib\nssm.exe
echo f | xcopy /f /Y lib\sleep.exe %install_location%\lib\sleep.exe
echo f | xcopy /f /Y lib\elevator.bat %install_location%\bin\elevator.bat
::Create start/stop/ bat files
cd /D %install_location%\bin
::Creating start.bat
echo ^@echo off > start.bat
echo. >> start.bat
echo If "%%1" == "elevated" goto :elevated >> start.bat
echo. >> start.bat
echo elevator.bat %%~dp0 %%0 elevated >> start.bat
echo. >> start.bat
echo :elevated >> start.bat
echo net start %service_name% >> start.bat
echo exit >> start.bat
::Creating stop.bat
echo ^@echo off > stop.bat
echo. >> stop.bat
echo If "%%1" == "elevated" goto :elevated >> stop.bat
echo. >> stop.bat
echo elevator.bat %%~dp0 %%0 elevated >> stop.bat
echo. >> stop.bat
echo :elevated >> stop.bat
echo net stop %service_name% >> stop.bat
echo exit >> stop.bat
::Creating open.bat
echo ^@echo off > open.bat
echo. >> open.bat
echo start http://localhost:%port%/hawtio >> open.bat
echo. >> stop.bat
::Creating Uninstaller
cd /D %install_location%
echo ^@echo off > uninstall.bat
echo. >> uninstall.bat
echo If "%%1" == "elevated" goto :elevated >> uninstall.bat
echo. >> uninstall.bat
echo cd bin >> uninstall.bat
echo elevator.bat %%~dp0 %%0 elevated >> uninstall.bat
echo. >> uninstall.bat
echo. >> uninstall.bat
echo :elevated >> uninstall.bat
echo ^:^:Stopping the service >>uninstall.bat
echo net stop %service_name% >> uninstall.bat
echo. >> uninstall.bat
echo ^:^:Uninstall service >>uninstall.bat
echo cd %install_location%\lib >> uninstall.bat
echo nssm.exe remove %service_name% confirm >> uninstall.bat
echo. >> uninstall.bat
echo echo Uninstall Complete, You can delete the %install_location% now to finish uninstallation >> uninstall.bat
echo Pause >> uninstall.bat
echo Exit >> uninstall.bat
cd %INSTALLER_HOME%lib
:: Create Service
::Ask for Elevated permissions
elevator.bat %~dp0 %0 ExecuteCodeWithElevatedPrivileges
:ExecuteCodeWithElevatedPrivileges
cd %INSTALLER_HOME%lib
nssm.exe install %service_name% "%JAVA_HOME%\bin\java.exe" -jar "%install_location%\lib\hawtio-app-1.4.66.jar" --port %port%
nssm.exe set %service_name% AppDirectory %install_location%
nssm.exe set %service_name% Start SERVICE_AUTO_START
nssm.exe set %service_name% DisplayName %service_display_name%
nssm.exe start %service_name%
echo Installation Completed Successfully.
echo See %install_location%\bin for service helpers.
Pause
cd /D %install_location%\bin
..\lib\sleep.exe 5
CALL open.bat