Project

General

Profile

« Previous | Next » 

Revision 4656

Added by daigle over 15 years ago

Scripts to support a debian package build

View differences:

src/scripts/debian/tomcat5.5
1
#!/bin/bash
2
#
3
# /etc/init.d/tomcat5.5 -- startup script for the Tomcat 5 servlet engine customixed
4
# for Metacat
5
#
6
# Written by Michael Daigle <daigle@nceas.ucsb.edu>.
7
#
8

  
9
DESC="Tomcat servlet engine"
10
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun
11
export CATALINA_HOME=/usr/share/tomcat5.5
12

  
13
if [ `id -u` -ne 0 ]; then
14
	echo "You need root privileges to run this script"
15
	exit 1
16
fi
17
         
18
# Make sure tomcat is started with system locale
19
if [ -r /etc/default/locale ]; then
20
	. /etc/default/locale
21
	export LANG
22
fi
23

  
24
. /lib/lsb/init-functions
25
. /etc/default/rcS
26

  
27
function start {
28
	if [ -z "$JAVA_HOME" ]; then
29
		log_failure_msg "no JDK found - please set JAVA_HOME"
30
		exit 1
31
	fi
32

  
33
	if [ ! -d "$CATALINA_HOME/conf" ]; then
34
		log_failure_msg "invalid CATALINA_HOME specified"
35
		exit 1
36
	fi
37

  
38
	log_daemon_msg "Starting $DESC" 
39
	$CATALINA_HOME/bin/startup.sh
40
	log_end_msg 0
41
}  
42

  
43
function stop {
44
	log_daemon_msg "Stopping $DESC"
45
	$CATALINA_HOME/bin/shutdown.sh
46
	log_end_msg 0
47
}
48
	
49
case "$1" in
50
  start)
51
	start
52
	;;
53
  stop)
54
	stop
55
	;;
56
  restart|force-reload)
57
	stop
58
	sleep 5
59
	start
60
	;;
61
  *)
62
	log_success_msg "Usage: $0 {start|stop|restart}"
63
	exit 1
64
	;;
65
esac
66

  
67
exit 0
src/scripts/debian/control
1
Package: metacat
2
Version: @metacatVersion@@metacatRC@
3
Section: base
4
Priority: optional
5
Architecture: all
6
Depends: sun-java5-jdk, apache2, libapache2-mod-jk, tomcat5.5, postgresql
7
Maintainer: Matt Jones <jones@nceas.ucsb.edu>
8
Description: Metacat is a metadata cataloging system.
9
  Metacat is a flexible metadata database. It utilizes XML as a 
10
  common syntax for representing the large number of metadata 
11
  content standards that are relevant to ecology.
src/scripts/debian/postinst
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

  
src/scripts/debian/workers.properties
1
workers.tomcat_home=/usr/share/tomcat5.5
2
workers.java_home=/usr/lib/jvm/java-1.5.0-sun
3

  
4
worker.list=ajp13
5
worker.knb.port=8009
6
worker.knb.host=localhost
7
worker.knb.type=ajp13
8
worker.knb.lbfactor=1
9
worker.loadbalancer.type=lb
10
worker.loadbalancer.balanced_workers=ajp13
src/scripts/debian/authority
1
<IfModule mod_jk.c>
2
	JkMount /authority knb
3
	JkMount /authority/* knb
4
</IfModule>
src/scripts/debian/jk.conf
1
JkWorkersFile   /etc/apache2/workers.properties
2
JkLogFile       /var/log/apache2/mod_jk.log
3
JkShmFile       /var/log/apache2/mod_jk.shm
4
JkLogLevel      info
src/scripts/debian/knb
1
ScriptAlias /knb/cgi-bin/ /usr/share/tomcat5.5/webapps/knb/cgi-bin/
2
<Directory "/usr/share/tomcat5.5/webapps/knb/cgi-bin/">
3
	AllowOverride All
4
	Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
5
	Order allow,deny
6
	Allow from all
7
</Directory>
8

  
9
<IfModule mod_jk.c>
10
	JkMount /knb ajp13
11
	JkMount /knb/* ajp13
12
	JkMount /knb/metacat ajp13
13
	JkUnMount /knb/cgi-bin/* ajp13
14
</IfModule>
src/scripts/debian/delay-tomcat-start
1
#!/bin/bash
2

  
3
sleep 5
4
echo Starting Tomcat
5
/etc/init.d/tomcat5.5 start

Also available in: Unified diff