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

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

Refs #668. Proteios SE installation and update bat-files for MS Windows updated to support msInspect properties file msinspect.properties:

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