4371 |
26 Oct 12 |
olle |
#!/bin/bash |
3140 |
25 Feb 09 |
gregory |
# $Id$ |
3142 |
25 Feb 09 |
gregory |
3 |
|
3142 |
25 Feb 09 |
gregory |
# Copyright (C) 2009 Gregory Vincic |
3142 |
25 Feb 09 |
gregory |
5 |
|
3142 |
25 Feb 09 |
gregory |
# Files are copyright by their respective authors. The contributions to |
3142 |
25 Feb 09 |
gregory |
# files where copyright is not explicitly stated can be traced with the |
3142 |
25 Feb 09 |
gregory |
# source code revision system. |
3142 |
25 Feb 09 |
gregory |
9 |
|
3142 |
25 Feb 09 |
gregory |
# This file is part of Proteios. |
3142 |
25 Feb 09 |
gregory |
# Available at http://www.proteios.org/ |
3142 |
25 Feb 09 |
gregory |
12 |
|
3142 |
25 Feb 09 |
gregory |
# Proteios is free software; you can redistribute it and/or |
3142 |
25 Feb 09 |
gregory |
# modify it under the terms of the GNU General Public License |
3142 |
25 Feb 09 |
gregory |
# as published by the Free Software Foundation; either version 2 |
3142 |
25 Feb 09 |
gregory |
# of the License, or (at your option) any later version. |
3142 |
25 Feb 09 |
gregory |
17 |
|
3142 |
25 Feb 09 |
gregory |
# Proteios is distributed in the hope that it will be useful, |
3142 |
25 Feb 09 |
gregory |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3142 |
25 Feb 09 |
gregory |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3142 |
25 Feb 09 |
gregory |
# GNU General Public License for more details. |
3142 |
25 Feb 09 |
gregory |
22 |
|
3142 |
25 Feb 09 |
gregory |
# You should have received a copy of the GNU General Public License |
3142 |
25 Feb 09 |
gregory |
# along with this program; if not, write to the Free Software |
3142 |
25 Feb 09 |
gregory |
# Foundation, Inc., 59 Temple Place - Suite 330, |
3142 |
25 Feb 09 |
gregory |
# Boston, MA 02111-1307, USA. |
3142 |
25 Feb 09 |
gregory |
27 |
|
4388 |
04 Dec 12 |
olle |
# Initial CATALINA_BASE validation; if not set, set to value of $CATALINA_HOME |
4388 |
04 Dec 12 |
olle |
29 |
if [ ! -d "$CATALINA_BASE" ]; then |
4388 |
04 Dec 12 |
olle |
30 |
CATALINA_BASE=$CATALINA_HOME |
4388 |
04 Dec 12 |
olle |
31 |
fi |
3142 |
25 Feb 09 |
gregory |
32 |
|
3131 |
20 Feb 09 |
gregory |
# Installation of files only. |
4388 |
04 Dec 12 |
olle |
34 |
force=$1 |
3131 |
20 Feb 09 |
gregory |
# Configuration and database initialization is done by configure |
4388 |
04 Dec 12 |
olle |
# Determine what ccnfig script to use |
4390 |
05 Dec 12 |
olle |
# If --force flag is used and Proteios SE installation exists; copy that config script to www/WEB-INF/config |
4388 |
04 Dec 12 |
olle |
38 |
if [ "$force" == "--force" ]; then |
4388 |
04 Dec 12 |
olle |
39 |
if [ -d "$CATALINA_BASE" ]; then |
4388 |
04 Dec 12 |
olle |
40 |
if [ -e $CATALINA_BASE/webapps/proteios/WEB-INF/config ]; then |
4390 |
05 Dec 12 |
olle |
41 |
cp -p "$CATALINA_BASE/webapps/proteios/WEB-INF/config" www/WEB-INF/config |
4388 |
04 Dec 12 |
olle |
42 |
fi |
4388 |
04 Dec 12 |
olle |
43 |
fi |
4388 |
04 Dec 12 |
olle |
44 |
fi |
4390 |
05 Dec 12 |
olle |
# Execute configuration script www/WEB-INF/config |
4390 |
05 Dec 12 |
olle |
46 |
. www/WEB-INF/config |
4388 |
04 Dec 12 |
olle |
47 |
|
4388 |
04 Dec 12 |
olle |
# CATALINA_BASE validation; if not set, try a number of default locations |
4388 |
04 Dec 12 |
olle |
49 |
if [ ! -d "$CATALINA_BASE" ]; then |
4388 |
04 Dec 12 |
olle |
50 |
CATALINA_BASE=/srv/tomcat6 |
4388 |
04 Dec 12 |
olle |
51 |
fi |
4388 |
04 Dec 12 |
olle |
52 |
if [ ! -d "$CATALINA_BASE" ]; then |
4388 |
04 Dec 12 |
olle |
53 |
CATALINA_BASE=/var/lib/tomcat6 |
4388 |
04 Dec 12 |
olle |
54 |
fi |
4388 |
04 Dec 12 |
olle |
55 |
if [ ! -d "$CATALINA_BASE" ]; then |
4388 |
04 Dec 12 |
olle |
56 |
CATALINA_BASE=/srv/tomcat7 |
4388 |
04 Dec 12 |
olle |
57 |
fi |
4388 |
04 Dec 12 |
olle |
58 |
if [ ! -d "$CATALINA_BASE" ]; then |
4388 |
04 Dec 12 |
olle |
59 |
CATALINA_BASE=/var/lib/tomcat7 |
4388 |
04 Dec 12 |
olle |
60 |
fi |
4388 |
04 Dec 12 |
olle |
61 |
if [ ! -d "$CATALINA_BASE" ]; then |
4388 |
04 Dec 12 |
olle |
62 |
echo "Stopped: CATALINA_BASE must be set before running $0" |
3540 |
11 Jan 10 |
gregory |
63 |
exit |
3540 |
11 Jan 10 |
gregory |
64 |
fi |
3540 |
11 Jan 10 |
gregory |
65 |
|
3564 |
15 Feb 10 |
gregory |
66 |
if [ ! -z $PREFIX ]; then |
4388 |
04 Dec 12 |
olle |
67 |
CATALINA_BASE=$PREFIX$CATALINA_BASE |
3564 |
15 Feb 10 |
gregory |
68 |
SERVICE_PATH=$PREFIX$SERVICE_PATH |
4388 |
04 Dec 12 |
olle |
69 |
mkdir -p $CATALINA_BASE $SERVICE_PATH |
3564 |
15 Feb 10 |
gregory |
70 |
fi |
3564 |
15 Feb 10 |
gregory |
71 |
|
3540 |
11 Jan 10 |
gregory |
# Check permissions |
4388 |
04 Dec 12 |
olle |
73 |
if [ ! -w $CATALINA_BASE ]; then |
4388 |
04 Dec 12 |
olle |
74 |
echo "Stopped: You need write access to $CATALINA_BASE" |
3540 |
11 Jan 10 |
gregory |
75 |
exit |
3540 |
11 Jan 10 |
gregory |
76 |
fi |
3540 |
11 Jan 10 |
gregory |
77 |
|
3547 |
20 Jan 10 |
fredrik |
78 |
if [ -e $SERVICE_PATH ]; then |
3547 |
20 Jan 10 |
fredrik |
79 |
if [ ! -w $SERVICE_PATH ]; then |
3558 |
11 Feb 10 |
gregory |
80 |
echo "Stopped: You need write access to $SERVICE_PATH" |
3558 |
11 Feb 10 |
gregory |
81 |
exit |
3558 |
11 Feb 10 |
gregory |
82 |
fi |
3540 |
11 Jan 10 |
gregory |
83 |
fi |
3540 |
11 Jan 10 |
gregory |
84 |
|
4388 |
04 Dec 12 |
olle |
85 |
root=$CATALINA_BASE/webapps/proteios |
3564 |
15 Feb 10 |
gregory |
86 |
|
3139 |
25 Feb 09 |
gregory |
87 |
if [ "$force" != "--force" ]; then |
3139 |
25 Feb 09 |
gregory |
88 |
if [ -e $root ]; then |
3139 |
25 Feb 09 |
gregory |
89 |
echo "Stopped: $root exists already, either remove it or use $0 --force" |
3139 |
25 Feb 09 |
gregory |
90 |
exit |
3139 |
25 Feb 09 |
gregory |
91 |
fi |
3139 |
25 Feb 09 |
gregory |
92 |
fi |
3131 |
20 Feb 09 |
gregory |
93 |
|
3540 |
11 Jan 10 |
gregory |
# The action is the name of the script without any path or suffix |
3133 |
24 Feb 09 |
gregory |
95 |
action=${0##\./} |
3540 |
11 Jan 10 |
gregory |
96 |
action=${action%%\.*} |
3540 |
11 Jan 10 |
gregory |
97 |
|
3133 |
24 Feb 09 |
gregory |
98 |
install() |
3133 |
24 Feb 09 |
gregory |
99 |
{ |
3133 |
24 Feb 09 |
gregory |
100 |
source=$1 |
3133 |
24 Feb 09 |
gregory |
101 |
dest=$2 |
3133 |
24 Feb 09 |
gregory |
102 |
if [ ! -e $dest ]; then |
3547 |
20 Jan 10 |
fredrik |
103 |
cp $source $dest |
3564 |
15 Feb 10 |
gregory |
104 |
if [ ! -z $PREFIX ]; then |
3564 |
15 Feb 10 |
gregory |
105 |
dest=${dest##$PREFIX} |
3564 |
15 Feb 10 |
gregory |
106 |
fi |
3133 |
24 Feb 09 |
gregory |
107 |
echo $dest |
3139 |
25 Feb 09 |
gregory |
108 |
else |
3139 |
25 Feb 09 |
gregory |
109 |
if [ "$force" == "--force" ]; then |
3547 |
20 Jan 10 |
fredrik |
110 |
cp $source $dest |
3564 |
15 Feb 10 |
gregory |
111 |
if [ ! -z $PREFIX ]; then |
3564 |
15 Feb 10 |
gregory |
112 |
dest=${dest##$PREFIX} |
3564 |
15 Feb 10 |
gregory |
113 |
fi |
3139 |
25 Feb 09 |
gregory |
114 |
echo $dest |
3139 |
25 Feb 09 |
gregory |
115 |
fi |
3133 |
24 Feb 09 |
gregory |
116 |
fi |
3133 |
24 Feb 09 |
gregory |
117 |
} |
3133 |
24 Feb 09 |
gregory |
118 |
|
3133 |
24 Feb 09 |
gregory |
119 |
uninstall() |
3133 |
24 Feb 09 |
gregory |
120 |
{ |
3133 |
24 Feb 09 |
gregory |
121 |
source=$1 |
3133 |
24 Feb 09 |
gregory |
122 |
dest=$2 |
3133 |
24 Feb 09 |
gregory |
123 |
if [ -f $dest ]; then |
3133 |
24 Feb 09 |
gregory |
124 |
rm $dest |
3133 |
24 Feb 09 |
gregory |
125 |
echo $dest |
3133 |
24 Feb 09 |
gregory |
126 |
fi |
3133 |
24 Feb 09 |
gregory |
127 |
} |
3133 |
24 Feb 09 |
gregory |
128 |
|
3138 |
25 Feb 09 |
gregory |
129 |
|
3136 |
24 Feb 09 |
gregory |
130 |
cd www |
3136 |
24 Feb 09 |
gregory |
131 |
if [ "$action" == "install" ]; then |
3136 |
24 Feb 09 |
gregory |
# Create directory structure |
3136 |
24 Feb 09 |
gregory |
133 |
dirs=`find . -type d` |
3136 |
24 Feb 09 |
gregory |
134 |
for dir in $dirs |
3136 |
24 Feb 09 |
gregory |
135 |
do |
3136 |
24 Feb 09 |
gregory |
136 |
dir=${dir##\./} |
3137 |
25 Feb 09 |
gregory |
137 |
mkdir -p $root/$dir |
3136 |
24 Feb 09 |
gregory |
138 |
done |
3558 |
11 Feb 10 |
gregory |
139 |
mkdir -p $USER_FILES_DIR $TEMP_FILES_DIR $USER_FILES_DIR/conf |
3136 |
24 Feb 09 |
gregory |
140 |
fi |
3136 |
24 Feb 09 |
gregory |
141 |
|
3133 |
24 Feb 09 |
gregory |
# Copy files into place |
3136 |
24 Feb 09 |
gregory |
143 |
files=`find . -type f` |
3133 |
24 Feb 09 |
gregory |
144 |
for file in $files |
3133 |
24 Feb 09 |
gregory |
145 |
do |
3136 |
24 Feb 09 |
gregory |
# Relative path |
3133 |
24 Feb 09 |
gregory |
147 |
file=${file##\./} |
3137 |
25 Feb 09 |
gregory |
148 |
dest=$root/$file |
3133 |
24 Feb 09 |
gregory |
149 |
$action $file $dest |
3133 |
24 Feb 09 |
gregory |
150 |
done |
3133 |
24 Feb 09 |
gregory |
151 |
cd .. |
3137 |
25 Feb 09 |
gregory |
152 |
$action ./Replace.jar $root/WEB-INF/lib/Replace.jar |
3137 |
25 Feb 09 |
gregory |
153 |
$action ./GetHostName.jar $root/WEB-INF/lib/GetHostName.jar |
3542 |
11 Jan 10 |
gregory |
154 |
$action ./proteios_ftp_server.sh.in $SERVICE_PATH/proteios_ftp_server.sh.in |
3133 |
24 Feb 09 |
gregory |
155 |
|
3558 |
11 Feb 10 |
gregory |
# Set owner and permissions |
3561 |
12 Feb 10 |
gregory |
157 |
chown $TOMCAT_USER -R $USER_FILES_DIR $TEMP_FILES_DIR $root |
3561 |
12 Feb 10 |
gregory |
158 |
chgrp $TOMCAT_GROUP -R $USER_FILES_DIR $TEMP_FILES_DIR $root |
3561 |
12 Feb 10 |
gregory |
159 |
chown root $root/WEB-INF/update.sh $root/WEB-INF/init.sh |
3561 |
12 Feb 10 |
gregory |
160 |
chgrp root $root/WEB-INF/update.sh $root/WEB-INF/init.sh |
3561 |
12 Feb 10 |
gregory |
161 |
chmod u+x $root/WEB-INF/update.sh $root/WEB-INF/init.sh |
3558 |
11 Feb 10 |
gregory |
162 |
|
3540 |
11 Jan 10 |
gregory |
# Remove unused files |
3558 |
11 Feb 10 |
gregory |
# We also remove files that are no longer part of this package here |
3540 |
11 Jan 10 |
gregory |
165 |
FILES_TO_REMOVE="\ |
3540 |
11 Jan 10 |
gregory |
166 |
$root/WEB-INF/init \ |
3540 |
11 Jan 10 |
gregory |
167 |
$root/WEB-INF/update \ |
3540 |
11 Jan 10 |
gregory |
168 |
$root/WEB-INF/updatedb.sh \ |
3540 |
11 Jan 10 |
gregory |
169 |
$root/WEB-INF/update_proteios-linux.sh \ |
3540 |
11 Jan 10 |
gregory |
170 |
$root/WEB-INF/set_classpath.sh \ |
4423 |
26 Feb 13 |
olle |
171 |
$root/WEB-INF/lib/antlr-2.7.6.jar \ |
4394 |
10 Jan 13 |
olle |
172 |
$root/WEB-INF/lib/c3p0-0.9.0.jar \ |
4377 |
06 Nov 12 |
olle |
173 |
$root/WEB-INF/lib/catalina.jar \ |
4377 |
06 Nov 12 |
olle |
174 |
$root/WEB-INF/lib/catalina-optional.jar \ |
4394 |
10 Jan 13 |
olle |
175 |
$root/WEB-INF/lib/cglib-2.1.3.jar \ |
4394 |
10 Jan 13 |
olle |
176 |
$root/WEB-INF/lib/commons-codec-1.3.jar \ |
4423 |
26 Feb 13 |
olle |
177 |
$root/WEB-INF/lib/commons-codec-1.4.jar \ |
4376 |
06 Nov 12 |
olle |
178 |
$root/WEB-INF/lib/commons-io-1.2.jar \ |
4203 |
11 May 11 |
fredrik |
179 |
$root/WEB-INF/lib/commons-math-1.1.jar \ |
4394 |
10 Jan 13 |
olle |
180 |
$root/WEB-INF/lib/ehcache-1.2.3.jar \ |
4423 |
26 Feb 13 |
olle |
181 |
$root/WEB-INF/lib/ehcache-2.4.6.jar \ |
4509 |
15 Aug 13 |
fredrik |
182 |
$root/WEB-INF/lib/ehcache-core-2.4.6.jar \ |
4423 |
26 Feb 13 |
olle |
183 |
$root/WEB-INF/lib/httpclient-4.1.2.jar \ |
4423 |
26 Feb 13 |
olle |
184 |
$root/WEB-INF/lib/httpcore-4.1.3.jar \ |
4509 |
15 Aug 13 |
fredrik |
185 |
$root/WEB-INF/lib/httpclient-4.2.3.jar \ |
4509 |
15 Aug 13 |
fredrik |
186 |
$root/WEB-INF/lib/httpcore-4.2.3.jar \ |
4394 |
10 Jan 13 |
olle |
187 |
$root/WEB-INF/lib/javassist-3.9.0.GA.jar \ |
4423 |
26 Feb 13 |
olle |
188 |
$root/WEB-INF/lib/jcommon-1.0.6.jar \ |
4423 |
26 Feb 13 |
olle |
189 |
$root/WEB-INF/lib/json_simple-1.1.jar \ |
4423 |
26 Feb 13 |
olle |
190 |
$root/WEB-INF/lib/log4j-1.2.15.jar \ |
4423 |
26 Feb 13 |
olle |
191 |
$root/WEB-INF/lib/mail.jar \ |
4394 |
10 Jan 13 |
olle |
192 |
$root/WEB-INF/lib/mysql-connector-java-3.1.12-bin.jar \ |
4423 |
26 Feb 13 |
olle |
193 |
$root/WEB-INF/lib/mysql-connector-java-5.1.18-bin.jar \ |
4633 |
23 Nov 17 |
fredrik |
194 |
$root/WEB-INF/lib/mysql-connector-java-5.1.22-bin.jar \ |
4394 |
10 Jan 13 |
olle |
195 |
$root/WEB-INF/lib/postgresql-8.0-313.jdbc3.jar \ |
4423 |
26 Feb 13 |
olle |
196 |
$root/WEB-INF/lib/postgresql-9.1-901.jdbc4.jar \ |
4394 |
10 Jan 13 |
olle |
197 |
$root/WEB-INF/lib/slf4j-api-1.5.8.jar \ |
4394 |
10 Jan 13 |
olle |
198 |
$root/WEB-INF/lib/slf4j-log4j12-1.5.8.jar \ |
3540 |
11 Jan 10 |
gregory |
199 |
$root/WEB-INF/install-linux.sh" |
3540 |
11 Jan 10 |
gregory |
200 |
for file in $FILES_TO_REMOVE |
3540 |
11 Jan 10 |
gregory |
201 |
do |
3540 |
11 Jan 10 |
gregory |
202 |
if [ -e $file ]; then |
3540 |
11 Jan 10 |
gregory |
203 |
rm $file |
3540 |
11 Jan 10 |
gregory |
204 |
fi |
3540 |
11 Jan 10 |
gregory |
205 |
done |