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

Last change on this file since 4551 was 4551, checked in by Fredrik Levander, 9 years ago

Refs #630. Added support for URIs with basic authentication. Refs #823. Added possibilities to specify alternate URIs in connection-properties file. Updated installation scripts for the connection-properties file.

File size: 10.6 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
160set filename=connection.properties
161set rel_path="."
162set next_step=step_1c11
163goto copy_file_from_tomcat_installation
164:step_1c11
165
166rem
167rem Check if necessary configuration files exist.
168rem
169:step_2a
170set body_text=2. Checking if necessary configuration files exist.
171set next_step=step_2b
172goto print
173:step_2b
174echo.
175
176set filename=proteios.config
177set rel_path="."
178set next_step=step_2c1
179goto check_if_necessary_configuration_file_exists
180:step_2c1
181
182set filename=web.xml
183set rel_path=".."
184set next_step=step_2c2
185goto check_if_necessary_configuration_file_exists
186:step_2c2
187
188set filename=ftp.properties
189set rel_path="."
190set next_step=step_2c3
191goto check_if_necessary_configuration_file_exists
192:step_2c3
193
194rem
195rem Create other configuration files if not existing.
196rem
197:step_3a
198set body_text=3. Create other configuration files if not existing.
199set next_step=step_3b
200goto print
201:step_3b
202echo.
203
204set filename=xtandem.properties
205set rel_path="."
206set file_title="X!Tandem search"
207set next_step=step_3c1
208goto create_config_file_if_not_existing
209:step_3c1
210
211set filename=mascot.properties
212set rel_path="."
213set file_title="Mascot search"
214set next_step=step_3c2
215goto create_config_file_if_not_existing
216:step_3c2
217
218set filename=omssa.properties
219set rel_path="."
220set file_title="OMSSA search"
221set next_step=step_3c3
222goto create_config_file_if_not_existing
223:step_3c3
224
225set filename=pike.properties
226set rel_path="."
227set file_title="PIKE search"
228set next_step=step_3c4
229goto create_config_file_if_not_existing
230:step_3c4
231
232set filename=msinspect.properties
233set rel_path="."
234set file_title="msInspect feature detection"
235set next_step=step_3c5
236goto create_config_file_if_not_existing
237:step_3c5
238
239set filename=openms.properties
240set rel_path="."
241set file_title="OpenMS feature detection"
242set next_step=step_3c6
243goto create_config_file_if_not_existing
244:step_3c6
245
246set filename=log4j.properties
247set rel_path="."
248set file_title="Log"
249set next_step=step_3c7
250goto create_config_file_if_not_existing
251:step_3c7
252
253set filename=connection.properties
254set rel_path="."
255set file_title="Connection"
256set next_step=step_3c8
257goto create_config_file_if_not_existing
258:step_3c8
259
260rem
261rem Get Proteios root password
262rem
263:step_4a
264set body_text=4. Enter a password for the root account in %app_name%.
265set next_step=step_4b
266goto print
267:step_4b
268echo    Password: > prompt.txt
269call inp2var.bat root_pwd prompt.txt mask_input
270echo.
271
272rem
273rem Execute update
274rem
275
276rem
277rem Build class path
278rem
279set cp=.\%build_dir%
280rem
281rem Note: Variables like %cp% are interpreted before a for-statement
282rem is executed, so a for-loop like
283rem
284rem for %%i in (.\www\WEB-INF\lib\*.jar) do set cp=%cp%;%%i
285rem
286rem will only add the last of the *.jar files to the %cp% list
287rem after the for-loop is finished. This can be solved by calling
288rem a temporary batch file that updates the %cp% value for each loop.
289rem The contents of the temporary batch file tmp1.bat is
290rem
291rem set cp=%cp%;%1
292rem
293rem where %1 is the argument that will be provided by the
294rem for-loop variable %%i.
295rem
296echo set cp=%%cp%%;%%1> tmp1.bat
297for %%i in (.\www\WEB-INF\lib\*.jar) do call tmp1.bat %%i
298del tmp1.bat
299
300rem
301rem Update database.
302rem
303java -cp %cp% org.proteios.install.InitDB update %root_pwd%
304
305rem
306rem Create link in tomcat webapps directory to proteomics directory
307rem
308
309rem
310rem Store current directory in variable %here%
311rem
312cd > prompt.txt
313call inp2var.bat here prompt.txt no_input
314echo Deploying %app_name% into %catalina_home%
315echo ________________________________________________________________________
316echo.
317echo Copying new installation from %here%\www to %catalina_home%\webapps\www.
318xcopy "%here%"\www "%catalina_home%"\webapps\www /E /I /V /Q
319if ERRORLEVEL 1 goto failure
320echo Removing old installation.
321rmdir "%catalina_home%"\webapps\%app_name% /S /Q
322if ERRORLEVEL 1 goto failure
323echo Activating new installation in %catalina_home%\webapps\%app_name%.
324move "%catalina_home%"\webapps\www "%catalina_home%"\webapps\%app_name%
325if ERRORLEVEL 1 goto failure
326
327rem
328rem Print finishing remarks
329rem
330:step_5a
331set body_text=%app_name% is now updated. Restart tomcat before use.
332set next_step=step_5b
333goto print
334:step_5b
335echo.
336echo.
337
338goto finish
339
340
341:print
342rem
343rem Subroutine print
344rem
345rem Prints header text for current step.
346rem
347rem Argument %body_text%: String to print
348rem Argument %next_step%: Return label when finished
349rem
350  echo.
351  echo.
352  echo %body_text%
353  echo.
354goto %next_step%
355
356
357:copy_file_from_tomcat_installation
358rem
359rem Subroutine copy_file_from_tomcat_installation
360rem
361rem Argument %filename%: Name of file to copy
362rem Argument %rel_path%: Directory path relative to WEB-INF\classes\ directory
363rem Argument %next_step%: Return label when finished
364rem
365cd %build_dir%\%rel_path%
366if exist "%catalina_inst_dir%\%rel_path%\%filename%" goto tomcat_config_file_ok
367echo No configuration file %filename% to copy from previous Tomcat installation.
368goto tomcat_config_file_end
369:tomcat_config_file_ok
370echo Copying file %filename% from previous Tomcat installation.
371copy "%catalina_inst_dir%\%rel_path%\%filename%" %filename%
372:tomcat_config_file_end
373cd %here%
374goto %next_step%
375
376
377:check_if_necessary_configuration_file_exists
378rem
379rem Subroutine check_if_necessary_configuration_file_exists
380rem
381rem Argument %filename%: Name of file to check
382rem Argument %rel_path%: Directory path relative to WEB-INF\classes\ directory
383rem Argument %next_step%: Return label when finished
384rem
385cd %build_dir%\%rel_path%
386if exist %filename% goto necessary_config_file_ok
387echo Configuration file %filename% missing - Use installation script instead.
388goto finish
389:necessary_config_file_ok
390echo Configuration file %filename% exists - OK.
391cd %here%
392goto %next_step%
393
394
395:create_config_file_if_not_existing
396rem
397rem Subroutine create_config_file_if_not_existing
398rem
399rem Argument %filename%: Name of file to create
400rem Argument %rel_path%: Directory path relative to WEB-INF\classes\ directory
401rem Argument %file_title%: file title
402rem Argument %next_step%: Return label when finished
403rem
404cd %build_dir%\%rel_path%
405if exist %filename% goto config_file_ok
406echo Creating %file_title% config file %fileanme% ...
407copy %filename%.in %filename%
408goto config_file_end
409:config_file_ok
410echo %file_title% config file %filename% exists - OK.
411:config_file_end
412cd %here%
413goto %next_step%
414
415:failure
416echo Installation failed
417goto finish
418
419
420:finish
421rem
422rem Clear used environment variables
423rem
424rem
425rem Remove values of used batch file parameters,
426rem so they cannot be accessed from the command line.
427rem
428  set app_name=
429  set build_dir=
430  set root_pwd=
431  set cp=
432  set body_text=
433  set next_step= 
434  set here= 
435 
436echo    Press Enter to finish: > prompt.txt
437call inp2var.bat dummy_var prompt.txt
438:end
Note: See TracBrowser for help on using the repository browser.