source: trunk/misc/install/update_proteios-win.bat @ 4181

Last change on this file since 4181 was 4181, checked in by olle, 12 years ago

Refs #744. Proteios SE update bat-file for MS Windows updated to create OpenMS properties file openms.properties from template file openms.properties.in, if not existing:

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