1 | #!/bin/sh |
---|
2 | |
---|
3 | # $Id: init.sh 4084 2010-12-20 12:40:56Z olle $ |
---|
4 | |
---|
5 | # Copyright (C) 2009 Gregory Vincic |
---|
6 | |
---|
7 | # Files are copyright by their respective authors. The contributions to |
---|
8 | # files where copyright is not explicitly stated can be traced with the |
---|
9 | # source code revision system. |
---|
10 | |
---|
11 | # This file is part of Proteios. |
---|
12 | # Available at http://www.proteios.org/ |
---|
13 | |
---|
14 | # Proteios is free software; you can redistribute it and/or |
---|
15 | # modify it under the terms of the GNU General Public License |
---|
16 | # as published by the Free Software Foundation; either version 2 |
---|
17 | # of the License, or (at your option) any later version. |
---|
18 | |
---|
19 | # Proteios is distributed in the hope that it will be useful, |
---|
20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
22 | # GNU General Public License for more details. |
---|
23 | |
---|
24 | # You should have received a copy of the GNU General Public License |
---|
25 | # along with this program; if not, write to the Free Software |
---|
26 | # Foundation, Inc., 59 Temple Place - Suite 330, |
---|
27 | # Boston, MA 02111-1307, USA. |
---|
28 | |
---|
29 | # Configuration script that should be used after istallation. (rpm only) |
---|
30 | |
---|
31 | . ./config |
---|
32 | |
---|
33 | |
---|
34 | stty -echo |
---|
35 | read -p "Mysql password for user $DB_MANAGER: " DB_MANAGER_PWD; echo |
---|
36 | SQL_EXEC="mysql -h $DB_HOST -u $DB_MANAGER -p$DB_MANAGER_PWD -e" |
---|
37 | DB_EXISTS=`$SQL_EXEC "show databases" | grep "^$DB_NAME\$"` |
---|
38 | if [ "$DB_EXISTS" == "$DB_NAME" ]; then |
---|
39 | echo "Database '$DB_NAME' already exists. Change DB_NAME in config file and try again." |
---|
40 | stty echo |
---|
41 | exit |
---|
42 | fi |
---|
43 | |
---|
44 | read -p "Proteios SE password for root: " APP_ROOT_PWD; echo |
---|
45 | stty echo |
---|
46 | HOST_NAME=`java -jar lib/GetHostName.jar` |
---|
47 | |
---|
48 | |
---|
49 | # Create database and user |
---|
50 | $SQL_EXEC "CREATE DATABASE IF NOT EXISTS \`$DB_NAME\` DEFAULT CHARACTER SET utf8;" |
---|
51 | $SQL_EXEC "GRANT ALL ON \`$DB_NAME\`.* TO '$APP_USER'@'$DB_HOST' IDENTIFIED BY '$APP_USER_PWD'; FLUSH PRIVILEGES;" |
---|
52 | |
---|
53 | # Update proteios web.xml file (used by Tomcat) |
---|
54 | java -jar lib/Replace.jar \ |
---|
55 | web.xml.in web.xml \ |
---|
56 | __TEMPFILES__="$TEMP_FILES_DIR" |
---|
57 | |
---|
58 | cd classes |
---|
59 | java -jar ../lib/Replace.jar \ |
---|
60 | proteios.config.in proteios.config \ |
---|
61 | __USERNAME__=$APP_USER \ |
---|
62 | __PASSWORD__=$APP_USER_PWD \ |
---|
63 | __DATABASE__=$DB_NAME \ |
---|
64 | __USERFILES__="$USER_FILES_DIR" \ |
---|
65 | __HOST__=$DB_HOST \ |
---|
66 | __SMTPHOST__=$MAIL_SERVER \ |
---|
67 | __MAIL_FROM_ADDRESS__=$MAIL_FROM_ADDRESS |
---|
68 | |
---|
69 | |
---|
70 | # Update proteios ftp.properties file (used by FTP Server) |
---|
71 | java -jar ../lib/Replace.jar \ |
---|
72 | ftp.properties.in ftp.properties \ |
---|
73 | __CONTROL_PORT__=$FTP_CONTROL_PORT \ |
---|
74 | __PASSIVE_PORT_RANGE__=$FTP_PASSIVE_PORT_RANGE \ |
---|
75 | __USERNAME__=$APP_USER \ |
---|
76 | __PASSWORD__=$APP_USER_PWD \ |
---|
77 | __DATABASE__=$DB_NAME \ |
---|
78 | __USERFILES__="$USER_FILES_DIR" \ |
---|
79 | __HOST__=$DB_HOST |
---|
80 | |
---|
81 | # Create proteios xtandem.properties file if not existing. |
---|
82 | if [ ! -f xtandem.properties ]; then |
---|
83 | cp -p xtandem.properties.in xtandem.properties |
---|
84 | fi |
---|
85 | |
---|
86 | # Create proteios mascot.properties file if not existing. |
---|
87 | if [ ! -f mascot.properties ]; then |
---|
88 | cp -p mascot.properties.in mascot.properties |
---|
89 | fi |
---|
90 | |
---|
91 | # Create proteios omssa.properties file if not existing. |
---|
92 | if [ ! -f omssa.properties ]; then |
---|
93 | cp -p omssa.properties.in omssa.properties |
---|
94 | fi |
---|
95 | |
---|
96 | # Create proteios pike.properties file if not existing. |
---|
97 | if [ ! -f pike.properties ]; then |
---|
98 | cp -p pike.properties.in pike.properties |
---|
99 | fi |
---|
100 | |
---|
101 | # Create proteios msinspect.properties file if not existing. |
---|
102 | if [ ! -f msinspect.properties ]; then |
---|
103 | cp -p msinspect.properties.in msinspect.properties |
---|
104 | fi |
---|
105 | |
---|
106 | # Create proteios log4j.properties file if not existing. |
---|
107 | if [ ! -f log4j.properties ]; then |
---|
108 | cp -p log4j.properties.in log4j.properties |
---|
109 | fi |
---|
110 | |
---|
111 | # Update proteios Proteios FTP Server start script |
---|
112 | java -jar ../lib/Replace.jar \ |
---|
113 | $SERVICE_PATH/proteios_ftp_server.sh.in $SERVICE_PATH/proteios_ftp_server.sh \ |
---|
114 | __CATALINA_HOME__="$CATALINA_HOME" \ |
---|
115 | __FTP_CONTROL_PORT__=$FTP_CONTROL_PORT \ |
---|
116 | __TEMP_FILES_DIR__=$TEMP_FILES_DIR |
---|
117 | |
---|
118 | # End configuration replacements |
---|
119 | cd .. |
---|
120 | |
---|
121 | # Build classpath |
---|
122 | CP=classes |
---|
123 | for i in `ls lib/*.jar`; do CP=${CP}:${i}; done |
---|
124 | |
---|
125 | # Create user files directory if not existing. |
---|
126 | mkdir -p "$USER_FILES_DIR/conf" |
---|
127 | chown $TOMCAT_USER -R $USER_FILES_DIR |
---|
128 | chgrp $TOMCAT_GROUP -R $USER_FILES_DIR |
---|
129 | |
---|
130 | # Create temporary files directory if not existing. |
---|
131 | mkdir -p "$TEMP_FILES_DIR" |
---|
132 | chown $TOMCAT_USER -R $TEMP_FILES_DIR |
---|
133 | chgrp $TOMCAT_GROUP -R $TEMP_FILES_DIR |
---|
134 | |
---|
135 | # Initialize database |
---|
136 | java -server -cp $CP org.proteios.install.InitDB $APP_ROOT_PWD |
---|
137 | |
---|
138 | |
---|
139 | if [ -e $SERVICE_PATH/proteios_ftp_server.sh ]; then |
---|
140 | chmod ugo+x $SERVICE_PATH/proteios_ftp_server.sh |
---|
141 | else |
---|
142 | echo "warning: $SERVICE_PATH/proteios_ftp_server.sh is missing" |
---|
143 | fi |
---|
144 | |
---|
145 | |
---|