source: trunk/misc/install/install-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.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 18.1 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 msinspect.properties file if not existing.
386rem
387cd %build_dir%
388if exist msinspect.properties goto msinspect_properties_file_ok
389echo Creating msInspect feature detection config file msinspect.properties...
390copy msinspect.properties.in msinspect.properties
391goto msinspect_properties_file_end
392:msinspect_properties_file_ok
393echo msInspect feature detection config file msinspect.properties exists - OK.
394:msinspect_properties_file_end
395cd %here%
396
397rem
398rem Create proteios log4j.properties file if not existing.
399rem
400cd %build_dir%
401if exist log4j.properties goto log4j_properties_file_ok
402echo Creating log config file log4j.properties...
403copy log4j.properties.in log4j.properties
404goto log4j_properties_file_end
405:log4j_properties_file_ok
406echo Log config file log4j.properties exists - OK.
407:log4j_properties_file_end
408cd %here%
409
410rem
411rem Build class path
412rem
413set cp=.\%build_dir%
414rem
415rem Note: Variables like %cp% are interpreted before a for-statement
416rem is executed, so a for-loop like
417rem
418rem for %%i in (.\www\WEB-INF\lib\*.jar) do set cp=%cp%;%%i
419rem
420rem will only add the last of the *.jar files to the %cp% list
421rem after the for-loop is finished. This can be solved by calling
422rem a temporary batch file that updates the %cp% value for each loop.
423rem The contents of the temporary batch file tmp1.bat is
424rem
425rem set cp=%cp%;%1
426rem
427rem where %1 is the argument that will be provided by the
428rem for-loop variable %%i.
429rem
430echo set cp=%%cp%%;%%1> tmp1.bat
431for %%i in (.\www\WEB-INF\lib\*.jar) do call tmp1.bat %%i
432del tmp1.bat
433rem
434rem Run proteios java installation program InitDB
435rem
436rem java -server -cp %cp% org.proteios.install.InitDB %root_pwd%
437
438rem
439rem Initialize database.
440rem
441if not "%update_db%"=="Y" goto no_update
442java -cp %cp% org.proteios.install.InitDB update %root_pwd%
443goto db_init_end
444:no_update
445java -cp %cp% org.proteios.install.InitDB %root_pwd%
446:db_init_end
447
448rem
449rem Create user files directory if not existing.
450rem
451if exist %user_files_dir% goto user_files_dir_ok
452echo Creating user files directory...
453mkdir %user_files_dir%
454rem
455rem Check if user files directory exists.
456rem
457if exist %user_files_dir% goto user_files_dir_ok2
458echo Failed.
459echo User files directory could not be created.
460echo Create user files directory %user_files_dir% yourself.
461goto user_files_dir_end
462:user_files_dir_ok2
463echo done
464goto user_files_dir_end
465:user_files_dir_ok
466echo User files directory exists - OK.
467:user_files_dir_end
468
469rem
470rem Create "conf" directory in user files directory if not existing.
471rem
472if exist "%user_files_dir%\conf" goto user_files_conf_dir_ok
473echo Creating \"conf\" directory in user files directory...
474mkdir "%user_files_dir%\conf"
475rem
476rem Check if "conf" directory in  user files directory exists.
477rem
478if exist "%user_files_dir%\conf" goto user_files_conf_dir_ok2
479echo Failed.
480echo Directory \"conf\" in user files directory could not be created.
481echo Create \"conf\" directory in user files directory %user_files_dir% yourself.
482goto user_files_conf_dir_end
483:user_files_conf_dir_ok2
484echo done
485goto user_files_dir_end
486:user_files_conf_dir_ok
487echo Directory \"conf\" in user files directory exists - OK.
488:user_files_conf_dir_end
489
490rem
491rem Create temporary files directory if not existing.
492rem
493if exist %temp_files_dir% goto temp_files_dir_ok
494echo Creating temporary files directory...
495mkdir %temp_files_dir%
496rem
497rem Check if temporary files directory exists.
498rem
499if exist %temp_files_dir% goto temp_files_dir_ok2
500echo Failed.
501echo Temporary files directory could not be created.
502echo Create temporary files directory %temp_files_dir% yourself.
503goto temp_files_dir_end
504:temp_files_dir_ok2
505echo done
506goto temp_files_dir_end
507:temp_files_dir_ok
508echo Temporary files directory exists - OK.
509:temp_files_dir_end
510
511rem
512rem Set variable catalina_home (tomcat installation directory)
513rem
514:step_10a
515set body_text=10. Let's deploy the web application into tomcat.
516set next_step=step_10b
517goto print
518:step_10b
519if defined catalina_home goto catalina_ok
520echo    Catalina home: > prompt.txt
521call inp2var.bat catalina_home prompt.txt
522rem echo catalina_home = %catalina_home%
523:catalina_ok
524echo.
525
526rem
527rem Create link in tomcat webapps directory to proteomics directory
528rem
529
530rem
531rem Store current directory in variable %here%
532rem
533cd > prompt.txt
534call inp2var.bat here prompt.txt no_input
535echo Deploying %app_name% into %catalina_home%
536echo ________________________________________________________________________
537echo Copying new installation from %here%\www to %catalina_home%\webapps\www.
538xcopy "%here%"\www "%catalina_home%"\webapps\www /E /I /V /Q
539if ERRORLEVEL 1 goto failure
540echo Removing old installation.
541rmdir "%catalina_home%"\webapps\%app_name% /S /Q
542if ERRORLEVEL 1 goto failure
543echo Activating new installation in %catalina_home%\webapps\%app_name%.
544move "%catalina_home%"\webapps\www "%catalina_home%"\webapps\%app_name%
545if ERRORLEVEL 1 goto failure
546echo ________________________________________________________________________
547echo.
548
549rem
550rem Update proteios Proteios FTP Server start script (bat-file)
551rem
552echo Updating Proteios FTP Server start script (bat-file)
553cd %here%
554rem
555rem Insert Tomcat installation directory
556rem in file proteios_ftp_server.bat.in.
557rem
558java -jar "%here%"\Replace.jar proteios_ftp_server.bat.in proteios_ftp_server.bat __CATALINA_HOME__="%catalina_home%"
559rem
560rem Insert Tomcat installation directory
561rem in files proteios_ftp_server_start.bat.in.
562rem and proteios_ftp_server_stop.bat.in.
563rem
564java -jar "%here%"\Replace.jar proteios_ftp_server_start.bat.in proteios_ftp_server_start.bat __CATALINA_HOME__="%catalina_home%"
565java -jar "%here%"\Replace.jar proteios_ftp_server_stop.bat.in proteios_ftp_server_stop.bat __CATALINA_HOME__="%catalina_home%"
566cd %here%
567echo.
568
569rem
570rem Print finishing remarks
571rem
572:step_11a
573set body_text=%app_name% is now installed. Start tomcat before use.
574set next_step=step_11b
575goto print
576:step_11b
577echo.
578echo.
579rem
580rem Extra dummy input to keep command prompt window open until input is given
581rem
582echo    Press Enter to finish: > prompt.txt
583call inp2var.bat dummy_var prompt.txt
584
585goto finish
586
587
588:print
589rem
590rem Subroutine print
591rem
592rem
593rem Prints header text for current step.
594rem
595  echo.
596  echo.
597  echo %body_text%
598  echo.
599goto %next_step%
600
601
602:failure
603echo Activation of installation failed
604goto step_11b
605
606:finish
607rem
608rem Clear used environment variables
609rem
610rem
611rem Remove values of used batch file parameters,
612rem so they cannot be accessed from the command line.
613rem
614  set db_socket=
615  set sql_client=
616  set app_name=
617  set db_manager=
618  set db_manager_pwd=
619  set db_name=
620  set db_host=
621  set app_user=
622  set app_user_pwd=
623  set user_files_dir=
624  set user_files_dir_slashes=
625  set ftp_control_port=
626  set ftp_passive_port_range=
627  set mail_server=
628  set mail_from_address=
629  set sql_exec=
630  set continue_install=
631  set drop_db=
632  set cp=
633  set body_text=
634  set next_step= 
635  set here= 
636  set dummy_var= 
637:end
Note: See TracBrowser for help on using the repository browser.