Project

General

Profile

« Previous | Next » 

Revision 8917

Added by Jing Tao over 9 years ago

Added the code to copy Metacat and other web applications from the webapps directory in tomcat6 to tomcat7.
It also update the value of deploy.applicationDir in the metacat.properties file as well.

View differences:

src/scripts/bash/install-java7-tomcat7.sh
3 3
#It will update the alternatives for java, javac, keytool and javaws to openjdk-7.
4 4
#It will modify the /etc/tomcat7/catalina.properties to allow DataONE idenifiers.
5 5
#It will modify the workers.properties file for apache-tomcat connector.
6
#It will move Metacat and other web applications from the old context directory to the new context directory.
6 7
#The user running the script should have the sudo permission.
7 8

  
8 9
NEW_JDK_PACKAGE=openjdk-7-jdk
......
10 11

  
11 12
JK_CONF=/etc/apache2/mods-enabled/jk.conf
12 13

  
14
OLD_TOMCAT=tomcat6
15
OLD_TOMCAT_BASE=/var/lib/${OLD_TOMCAT}
16

  
13 17
NEW_TOMCAT=tomcat7
14
NEW_CATALINA_PROPERTIES=/etc/tomcat7/catalina.properties
15
NEW_TOMCAT_HOME=/usr/share/tomcat7
16
NEW_TOMCAT_BASE=/var/lib/tomcat7
18
NEW_CATALINA_PROPERTIES=/etc/${NEW_TOMCAT}/catalina.properties
19
NEW_TOMCAT_HOME=/usr/share/${NEW_TOMCAT}
20
NEW_TOMCAT_BASE=/var/lib/${NEW_TOMCAT}
21

  
22
KNB=knb
23
METACAT=metacat
24
WEBAPPS=webapps
17 25
TOMCAT_CONFIG_SLASH='org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true'
18 26
TOMCAT_CONFIG_BACKSLASH='org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true'
27
INIT_START_DIR=/etc/init.d
19 28

  
20 29
echo "install ${NEW_JDK_PACKAGE}"
21 30
sudo apt-get install ${NEW_JDK_PACKAGE}
......
28 37

  
29 38
echo "install ${NEW_TOMCAT}"
30 39
sudo apt-get install ${NEW_TOMCAT}
40
echo "configure ${NEW_TOMCAT}"
31 41
if grep -q "${TOMCAT_CONFIG_SLASH}" ${NEW_CATALINA_PROPERTIES}; then  
32 42
echo "${TOMCAT_CONFIG_SLASH} exists and don't need to do anything."  
33 43
else  
......
42 52
fi
43 53

  
44 54

  
45

  
46

  
47 55
echo "read the location of the workers.properties file from the jk_conf"
48 56
while read f1 f2 
49 57
do
......
54 62
echo "the jk workers.properties location is $JK_WORKER_PATH"
55 63

  
56 64
echo "update the tomcat home and java home in workers.properties file"
57
SAFE_TOMCAT_HOME=$(printf '%s\n' "$NEW_TOMCAT_HOME" | sed 's/[[\.*^$(){}?+|/]/\\&/g')
58
SAFE_JDK_HOME=$(printf '%s\n' "$NEW_JDK_HOME" | sed 's/[[\.*^$(){}?+|/]/\\&/g')
59
sudo sed -i.bak --regexp-extended "s/(workers\.tomcat_home=).*/\1${SAFE_TOMCAT_HOME}/;
60
                s/(workers\.java_home=).*/\1${SAFE_JDK_HOME}/;"\
65
SAFE_NEW_TOMCAT_HOME=$(printf '%s\n' "$NEW_TOMCAT_HOME" | sed 's/[[\.*^$(){}?+|/]/\\&/g')
66
SAFE_NEW_JDK_HOME=$(printf '%s\n' "$NEW_JDK_HOME" | sed 's/[[\.*^$(){}?+|/]/\\&/g')
67
sudo sed -i.bak --regexp-extended "s/(workers\.tomcat_home=).*/\1${SAFE_NEW_TOMCAT_HOME}/;
68
                s/(workers\.java_home=).*/\1${SAFE_NEW_JDK_HOME}/;"\
61 69
                $JK_WORKER_PATH
70

  
71
echo "move Metacat and other web applications from $OLD_TOMCAT to $NEW_TOMCAT"
72
sudo ${INIT_START_DIR}/${OLD_TOMCAT} stop
73
sudo ${INIT_START_DIR}/${NEW_TOMCAT} stop
74
sudo rm -rf ${NEW_TOMCAT_BASE}/${WEBAPPS}/*
75
sudo cp -R ${OLD_TOMCAT_BASE}/${WEBAPPS}/*  ${NEW_TOMCAT_BASE}/${WEBAPPS}/.
76
sudo chown -R ${NEW_TOMCAT}:${NEW_TOMCAT} ${NEW_TOMCAT_BASE}/${WEBAPPS}/*
77
echo "change the value of the application.deployDir in the metacat.properties file"
78
SAFE_NEW_TOMCAT_WEBAPPS=$(printf '%s\n' "$NEW_TOMCAT_BASE/$WEBAPPS" | sed 's/[[\.*^$(){}?+|/]/\\&/g')
79
#echo "the escaped webpass value is ${SAFE_NEW_TOMCAT_WEBAPPS}"
80
if [ -f "$NEW_TOMCAT_BASE/$WEBAPPS/$KNB/WEB-INF/metacat.properties" ]; then
81
	echo "$NEW_TOMCAT_BASE/$WEBAPPS/$KNB/WEB-INF/metacat.properties exists and the application.deployDir will be updated"	
82
	sudo sed -i.bak --regexp-extended "s/(application\.deployDir=).*/\1${SAFE_NEW_TOMCAT_WEBAPPS}/;" $NEW_TOMCAT_BASE/$WEBAPPS/$KNB/WEB-INF/metacat.properties
83
else
84
	echo "$NEW_TOMCAT_BASE/$WEBAPPS/$KNB/WEB-INF/metacat.properties does NOT exists and the application.deployDir will NOT be updated"
85
fi
86

  
87
if [ -f "$NEW_TOMCAT_BASE/$WEBAPPS/$METACAT/WEB-INF/metacat.properties" ]; then
88
                echo "$NEW_TOMCAT_BASE/$WEBAPPS/$METACAT/WEB-INF/metacat.properties eixsts and the application.deployDir will be updated" 
89
                sudo sed -i.bak --regexp-extended "s/(application\.deployDir=).*/\1${SAFE_NEW_TOMCAT_WEBAPPS}/;" $NEW_TOMCAT_BASE/$WEBAPPS/$METACAT/WEB-INF/metacat.properties
90
else 
91
  echo "$NEW_TOMCAT_BASE/$WEBAPPS/$METACAT/WEB-INF/metacat.properties doesn't eixt and the application.deployDir will NOT be updated"
92
fi

Also available in: Unified diff