Project

General

Profile

« Previous | Next » 

Revision 8932

Added by Jing Tao over 9 years ago

Added the .conf to those site files since the new apache server only loads the sites with the extension.

View differences:

install-java7-tomcat7.sh
6 6
#It will move Metacat and other web applications from the old context directory to the new context directory.
7 7
#The user running the script should have the sudo permission.
8 8

  
9
APACHE_SITE_FILE=/etc/apache2/sites-available/knb-ssl
9
APACHE_ENABLED_SITES_DIR=/etc/apache2/sites-enabled
10
APACHE_AVAILABLE_SITES_DIR=/etc/apache2/sites-available
10 11
NEW_JDK_PACKAGE=openjdk-7-jdk
11 12
NEW_JDK_HOME=/usr/lib/jvm/java-7-openjdk-amd64
12 13

  
......
24 25
NEW_TOMCAT_SERVER_CONIF=$NEW_TOMCAT_BASE/conf/server.xml
25 26

  
26 27
KNB=knb
28
SSL=ssl
27 29
METACAT=metacat
28 30
WEBAPPS=webapps
31
METACAT_DATA_DIR=/var/metacat
29 32
TOMCAT_CONFIG_SLASH='org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true'
30 33
TOMCAT_CONFIG_BACKSLASH='org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true'
31 34
INIT_START_DIR=/etc/init.d
32 35

  
36

  
37
if [ $# -ne 1 ]; then
38
   echo "This script should take one and only one parameter as the name of the host.";
39
   exit 1;
40
fi
41
HOST_NAMEW=$1
42

  
33 43
sudo /etc/init.d/apache2 stop
34 44
echo "install ${NEW_JDK_PACKAGE}"
35 45
sudo apt-get install ${NEW_JDK_PACKAGE}
......
74 84
  sudo xmlstarlet ed -L -P -s "/Server/Service/Connector[not(@redirectPort)]" --type attr -n redirectPort -v 8443 $NEW_TOMCAT_SERVER_CONIF
75 85
fi
76 86

  
77
echo "read the location of the workers.properties file from the jk_conf"
78
while read f1 f2 
79
do
80
        if [ "$f1" = "JkWorkersFile" ]; then
81
		JK_WORKER_PATH="$f2"	
82
	fi
83
done < ${JK_CONF}
84
echo "the jk workers.properties location is $JK_WORKER_PATH"
85 87

  
86
echo "update the tomcat home and java home in workers.properties file"
87
SAFE_NEW_TOMCAT_HOME=$(printf '%s\n' "$NEW_TOMCAT_HOME" | sed 's/[[\.*^$(){}?+|/]/\\&/g')
88
SAFE_NEW_JDK_HOME=$(printf '%s\n' "$NEW_JDK_HOME" | sed 's/[[\.*^$(){}?+|/]/\\&/g')
89
sudo sed -i.bak --regexp-extended "s/(workers\.tomcat_home=).*/\1${SAFE_NEW_TOMCAT_HOME}/;
90
                s/(workers\.java_home=).*/\1${SAFE_NEW_JDK_HOME}/;"\
91
                $JK_WORKER_PATH
92

  
93
echo "update the apache site file by replacing $OLD_TOMCAT by $NEW_TOMCAT"
94
sudo sed -i.bak "s/${OLD_TOMCAT}/${NEW_TOMCAT}/;" $APACHE_SITE_FILE
95

  
96 88
echo "move Metacat and other web applications from $OLD_TOMCAT to $NEW_TOMCAT"
97 89
sudo ${INIT_START_DIR}/${OLD_TOMCAT} stop
98 90
sudo ${INIT_START_DIR}/${NEW_TOMCAT} stop
......
118 110
  echo "$NEW_TOMCAT_BASE/$WEBAPPS/$METACAT/WEB-INF/metacat.properties doesn't eixt and the application.deployDir will NOT be updated"
119 111
fi
120 112

  
113
echo "change the ownership of $METACAT_DATA_DIR to $NEW_TOMCAT"
114
sudo chown -R ${NEW_TOMCAT}:${NEW_TOMCAT} ${METACAT_DATA_DIR}
115

  
116

  
117
echo "Change somethings on apache configuration"
118
echo "read the location of the workers.properties file from the jk_conf"
119
while read f1 f2 
120
do
121
        if [ "$f1" = "JkWorkersFile" ]; then
122
        JK_WORKER_PATH="$f2"    
123
    fi
124
done < ${JK_CONF}
125
echo "the jk workers.properties location is $JK_WORKER_PATH"
126

  
127
echo "update the tomcat home and java home in workers.properties file"
128
SAFE_NEW_TOMCAT_HOME=$(printf '%s\n' "$NEW_TOMCAT_HOME" | sed 's/[[\.*^$(){}?+|/]/\\&/g')
129
SAFE_NEW_JDK_HOME=$(printf '%s\n' "$NEW_JDK_HOME" | sed 's/[[\.*^$(){}?+|/]/\\&/g')
130
sudo sed -i.bak --regexp-extended "s/(workers\.tomcat_home=).*/\1${SAFE_NEW_TOMCAT_HOME}/;
131
                s/(workers\.java_home=).*/\1${SAFE_NEW_JDK_HOME}/;"\
132
                $JK_WORKER_PATH
133

  
134
echo "we need to do some work since the new version of apache only load the site files with .conf extension in the sites-enabled directory"
135
echo "delete all links which doesn't end with .conf in the site-enabled directory since they can't be loaded"
136
sudo find $APACHE_ENABLED_SITES_DIR -type f ! -name "*.conf" -delete
137

  
138
echo "add .conf to the files which don't end with .conf or .bak or .org"
139
for i in $(sudo find $APACHE_AVAILABLE_SITES_DIR -type f \( ! -name "*.conf" -a ! -name "*.bak" -a ! -name "*.org" \)); 
140
do
141
    sudo mv "$i" "${i}".conf 
142
done
143

  
144
echo "update the apache site files by replacing $OLD_TOMCAT by $NEW_TOMCAT"
145
for j in $(sudo find $APACHE_AVAILABLE_SITES_DIR -type f -name "*.conf")
146
do
147
    sudo sed -i.bak "s/${OLD_TOMCAT}/${NEW_TOMCAT}/;" $j
148
done
149

  
150
echo "rename the site file knb to $HOST_NAME and knb-ssl to $HOST_NAME-ssl"
151
sudo mv $APACHE_AVAILABLE_SITES_DIR/$KNB $APACHE_AVAILABLE_SITES_DIR/$HOST_NAME.conf
152
sudo mv $APACHE_AVAILABLE_SITES_DIR/$KNB-ssl $APACHE_AVAILABLE_SITES_DIR/$HOST_NAME-ssl.conf
153

  
154
echo "enable the two sites $HOST_NAME and $HOST_NAME-ssl"
155
sudo a2ensite $HOST_NAME
156
sudo a2ensite $HOST_NAME-ssl
157

  
121 158
sudo /etc/init.d/apache2 start
122 159
sudo /etc/init.d/tomcat7 start

Also available in: Unified diff