source: trunk/misc/install/install-win.bat @ 4000

Last change on this file since 4000 was 4000, checked in by olle, 13 years ago

Refs #715. Proteios SE installation script file install-win.bat
in misc/install/ updated to allow an installation directory
with spaces in the name:

  1. Proteios SE installation script file install-win.bat

in misc/install/ updated by enclosing the variable storing
the name of the installation directory in double quotation marks
("") when the value is used as path for java program Replace.jar.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 17.7 KB
Line 
1@echo off
2rem
3rem install-win.bat
4rem
5
6rem Copyright (C) 2006 Gregory Vincic, Jari Hakkinen, Olle Mansson
7rem Copyright (C) 2007 Gregory Vincic, Olle Mansson
8rem
9rem Files are copyright by their respective authors. The contributions to
10rem files where copyright is not explicitly stated can be traced with the
11rem source code revision system.
12rem
13rem This file is part of Proteios.
14rem Available at http://www.proteios.org/
15rem
16rem Proteios is free software; you can redistribute it and/or
17rem modify it under the terms of the GNU General Public License
18rem as published by the Free Software Foundation; either version 2
19rem of the License, or (at your option) any later version.
20rem
21rem Proteios is distributed in the hope that it will be useful,
22rem but WITHOUT ANY WARRANTY, without even the implied warranty of
23rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24rem GNU General Public License for more details.
25rem
26rem You should have received a copy of the GNU General Public License
27rem along with this program; if not, write to the Free Software
28rem Foundation, Inc., 59 Temple Place - Suite 330,
29rem Boston, MA 02111-1307, USA.
30
31rem
32rem Performs Proteios 2.x installation on Microsoft Windows.
33rem
34rem Uses bat file inp2var.bat to store console input data
35rem into a given variable.
36rem
37rem Usage: inp2var.bat var_name [promptfile [mask_input]]
38rem
39rem Used programs/files:
40rem
41rem inp2var.bat
42rem   inp2var.jar
43rem Replace.jar
44rem
45
46rem
47rem Configuration
48rem
49set sql_client=mysql
50set app_name=proteios
51set build_dir=www\WEB-INF\classes
52rem Store system host name in environment variable %host_name% for use in default notification e-mail "from"-address
53java -jar GetHostName.jar > prompt.txt
54call inp2var.bat host_name prompt.txt no_input
55rem
56rem End Configuration
57rem
58
59rem
60rem Welcome message and installation references
61rem
62echo.
63echo.
64echo Welcome to the %app_name% installation.
65echo.
66echo For more information on the installation steps, see:
67echo http://www.proteios.org/wiki/Installation
68echo.
69
70rem
71rem Get DBMS hostname, administrator name and password
72rem
73:step_1a
74set body_text=1. Enter database host name and user name with create privileges on your DBMS.
75set next_step=step_1b
76goto print
77:step_1b
78echo    Database Host [localhost]: > prompt.txt
79call inp2var.bat db_host prompt.txt
80if "%db_host%"=="" set db_host=localhost
81echo    Username [root]: > prompt.txt
82call inp2var.bat db_manager prompt.txt
83if "%db_manager%"=="" set db_manager=root
84echo    Password: > prompt.txt
85call inp2var.bat db_manager_pwd prompt.txt mask_input
86echo.
87
88rem
89rem Get Proteios root password
90rem
91:step_2a
92set body_text=2. Enter a password for the root account in %app_name%.
93set next_step=step_2b
94goto print
95:step_2b
96echo    Password: > prompt.txt
97call inp2var.bat root_pwd prompt.txt mask_input
98echo.
99
100rem
101rem Get DBMS name
102rem
103:step_3a
104set body_text=3. Configure the database name and user that %app_name% will use to connect to your DBMS.
105set next_step=step_3b
106goto print
107:step_3b
108echo    Database name [%app_name%]: > prompt.txt
109call inp2var.bat db_name prompt.txt
110if "%db_name%"=="" set db_name=%app_name%
111
112rem
113rem Get DBMS user name and password
114rem
115echo    Username [%app_name%]: > prompt.txt
116call inp2var.bat app_user prompt.txt
117if "%app_user%"=="" set app_user=%app_name%
118echo    Password: > prompt.txt
119call inp2var.bat app_user_pwd prompt.txt mask_input
120echo.
121
122
123rem
124rem Get user files directory.
125rem
126:step_4a
127set body_text=4. Select a directory for %app_name% to use for user files.
128set next_step=step_4b
129goto print
130:step_4b
131echo    User files directory [C:\%app_name%]: > prompt.txt
132call inp2var.bat user_files_dir prompt.txt
133if "%user_files_dir%"=="" set user_files_dir=C:\%app_name%
134rem
135rem Store user files directory name with backslashes "\"
136rem exchanged for slashes "/" in variable %user_files_dir_slashes%
137rem
138echo %user_files_dir% > prompt.txt
139call inp2var.bat user_files_dir_slashes prompt.txt no_input_convert_backslashes
140
141rem
142rem Get temporary files directory.
143rem
144:step_5a
145set body_text=5. Select a directory for %app_name% to use for temporary files.
146set next_step=step_5b
147goto print
148:step_5b
149echo    Temporary files directory [C:\temp]: > prompt.txt
150call inp2var.bat temp_files_dir prompt.txt
151if "%temp_files_dir%"=="" set temp_files_dir=C:\temp
152rem
153rem Store temporary files directory name with backslashes "\"
154rem exchanged for slashes "/" in variable %temp_files_dir_slashes%
155rem
156echo %temp_files_dir% > prompt.txt
157call inp2var.bat temp_files_dir_slashes prompt.txt no_input_convert_backslashes
158
159rem
160rem Get FTP control port.
161rem
162:step_6a
163set body_text=6. Select control port for %app_name% FTP Server.
164set next_step=step_6b
165goto print
166:step_6b
167echo    FTP Server Control Port [8021]: > prompt.txt
168call inp2var.bat ftp_control_port prompt.txt
169if "%ftp_control_port%"=="" set ftp_control_port=8021
170
171rem
172rem Get optional FTP passive port range.
173rem
174:step_7a
175set body_text=7. Set optional passive port range for %app_name% FTP Server (min,max or blank).
176set next_step=step_7b
177goto print
178:step_7b
179echo    FTP Server Passive Port Range []: > prompt.txt
180call inp2var.bat ftp_passive_port_range prompt.txt
181if "%ftp_passive_port_range%"=="" set ftp_passive_port_range=
182
183rem
184rem Get outgoing mail server for notification e-mail.
185rem
186:step_8a
187set body_text=8. Set outgoing mail server for %app_name% notification e-mail.
188set next_step=step_8b
189goto print
190:step_8b
191echo    Mail server []: > prompt.txt
192call inp2var.bat mail_server prompt.txt
193if "%mail_server%"=="" set mail_server=
194
195rem
196rem Get "from"-address for notification e-mail.
197rem
198:step_9a
199set body_text=9. Set "from"-address for %app_name% notification e-mail.
200set next_step=step_9b
201goto print
202:step_9b
203echo    Mail "from"-address [noreply@%host_name%]: > prompt.txt
204call inp2var.bat mail_from_address prompt.txt
205if "%mail_from_address%"=="" set mail_from_address=noreply@%host_name%
206
207:step_9c
208rem
209rem Print summary of selected options
210rem
211set body_text=Thank you! Selected options for the installation:
212set next_step=step_9c1
213goto print
214:step_9c1
215echo    Database Host name       : %db_host%
216echo    Database Manager Username: %db_manager%
217echo    Database name            : %db_name%
218echo    '%app_name%' Database Username                 : %app_user%
219echo    '%app_name%' User Files Directory              : %user_files_dir%
220echo    '%app_name%' Temporary Files Directory         : %temp_files_dir%
221echo    '%app_name%' FTP Server Control Port           : %ftp_control_port%
222echo    '%app_name%' FTP Server Passive Port Range     : %ftp_passive_port_range%
223echo    '%app_name%' Outgoing mail server              : %mail_server%
224echo    '%app_name%' notification e-mail "from"-address: %mail_from_address%
225echo.
226echo Do you want to continue the installation[y/N]? > prompt.txt
227call inp2var.bat continue_install prompt.txt
228if "%continue_install%"=="" set continue_install=N
229if "%continue_install%"=="y" set continue_install=Y
230if not "%continue_install%"=="Y" set continue_install=N
231if "%continue_install%"=="Y" goto yes_install
232set body_text=Installation stopped. Please try again later.
233set next_step=step_9c2
234goto print
235:step_9c2
236goto finish
237rem
238rem
239rem
240:yes_install
241set body_text=Let's continue with the installation.
242set next_step=step_9c3
243goto print
244:step_9c3
245
246
247rem
248rem Installation
249rem
250rem
251rem Database setup. If database at localhost, do not use -h option.
252rem
253set sql_exec=%sql_client% -h %db_host% -u %db_manager% -p%db_manager_pwd% -e
254if "%db_host%"=="localhost" set sql_exec=%sql_client% -u %db_manager% -p%db_manager_pwd% -e
255rem
256rem Only ask if database should be dropped, if it shouldn't be updated.
257rem
258echo Do you want to update an existing '%db_name%' database [y/N]? > prompt.txt
259call inp2var.bat update_db prompt.txt
260if "%update_db%"=="" set update_db=N
261if "%update_db%"=="y" set update_db=Y
262if not "%update_db%"=="Y" set update_db=N
263if "%update_db%"=="Y" goto yes_update
264rem
265rem No database update, ask if database should be dropped.
266rem
267echo Do you want to drop the existing '%db_name%' database [y/N]? > prompt.txt
268call inp2var.bat drop_db prompt.txt
269if "%drop_db%"=="" set drop_db=N
270if "%drop_db%"=="y" set drop_db=Y
271if not "%drop_db%"=="Y" set drop_db=N
272if "%drop_db%"=="N" goto no_drop
273rem
274rem Dropping existing database [optional]
275rem
276echo Dropping database...
277%sql_exec% "DROP DATABASE IF EXISTS `%db_name%`;"
278echo done
279:no_drop
280:yes_update
281
282rem
283rem Create database if not existing
284rem
285rem (Error checking is needed here)
286rem
287%sql_exec% "CREATE DATABASE IF NOT EXISTS `%db_name%` DEFAULT CHARACTER SET utf8;"
288%sql_exec% "GRANT ALL ON `%db_name%`.* TO '%app_user%'@'%db_host%' IDENTIFIED BY '%app_user_pwd%'; FLUSH PRIVILEGES;"
289
290rem
291rem Update proteios configuration file (parsed by InitDB program)
292rem
293rem
294rem Store current directory in variable %here%
295rem
296cd > prompt.txt
297call inp2var.bat here prompt.txt no_input
298echo Updating %app_name% *.config files in %build_dir%
299cd %build_dir%
300rem
301rem Insert database username, password, name, and user files directory
302rem in file proteios.config.in.
303rem
304java -jar "%here%"\Replace.jar proteios.config.in proteios.config __USERNAME__=%app_user% __PASSWORD__=%app_user_pwd% __DATABASE__=%db_name% __USERFILES__=%user_files_dir_slashes% __HOST__=%db_host% __SMTPHOST__=%mail_server% __MAIL_FROM_ADDRESS__=%mail_from_address%
305cd %here%
306
307rem
308rem Update proteios web.xml file (used by Tomcat)
309rem
310echo Updating %app_name% web.xml file
311cd %build_dir%\..
312rem
313rem Insert temporary files directory
314rem in file web.xml.in.
315rem
316java -jar "%here%"\Replace.jar web.xml.in web.xml __TEMPFILES__=%temp_files_dir_slashes%
317cd %here%
318
319rem
320rem Update proteios ftp.properties file (used by FTP Server)
321rem
322echo Updating %app_name% ftp.properties file
323cd %build_dir%
324rem
325rem Insert control port number
326rem and passive port range
327rem in file ftp.properties.in.
328rem
329java -jar "%here%"\Replace.jar ftp.properties.in ftp.properties __CONTROL_PORT__=%ftp_control_port% __PASSIVE_PORT_RANGE__=%ftp_passive_port_range% __USERNAME__=%app_user% __PASSWORD__=%app_user_pwd% __DATABASE__=%db_name% __USERFILES__=%user_files_dir_slashes%  __HOST__=%db_host%
330cd %here%
331
332rem
333rem Create proteios xtandem.properties file if not existing.
334rem
335cd %build_dir%
336if exist xtandem.properties goto xtandem_properties_file_ok
337echo Creating X!Tandem search config file xtandem.properties...
338copy xtandem.properties.in xtandem.properties
339goto xtandem_properties_file_end
340:xtandem_properties_file_ok
341echo X!Tandem search config file xtandem.properties exists - OK.
342:xtandem_properties_file_end
343cd %here%
344
345rem
346rem Create proteios mascot.properties file if not existing.
347rem
348cd %build_dir%
349if exist mascot.properties goto mascot_properties_file_ok
350echo Creating Mascot search config file mascot.properties...
351copy mascot.properties.in mascot.properties
352goto mascot_properties_file_end
353:mascot_properties_file_ok
354echo Mascot search config file mascot.properties exists - OK.
355:mascot_properties_file_end
356cd %here%
357
358rem
359rem Create proteios omssa.properties file if not existing.
360rem
361cd %build_dir%
362if exist omssa.properties goto omssa_properties_file_ok
363echo Creating OMSSA search config file omssa.properties...
364copy omssa.properties.in omssa.properties
365goto omssa_properties_file_end
366:omssa_properties_file_ok
367echo OMSSA search config file omssa.properties exists - OK.
368:omssa_properties_file_end
369cd %here%
370
371rem
372rem Create proteios pike.properties file if not existing.
373rem
374cd %build_dir%
375if exist pike.properties goto pike_properties_file_ok
376echo Creating PIKE search config file pike.properties...
377copy pike.properties.in pike.properties
378goto pike_properties_file_end
379:pike_properties_file_ok
380echo PIKE search config file pike.properties exists - OK.
381:pike_properties_file_end
382cd %here%
383
384rem
385rem Create proteios log4j.properties file if not existing.
386rem
387cd %build_dir%
388if exist log4j.properties goto log4j_properties_file_ok
389echo Creating log config file log4j.properties...
390copy log4j.properties.in log4j.properties
391goto log4j_properties_file_end
392:log4j_properties_file_ok
393echo Log config file log4j.properties exists - OK.
394:log4j_properties_file_end
395cd %here%
396
397rem
398rem Build class path
399rem
400set cp=.\%build_dir%
401rem
402rem Note: Variables like %cp% are interpreted before a for-statement
403rem is executed, so a for-loop like
404rem
405rem for %%i in (.\www\WEB-INF\lib\*.jar) do set cp=%cp%;%%i
406rem
407rem will only add the last of the *.jar files to the %cp% list
408rem after the for-loop is finished. This can be solved by calling
409rem a temporary batch file that updates the %cp% value for each loop.
410rem The contents of the temporary batch file tmp1.bat is
411rem
412rem set cp=%cp%;%1
413rem
414rem where %1 is the argument that will be provided by the
415rem for-loop variable %%i.
416rem
417echo set cp=%%cp%%;%%1> tmp1.bat
418for %%i in (.\www\WEB-INF\lib\*.jar) do call tmp1.bat %%i
419del tmp1.bat
420rem
421rem Run proteios java installation program InitDB
422rem
423rem java -server -cp %cp% org.proteios.install.InitDB %root_pwd%
424
425rem
426rem Initialize database.
427rem
428if not "%update_db%"=="Y" goto no_update
429java -cp %cp% org.proteios.install.InitDB update %root_pwd%
430goto db_init_end
431:no_update
432java -cp %cp% org.proteios.install.InitDB %root_pwd%
433:db_init_end
434
435rem
436rem Create user files directory if not existing.
437rem
438if exist %user_files_dir% goto user_files_dir_ok
439echo Creating user files directory...
440mkdir %user_files_dir%
441rem
442rem Check if user files directory exists.
443rem
444if exist %user_files_dir% goto user_files_dir_ok2
445echo Failed.
446echo User files directory could not be created.
447echo Create user files directory %user_files_dir% yourself.
448goto user_files_dir_end
449:user_files_dir_ok2
450echo done
451goto user_files_dir_end
452:user_files_dir_ok
453echo User files directory exists - OK.
454:user_files_dir_end
455
456rem
457rem Create "conf" directory in user files directory if not existing.
458rem
459if exist "%user_files_dir%\conf" goto user_files_conf_dir_ok
460echo Creating \"conf\" directory in user files directory...
461mkdir "%user_files_dir%\conf"
462rem
463rem Check if "conf" directory in  user files directory exists.
464rem
465if exist "%user_files_dir%\conf" goto user_files_conf_dir_ok2
466echo Failed.
467echo Directory \"conf\" in user files directory could not be created.
468echo Create \"conf\" directory in user files directory %user_files_dir% yourself.
469goto user_files_conf_dir_end
470:user_files_conf_dir_ok2
471echo done
472goto user_files_dir_end
473:user_files_conf_dir_ok
474echo Directory \"conf\" in user files directory exists - OK.
475:user_files_conf_dir_end
476
477rem
478rem Create temporary files directory if not existing.
479rem
480if exist %temp_files_dir% goto temp_files_dir_ok
481echo Creating temporary files directory...
482mkdir %temp_files_dir%
483rem
484rem Check if temporary files directory exists.
485rem
486if exist %temp_files_dir% goto temp_files_dir_ok2
487echo Failed.
488echo Temporary files directory could not be created.
489echo Create temporary files directory %temp_files_dir% yourself.
490goto temp_files_dir_end
491:temp_files_dir_ok2
492echo done
493goto temp_files_dir_end
494:temp_files_dir_ok
495echo Temporary files directory exists - OK.
496:temp_files_dir_end
497
498rem
499rem Set variable catalina_home (tomcat installation directory)
500rem
501:step_10a
502set body_text=10. Let's deploy the web application into tomcat.
503set next_step=step_10b
504goto print
505:step_10b
506if defined catalina_home goto catalina_ok
507echo    Catalina home: > prompt.txt
508call inp2var.bat catalina_home prompt.txt
509rem echo catalina_home = %catalina_home%
510:catalina_ok
511echo.
512
513rem
514rem Create link in tomcat webapps directory to proteomics directory
515rem
516
517rem
518rem Store current directory in variable %here%
519rem
520cd > prompt.txt
521call inp2var.bat here prompt.txt no_input
522echo Deploying %app_name% into %catalina_home%
523echo ________________________________________________________________________
524echo Copying new installation from %here%\www to %catalina_home%\webapps\www.
525xcopy "%here%"\www "%catalina_home%"\webapps\www /E /I /V /Q
526if ERRORLEVEL 1 goto failure
527echo Removing old installation.
528rmdir "%catalina_home%"\webapps\%app_name% /S /Q
529if ERRORLEVEL 1 goto failure
530echo Activating new installation in %catalina_home%\webapps\%app_name%.
531move "%catalina_home%"\webapps\www "%catalina_home%"\webapps\%app_name%
532if ERRORLEVEL 1 goto failure
533echo ________________________________________________________________________
534echo.
535
536rem
537rem Update proteios Proteios FTP Server start script (bat-file)
538rem
539echo Updating Proteios FTP Server start script (bat-file)
540cd %here%
541rem
542rem Insert Tomcat installation directory
543rem in file proteios_ftp_server.bat.in.
544rem
545java -jar "%here%"\Replace.jar proteios_ftp_server.bat.in proteios_ftp_server.bat __CATALINA_HOME__="%catalina_home%"
546rem
547rem Insert Tomcat installation directory
548rem in files proteios_ftp_server_start.bat.in.
549rem and proteios_ftp_server_stop.bat.in.
550rem
551java -jar "%here%"\Replace.jar proteios_ftp_server_start.bat.in proteios_ftp_server_start.bat __CATALINA_HOME__="%catalina_home%"
552java -jar "%here%"\Replace.jar proteios_ftp_server_stop.bat.in proteios_ftp_server_stop.bat __CATALINA_HOME__="%catalina_home%"
553cd %here%
554echo.
555
556rem
557rem Print finishing remarks
558rem
559:step_11a
560set body_text=%app_name% is now installed. Start tomcat before use.
561set next_step=step_11b
562goto print
563:step_11b
564echo.
565echo.
566rem
567rem Extra dummy input to keep command prompt window open until input is given
568rem
569echo    Press Enter to finish: > prompt.txt
570call inp2var.bat dummy_var prompt.txt
571
572goto finish
573
574
575:print
576rem
577rem Subroutine print
578rem
579rem
580rem Prints header text for current step.
581rem
582  echo.
583  echo.
584  echo %body_text%
585  echo.
586goto %next_step%
587
588
589:failure
590echo Activation of installation failed
591goto step_11b
592
593:finish
594rem
595rem Clear used environment variables
596rem
597rem
598rem Remove values of used batch file parameters,
599rem so they cannot be accessed from the command line.
600rem
601  set db_socket=
602  set sql_client=
603  set app_name=
604  set db_manager=
605  set db_manager_pwd=
606  set db_name=
607  set db_host=
608  set app_user=
609  set app_user_pwd=
610  set user_files_dir=
611  set user_files_dir_slashes=
612  set ftp_control_port=
613  set ftp_passive_port_range=
614  set mail_server=
615  set mail_from_address=
616  set sql_exec=
617  set continue_install=
618  set drop_db=
619  set cp=
620  set body_text=
621  set next_step= 
622  set here= 
623  set dummy_var= 
624:end
Note: See TracBrowser for help on using the repository browser.