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

Last change on this file since 3546 was 3546, checked in by Fredrik Levander, 13 years ago

Fixes #644. Updated scripts to copy files into tomcat installation and overwrite existing installation.

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