|
1 |
#!/bin/bash
|
|
2 |
|
|
3 |
LONG_DATE=`date +%Y%m%d%H%M%S`
|
|
4 |
|
|
5 |
TOMCAT_USER=tomcat55
|
|
6 |
TOMCAT_HOME=/usr/share/tomcat5.5
|
|
7 |
SOURCE_DIR=/usr/share/metacat-@metacatVersion@
|
|
8 |
|
|
9 |
###############################################################################
|
|
10 |
# Install metacat war file
|
|
11 |
###############################################################################
|
|
12 |
|
|
13 |
## Stop tomcat
|
|
14 |
echo "Stopping Tomcat"
|
|
15 |
/etc/init.d/tomcat5.5 stop
|
|
16 |
|
|
17 |
## backup the old war file
|
|
18 |
if [ -e ${TOMCAT_HOME}/webapps/knb.war ]
|
|
19 |
then
|
|
20 |
echo "Backing up ${TOMCAT_HOME}/webapps/knb.war to ${TOMCAT_HOME}/webapps/knb.war.${LONG_DATE}"
|
|
21 |
mv ${TOMCAT_HOME}/webapps/knb.war ${TOMCAT_HOME}/webapps/knb.war.${LONG_DATE}
|
|
22 |
fi
|
|
23 |
|
|
24 |
## remove the knb application directory
|
|
25 |
if [ -d ${TOMCAT_HOME}/webapps/knb ]
|
|
26 |
then
|
|
27 |
echo "Removing the old metacat application directorties"
|
|
28 |
rm -rf ${TOMCAT_HOME}/webapps/knb
|
|
29 |
fi
|
|
30 |
|
|
31 |
## copy the new war file into the webapps directory
|
|
32 |
echo copying new knb.war file to ${TOMCAT_HOME}/webapps/knb.war
|
|
33 |
cp ${SOURCE_DIR}/knb.war ${TOMCAT_HOME}/webapps/knb.war
|
|
34 |
|
|
35 |
## expand the war file
|
|
36 |
CURR_DIR=`pwd`
|
|
37 |
|
|
38 |
## make knb directory and extract knb.war into it.
|
|
39 |
echo "Making knb application directory: ${TOMCAT_HOME}/webapps/knb"
|
|
40 |
mkdir ${TOMCAT_HOME}/webapps/knb
|
|
41 |
cd ${TOMCAT_HOME}/webapps/knb
|
|
42 |
|
|
43 |
echo "extracting knb.war into ${TOMCAT_HOME}/webapps/knb"
|
|
44 |
jar -xvf ${TOMCAT_HOME}/webapps/knb.war > /dev/null
|
|
45 |
chown -R ${TOMCAT_USER} ${TOMCAT_HOME}/webapps/knb
|
|
46 |
echo cd to $CURR_DIR
|
|
47 |
cd $CURR_DIR
|
|
48 |
|
|
49 |
chmod -R +x ${TOMCAT_HOME}/webapps/knb/cgi-bin
|
|
50 |
|
|
51 |
###############################################################################
|
|
52 |
# Create Metacat External File Space
|
|
53 |
###############################################################################
|
|
54 |
|
|
55 |
## Create the /var/metacat directory
|
|
56 |
if [ ! -d /var/metacat ]
|
|
57 |
then
|
|
58 |
echo "Making Metacat utility directory: /var/metacat"
|
|
59 |
mkdir /var/metacat
|
|
60 |
fi
|
|
61 |
|
|
62 |
## Change the ownership of the /var/metacat directory to be the tomcat user.
|
|
63 |
echo "changing ownership of /var/metacat to ${TOMCAT_USER}"
|
|
64 |
chown -R ${TOMCAT_USER} /var/metacat
|
|
65 |
|
|
66 |
###############################################################################
|
|
67 |
# Configure Tomcat
|
|
68 |
###############################################################################
|
|
69 |
|
|
70 |
## Change ownership of the tomcat directories to be the tomcat user
|
|
71 |
echo "changing ownership of ${TOMCAT_HOME} to ${TOMCAT_USER}"
|
|
72 |
chown -R ${TOMCAT_USER} ${TOMCAT_HOME}
|
|
73 |
echo "changing ownership of /var/lib/tomcat5.5 to ${TOMCAT_USER}"
|
|
74 |
chown -R ${TOMCAT_USER} /var/lib/tomcat5.5
|
|
75 |
echo "changing ownership of /etc/tomcat5.5 to ${TOMCAT_USER}"
|
|
76 |
chown -R ${TOMCAT_USER} /etc/tomcat5.5
|
|
77 |
|
|
78 |
## If the tomcat5.5 startup script in the package is different than the one
|
|
79 |
## in /etc/init.d, then backup the existing one and copy in the package version.
|
|
80 |
TOMCAT_START_SCRIPT_DIFF=`diff ${SOURCE_DIR}/tomcat5.5 /etc/init.d/tomcat5.5`
|
|
81 |
if [ "$TOMCAT_START_SCRIPT_DIFF" != "" ]
|
|
82 |
then
|
|
83 |
echo "Backing up /etc/init.d/tomcat5.5 to /etc/init.d/tomcat5.5.${LONG_DATE}"
|
|
84 |
mv /etc/init.d/tomcat5.5 /etc/init.d/tomcat5.5.${LONG_DATE}
|
|
85 |
echo "Copying new tomcat5.5 script to /etc/init.d/"
|
|
86 |
cp ${SOURCE_DIR}/tomcat5.5 /etc/init.d/
|
|
87 |
echo "Making /etc/init.d/tomcat5.5 executable"
|
|
88 |
chmod +x /etc/init.d/tomcat5.5
|
|
89 |
fi
|
|
90 |
|
|
91 |
###############################################################################
|
|
92 |
# Configure Apache
|
|
93 |
###############################################################################
|
|
94 |
|
|
95 |
## Stop apache
|
|
96 |
echo "Stopping Apache"
|
|
97 |
/etc/init.d/apache2 stop
|
|
98 |
|
|
99 |
## copy in jk.conf file
|
|
100 |
if [ -e /etc/apache2/mods-available/jk.conf ]
|
|
101 |
then
|
|
102 |
JK_CONF_DIFF=`diff ${SOURCE_DIR}/jk.conf /etc/apache2/mods-available/jk.conf`
|
|
103 |
if [ "${JK_CONF_DIFF}" != "" ]
|
|
104 |
then
|
|
105 |
echo "Backing up /etc/apache2/mods-available/jk.conf to /etc/apache2/mods-available/jk.conf.${LONG_DATE}"
|
|
106 |
mv /etc/apache2/mods-available/jk.conf /etc/apache2/mods-available/jk.conf.${LONG_DATE}
|
|
107 |
fi
|
|
108 |
fi
|
|
109 |
echo "Copying jk.conf to /etc/apache2/mods-available/"
|
|
110 |
cp ${SOURCE_DIR}/jk.conf /etc/apache2/mods-available/
|
|
111 |
|
|
112 |
## copy in workers.properties file
|
|
113 |
if [ -e /etc/apache2/workers.properties ]
|
|
114 |
then
|
|
115 |
WORKERS_PROPS_DIFF=`diff ${SOURCE_DIR}/workers.properties /etc/apache2/workers.properties`
|
|
116 |
if [ "${WORKERS_PROPS_DIFF}" != "" ]
|
|
117 |
then
|
|
118 |
echo "Backing up /etc/apache2/workers.properties to /etc/apache2/workers.properties.${LONG_DATE}"
|
|
119 |
mv /etc/apache2/workers.properties /etc/apache2/workers.properties.${LONG_DATE}
|
|
120 |
fi
|
|
121 |
fi
|
|
122 |
echo "Copying workers.properties to /etc/apache2/"
|
|
123 |
cp ${SOURCE_DIR}/workers.properties /etc/apache2/
|
|
124 |
|
|
125 |
## disable and then re-enable mod jk to pick up changes
|
|
126 |
echo "Refreshing Mod JK"
|
|
127 |
a2dismod jk
|
|
128 |
a2enmod jk
|
|
129 |
|
|
130 |
## copy in knb site file
|
|
131 |
if [ -e /etc/apache2/sites-available/knb ]
|
|
132 |
then
|
|
133 |
KNB_SITE_DIFF=`diff ${SOURCE_DIR}/knb /etc/apache2/sites-available/knb`
|
|
134 |
if [ "${KNB_SITE_DIFF}" != "" ]
|
|
135 |
then
|
|
136 |
echo "Backing up /etc/apache2/sites-available/knb to /etc/apache2/sites-available/knb.${LONG_DATE}"
|
|
137 |
mv /etc/apache2/sites-available/knb /etc/apache2/sites-available/knb.${LONG_DATE}
|
|
138 |
fi
|
|
139 |
fi
|
|
140 |
echo "Copying knb site file to /etc/apache2/sites-available/"
|
|
141 |
cp ${SOURCE_DIR}/knb /etc/apache2/sites-available/
|
|
142 |
|
|
143 |
## enable knb site
|
|
144 |
echo "Enabling knb site"
|
|
145 |
a2dissite knb
|
|
146 |
a2ensite knb
|
|
147 |
|
|
148 |
###############################################################################
|
|
149 |
# Configure Postgres
|
|
150 |
###############################################################################
|
|
151 |
|
|
152 |
## modify pg_hba.conf
|
|
153 |
PG_HBA_IS_MODIFIED=`grep "metacat metacat" /etc/postgresql/8.3/main/pg_hba.conf`
|
|
154 |
if [ "${PG_HBA_IS_MODIFIED}" == "" ]
|
|
155 |
then
|
|
156 |
echo "backing up /etc/postgresql/8.3/main/pg_hba.conf to /etc/postgresql/8.3/main/pg_hba.conf.${LONG_DATE}"
|
|
157 |
cp /etc/postgresql/8.3/main/pg_hba.conf /etc/postgresql/8.3/main/pg_hba.conf.${LONG_DATE}
|
|
158 |
|
|
159 |
echo "appending 'host metacat metacat 127.0.0.1 255.255.255.255 password' to /etc/postgresql/8.3/main/pg_hba.conf"
|
|
160 |
echo "host metacat metacat 127.0.0.1 255.255.255.255 password" >> /etc/postgresql/8.3/main/pg_hba.conf
|
|
161 |
fi
|
|
162 |
|
|
163 |
## create metacat schema and user
|
|
164 |
echo "Creating metacat database schema"
|
|
165 |
su postgres -c "createdb metacat"
|
|
166 |
|
|
167 |
echo "Creating metacat user"
|
|
168 |
su postgres -c "psql -c \"CREATE USER metacat WITH UNENCRYPTED PASSWORD 'metacat'\""
|
|
169 |
|
|
170 |
## Restart the postgres db
|
|
171 |
echo "Restarting postgres database"
|
|
172 |
/etc/init.d/postgresql-8.3 restart
|
|
173 |
|
|
174 |
###############################################################################
|
|
175 |
# Start Apache and Tomcat
|
|
176 |
###############################################################################
|
|
177 |
|
|
178 |
## Start Apache
|
|
179 |
/etc/init.d/apache2 start
|
|
180 |
|
|
181 |
## ugly hack to fix circular dependency bug that will keep tomcat
|
|
182 |
## from starting within this script
|
|
183 |
if [ ! -f /etc/java-1.5.0-sun/jvm.cfg ]; then
|
|
184 |
temp_jvm_cfg=/etc/java-1.5.0-sun/jvm.cfg
|
|
185 |
mkdir -p /etc/java-1.5.0-sun
|
|
186 |
printf -- "-server KNOWN\n" > $temp_jvm_cfg
|
|
187 |
fi
|
|
188 |
|
|
189 |
## Start Tomcat
|
|
190 |
echo "starting Tomcat server"
|
|
191 |
|
|
192 |
#export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
|
|
193 |
#/usr/share/tomcat5.5/bin/startup.sh
|
|
194 |
|
|
195 |
/etc/init.d/tomcat5.5 start
|
|
196 |
#chmod u+x ${SOURCE_DIR}/delay-tomcat-start
|
|
197 |
#${SOURCE_DIR}/delay-tomcat-start &
|
0 |
198 |
|
Scripts to support a debian package build