1 | @echo off |
---|
2 | rem |
---|
3 | rem update_proteios-win.bat |
---|
4 | rem |
---|
5 | |
---|
6 | rem Copyright (C) 2009 Olle Mansson |
---|
7 | rem |
---|
8 | rem Files are copyright by their respective authors. The contributions to |
---|
9 | rem files where copyright is not explicitly stated can be traced with the |
---|
10 | rem source code revision system. |
---|
11 | rem |
---|
12 | rem This file is part of Proteios. |
---|
13 | rem Available at http://www.proteios.org/ |
---|
14 | rem |
---|
15 | rem Proteios is free software; you can redistribute it and/or |
---|
16 | rem modify it under the terms of the GNU General Public License |
---|
17 | rem as published by the Free Software Foundation; either version 2 |
---|
18 | rem of the License, or (at your option) any later version. |
---|
19 | rem |
---|
20 | rem Proteios is distributed in the hope that it will be useful, |
---|
21 | rem but WITHOUT ANY WARRANTY, without even the implied warranty of |
---|
22 | rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
23 | rem GNU General Public License for more details. |
---|
24 | rem |
---|
25 | rem You should have received a copy of the GNU General Public License |
---|
26 | rem along with this program; if not, write to the Free Software |
---|
27 | rem Foundation, Inc., 59 Temple Place - Suite 330, |
---|
28 | rem Boston, MA 02111-1307, USA. |
---|
29 | |
---|
30 | rem |
---|
31 | rem Performs Proteios 2.x update on Microsoft Windows. |
---|
32 | rem |
---|
33 | rem Uses bat file inp2var.bat to store console input data |
---|
34 | rem into a given variable. |
---|
35 | rem |
---|
36 | rem Usage: inp2var.bat var_name [promptfile [mask_input|no_input]] |
---|
37 | rem |
---|
38 | rem Used programs/files: |
---|
39 | rem |
---|
40 | rem inp2var.bat |
---|
41 | rem inp2var.jar |
---|
42 | rem |
---|
43 | |
---|
44 | rem |
---|
45 | rem Configuration |
---|
46 | rem |
---|
47 | set app_name=proteios |
---|
48 | set build_dir=www\WEB-INF\classes |
---|
49 | rem |
---|
50 | rem End Configuration |
---|
51 | rem |
---|
52 | |
---|
53 | rem |
---|
54 | rem Welcome message and update references |
---|
55 | rem |
---|
56 | echo. |
---|
57 | echo. |
---|
58 | echo Welcome to the %app_name% update routine. |
---|
59 | echo. |
---|
60 | echo. |
---|
61 | echo It is assumed that %app_name% is already installed. |
---|
62 | echo. |
---|
63 | echo For more information on the installation steps, see: |
---|
64 | echo http://www.proteios.org/wiki/Update |
---|
65 | echo. |
---|
66 | |
---|
67 | rem |
---|
68 | rem Try to copy configuration files from previous Tomcat installation. |
---|
69 | rem |
---|
70 | :step_1a |
---|
71 | set body_text=1. Trying to copy configuration files from previous Tomcat installation. |
---|
72 | set next_step=step_1b |
---|
73 | goto print |
---|
74 | :step_1b |
---|
75 | echo. |
---|
76 | |
---|
77 | rem |
---|
78 | rem |
---|
79 | rem Set variable catalina_home (tomcat installation directory) |
---|
80 | rem |
---|
81 | rem set catalina_home= |
---|
82 | if not "%catalina_home%"=="" goto catalina_ok |
---|
83 | echo Catalina home: > prompt.txt |
---|
84 | call inp2var.bat catalina_home prompt.txt |
---|
85 | rem echo catalina_home = %catalina_home% |
---|
86 | :catalina_ok |
---|
87 | set catalina_inst_dir=%catalina_home%\webapps\%app_name%\WEB-INF\classes |
---|
88 | echo. |
---|
89 | |
---|
90 | rem |
---|
91 | rem Store current directory in variable %here% |
---|
92 | rem |
---|
93 | cd > prompt.txt |
---|
94 | call inp2var.bat here prompt.txt no_input |
---|
95 | |
---|
96 | rem |
---|
97 | rem Try to copy configuration files from previous Tomcat installation. |
---|
98 | rem |
---|
99 | |
---|
100 | set filename=proteios.config |
---|
101 | set rel_path="." |
---|
102 | set next_step=step_1c1 |
---|
103 | goto copy_file_from_tomcat_installation |
---|
104 | :step_1c1 |
---|
105 | |
---|
106 | set filename=web.xml |
---|
107 | set rel_path=".." |
---|
108 | set next_step=step_1c2 |
---|
109 | goto copy_file_from_tomcat_installation |
---|
110 | :step_1c2 |
---|
111 | |
---|
112 | set filename=ftp.properties |
---|
113 | set rel_path="." |
---|
114 | set next_step=step_1c3 |
---|
115 | goto copy_file_from_tomcat_installation |
---|
116 | :step_1c3 |
---|
117 | |
---|
118 | set filename=xtandem.properties |
---|
119 | set rel_path="." |
---|
120 | set next_step=step_1c4 |
---|
121 | goto copy_file_from_tomcat_installation |
---|
122 | :step_1c4 |
---|
123 | |
---|
124 | set filename=mascot.properties |
---|
125 | set rel_path="." |
---|
126 | set next_step=step_1c5 |
---|
127 | goto copy_file_from_tomcat_installation |
---|
128 | :step_1c5 |
---|
129 | |
---|
130 | set filename=omssa.properties |
---|
131 | set rel_path="." |
---|
132 | set next_step=step_1c6 |
---|
133 | goto copy_file_from_tomcat_installation |
---|
134 | :step_1c6 |
---|
135 | |
---|
136 | set filename=pike.properties |
---|
137 | set rel_path="." |
---|
138 | set next_step=step_1c7 |
---|
139 | goto copy_file_from_tomcat_installation |
---|
140 | :step_1c7 |
---|
141 | |
---|
142 | set filename=log4j.properties |
---|
143 | set rel_path="." |
---|
144 | set next_step=step_1c8 |
---|
145 | goto copy_file_from_tomcat_installation |
---|
146 | :step_1c8 |
---|
147 | |
---|
148 | rem |
---|
149 | rem Check if necessary configuration files exist. |
---|
150 | rem |
---|
151 | :step_2a |
---|
152 | set body_text=2. Checking if necessary configuration files exist. |
---|
153 | set next_step=step_2b |
---|
154 | goto print |
---|
155 | :step_2b |
---|
156 | echo. |
---|
157 | |
---|
158 | set filename=proteios.config |
---|
159 | set rel_path="." |
---|
160 | set next_step=step_2c1 |
---|
161 | goto check_if_necessary_configuration_file_exists |
---|
162 | :step_2c1 |
---|
163 | |
---|
164 | set filename=web.xml |
---|
165 | set rel_path=".." |
---|
166 | set next_step=step_2c2 |
---|
167 | goto check_if_necessary_configuration_file_exists |
---|
168 | :step_2c2 |
---|
169 | |
---|
170 | set filename=ftp.properties |
---|
171 | set rel_path="." |
---|
172 | set next_step=step_2c3 |
---|
173 | goto check_if_necessary_configuration_file_exists |
---|
174 | :step_2c3 |
---|
175 | |
---|
176 | rem |
---|
177 | rem Create other configuration files if not existing. |
---|
178 | rem |
---|
179 | :step_3a |
---|
180 | set body_text=3. Create other configuration files if not existing. |
---|
181 | set next_step=step_3b |
---|
182 | goto print |
---|
183 | :step_3b |
---|
184 | echo. |
---|
185 | |
---|
186 | set filename=xtandem.properties |
---|
187 | set rel_path="." |
---|
188 | set file_title="X!Tandem search" |
---|
189 | set next_step=step_3c1 |
---|
190 | goto create_config_file_if_not_existing |
---|
191 | :step_3c1 |
---|
192 | |
---|
193 | set filename=mascot.properties |
---|
194 | set rel_path="." |
---|
195 | set file_title="Mascot search" |
---|
196 | set next_step=step_3c2 |
---|
197 | goto create_config_file_if_not_existing |
---|
198 | :step_3c2 |
---|
199 | |
---|
200 | set filename=omssa.properties |
---|
201 | set rel_path="." |
---|
202 | set file_title="OMSSA search" |
---|
203 | set next_step=step_3c3 |
---|
204 | goto create_config_file_if_not_existing |
---|
205 | :step_3c3 |
---|
206 | |
---|
207 | set filename=pike.properties |
---|
208 | set rel_path="." |
---|
209 | set file_title="PIKE search" |
---|
210 | set next_step=step_3c4 |
---|
211 | goto create_config_file_if_not_existing |
---|
212 | :step_3c4 |
---|
213 | |
---|
214 | set filename=log4j.properties |
---|
215 | set rel_path="." |
---|
216 | set file_title="Log" |
---|
217 | set next_step=step_3c5 |
---|
218 | goto create_config_file_if_not_existing |
---|
219 | :step_3c5 |
---|
220 | |
---|
221 | rem |
---|
222 | rem Get Proteios root password |
---|
223 | rem |
---|
224 | :step_4a |
---|
225 | set body_text=4. Enter a password for the root account in %app_name%. |
---|
226 | set next_step=step_4b |
---|
227 | goto print |
---|
228 | :step_4b |
---|
229 | echo Password: > prompt.txt |
---|
230 | call inp2var.bat root_pwd prompt.txt mask_input |
---|
231 | echo. |
---|
232 | |
---|
233 | rem |
---|
234 | rem Execute update |
---|
235 | rem |
---|
236 | |
---|
237 | rem |
---|
238 | rem Build class path |
---|
239 | rem |
---|
240 | set cp=.\%build_dir% |
---|
241 | rem |
---|
242 | rem Note: Variables like %cp% are interpreted before a for-statement |
---|
243 | rem is executed, so a for-loop like |
---|
244 | rem |
---|
245 | rem for %%i in (.\www\WEB-INF\lib\*.jar) do set cp=%cp%;%%i |
---|
246 | rem |
---|
247 | rem will only add the last of the *.jar files to the %cp% list |
---|
248 | rem after the for-loop is finished. This can be solved by calling |
---|
249 | rem a temporary batch file that updates the %cp% value for each loop. |
---|
250 | rem The contents of the temporary batch file tmp1.bat is |
---|
251 | rem |
---|
252 | rem set cp=%cp%;%1 |
---|
253 | rem |
---|
254 | rem where %1 is the argument that will be provided by the |
---|
255 | rem for-loop variable %%i. |
---|
256 | rem |
---|
257 | echo set cp=%%cp%%;%%1> tmp1.bat |
---|
258 | for %%i in (.\www\WEB-INF\lib\*.jar) do call tmp1.bat %%i |
---|
259 | del tmp1.bat |
---|
260 | |
---|
261 | rem |
---|
262 | rem Update database. |
---|
263 | rem |
---|
264 | java -cp %cp% org.proteios.install.InitDB update %root_pwd% |
---|
265 | |
---|
266 | rem |
---|
267 | rem Create link in tomcat webapps directory to proteomics directory |
---|
268 | rem |
---|
269 | |
---|
270 | rem |
---|
271 | rem Store current directory in variable %here% |
---|
272 | rem |
---|
273 | cd > prompt.txt |
---|
274 | call inp2var.bat here prompt.txt no_input |
---|
275 | echo Deploying %app_name% into %catalina_home% |
---|
276 | echo ________________________________________________________________________ |
---|
277 | echo. |
---|
278 | echo Copying new installation from %here%\www to %catalina_home%\webapps\www. |
---|
279 | xcopy "%here%"\www "%catalina_home%"\webapps\www /E /I /V /Q |
---|
280 | if ERRORLEVEL 1 goto failure |
---|
281 | echo Removing old installation. |
---|
282 | rmdir "%catalina_home%"\webapps\%app_name% /S /Q |
---|
283 | if ERRORLEVEL 1 goto failure |
---|
284 | echo Activating new installation in %catalina_home%\webapps\%app_name%. |
---|
285 | move "%catalina_home%"\webapps\www "%catalina_home%"\webapps\%app_name% |
---|
286 | if ERRORLEVEL 1 goto failure |
---|
287 | |
---|
288 | rem |
---|
289 | rem Print finishing remarks |
---|
290 | rem |
---|
291 | :step_5a |
---|
292 | set body_text=%app_name% is now updated. Restart tomcat before use. |
---|
293 | set next_step=step_5b |
---|
294 | goto print |
---|
295 | :step_5b |
---|
296 | echo. |
---|
297 | echo. |
---|
298 | |
---|
299 | goto finish |
---|
300 | |
---|
301 | |
---|
302 | :print |
---|
303 | rem |
---|
304 | rem Subroutine print |
---|
305 | rem |
---|
306 | rem Prints header text for current step. |
---|
307 | rem |
---|
308 | rem Argument %body_text%: String to print |
---|
309 | rem Argument %next_step%: Return label when finished |
---|
310 | rem |
---|
311 | echo. |
---|
312 | echo. |
---|
313 | echo %body_text% |
---|
314 | echo. |
---|
315 | goto %next_step% |
---|
316 | |
---|
317 | |
---|
318 | :copy_file_from_tomcat_installation |
---|
319 | rem |
---|
320 | rem Subroutine copy_file_from_tomcat_installation |
---|
321 | rem |
---|
322 | rem Argument %filename%: Name of file to copy |
---|
323 | rem Argument %rel_path%: Directory path relative to WEB-INF\classes\ directory |
---|
324 | rem Argument %next_step%: Return label when finished |
---|
325 | rem |
---|
326 | cd %build_dir%\%rel_path% |
---|
327 | if exist "%catalina_inst_dir%\%rel_path%\%filename%" goto tomcat_config_file_ok |
---|
328 | echo No configuration file %filename% to copy from previous Tomcat installation. |
---|
329 | goto tomcat_config_file_end |
---|
330 | :tomcat_config_file_ok |
---|
331 | echo Copying file %filename% from previous Tomcat installation. |
---|
332 | copy "%catalina_inst_dir%\%rel_path%\%filename%" %filename% |
---|
333 | :tomcat_config_file_end |
---|
334 | cd %here% |
---|
335 | goto %next_step% |
---|
336 | |
---|
337 | |
---|
338 | :check_if_necessary_configuration_file_exists |
---|
339 | rem |
---|
340 | rem Subroutine check_if_necessary_configuration_file_exists |
---|
341 | rem |
---|
342 | rem Argument %filename%: Name of file to check |
---|
343 | rem Argument %rel_path%: Directory path relative to WEB-INF\classes\ directory |
---|
344 | rem Argument %next_step%: Return label when finished |
---|
345 | rem |
---|
346 | cd %build_dir%\%rel_path% |
---|
347 | if exist %filename% goto necessary_config_file_ok |
---|
348 | echo Configuration file %filename% missing - Use installation script instead. |
---|
349 | goto finish |
---|
350 | :necessary_config_file_ok |
---|
351 | echo Configuration file %filename% exists - OK. |
---|
352 | cd %here% |
---|
353 | goto %next_step% |
---|
354 | |
---|
355 | |
---|
356 | :create_config_file_if_not_existing |
---|
357 | rem |
---|
358 | rem Subroutine create_config_file_if_not_existing |
---|
359 | rem |
---|
360 | rem Argument %filename%: Name of file to create |
---|
361 | rem Argument %rel_path%: Directory path relative to WEB-INF\classes\ directory |
---|
362 | rem Argument %file_title%: file title |
---|
363 | rem Argument %next_step%: Return label when finished |
---|
364 | rem |
---|
365 | cd %build_dir%\%rel_path% |
---|
366 | if exist %filename% goto config_file_ok |
---|
367 | echo Creating %file_title% config file %fileanme% ... |
---|
368 | copy %filename%.in %filename% |
---|
369 | goto config_file_end |
---|
370 | :config_file_ok |
---|
371 | echo %file_title% config file %filename% exists - OK. |
---|
372 | :config_file_end |
---|
373 | cd %here% |
---|
374 | goto %next_step% |
---|
375 | |
---|
376 | :failure |
---|
377 | echo Installation failed |
---|
378 | goto finish |
---|
379 | |
---|
380 | |
---|
381 | :finish |
---|
382 | rem |
---|
383 | rem Clear used environment variables |
---|
384 | rem |
---|
385 | rem |
---|
386 | rem Remove values of used batch file parameters, |
---|
387 | rem so they cannot be accessed from the command line. |
---|
388 | rem |
---|
389 | set app_name= |
---|
390 | set build_dir= |
---|
391 | set root_pwd= |
---|
392 | set cp= |
---|
393 | set body_text= |
---|
394 | set next_step= |
---|
395 | set here= |
---|
396 | |
---|
397 | echo Press Enter to finish: > prompt.txt |
---|
398 | call inp2var.bat dummy_var prompt.txt |
---|
399 | :end |
---|