Skip to content

Commit 64f511b

Browse files
authored
Upgrade to tomcat 9.0.82 (#244)
1 parent 61a01ac commit 64f511b

2 files changed

Lines changed: 38 additions & 14 deletions

File tree

‎scripts/afterInstall.sh‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export HOME=/home/ubuntu
44
export BUILD_DIR=$HOME/build-folder
55
export LEGACY_BUILD_DIR=$HOME/legacy-build-folder
66
export BUILD_FILES=$HOME/wise-build-files
7-
export CATALINA_HOME=/var/lib/tomcat9
7+
export CATALINA_HOME=/opt/tomcat
88

99
exec &>> $HOME/deploy.log
1010

@@ -31,7 +31,10 @@ echo "Moving legacy.war to $CATALINA_HOME/webapps/legacy.war"
3131
mv legacy.war $CATALINA_HOME/webapps/legacy.war
3232
chown tomcat:tomcat $CATALINA_HOME/webapps/legacy.war
3333

34-
echo "Deleting build-folder"
34+
echo "Deleting build folder"
3535
rm -rf $BUILD_DIR
3636

37+
echo "Deleting legacy build folder"
38+
rm -rf $LEGACY_BUILD_DIR
39+
3740
echo "Finishing deployment at $(date)"

‎scripts/beforeInstall.sh‎

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export HOME=/home/ubuntu
44
export BUILD_DIR=$HOME/build-folder
55
export LEGACY_BUILD_DIR=$HOME/legacy-build-folder
66
export BUILD_FILES=$HOME/wise-build-files
7-
export CATALINA_HOME=/var/lib/tomcat9
7+
export CATALINA_HOME=/opt/tomcat
88

99
if [[ "$DEPLOYMENT_GROUP_NAME" == "qa-wise-api-deployment-group" ]]; then
1010
export ENV="qa"
@@ -28,9 +28,9 @@ echo "Installing AWS CLI"
2828
apt-get install awscli -y
2929

3030
echo "Downloading files from wise-build-files S3 bucket"
31-
sudo -u ubuntu -g ubuntu mkdir $HOME/wise-build-files
32-
sudo -u ubuntu -g ubuntu aws s3 sync s3://wise-build-files $HOME/wise-build-files
33-
chmod u+x $HOME/wise-build-files/sync.sh
31+
sudo -u ubuntu -g ubuntu mkdir $BUILD_FILES
32+
sudo -u ubuntu -g ubuntu aws s3 sync s3://wise-build-files $BUILD_FILES
33+
chmod u+x $BUILD_FILES/sync.sh
3434

3535
echo "Installing Java 11"
3636
apt-get install openjdk-11-jdk-headless -y
@@ -39,25 +39,46 @@ echo "Create tomcat group"
3939
groupadd -g 1001 tomcat
4040

4141
echo "Create tomcat user"
42-
useradd -u 1001 -g tomcat -c "Apache Tomcat" -d / -s /usr/sbin/nologin tomcat
42+
useradd -u 1001 -g tomcat -c "Apache Tomcat" -d $CATALINA_HOME -s /usr/sbin/nologin tomcat
4343

4444
echo "Adding ubuntu user to tomcat group"
4545
usermod -a -G tomcat ubuntu
4646

47-
echo "Installing Tomcat 9"
48-
apt-get install tomcat9 -y
47+
echo "Creating tomcat directory"
48+
mkdir $CATALINA_HOME
49+
50+
echo "Making tomcat the owner of the tomcat directory"
51+
chown tomcat:tomcat $CATALINA_HOME
52+
53+
echo "Downloading Tomcat 9"
54+
wget -P /tmp https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.82/bin/apache-tomcat-9.0.82.tar.gz
55+
56+
echo "Unpackaging Tomcat 9 to $CATALINA_HOME"
57+
tar xzvf /tmp/apache-tomcat-9.0.82.tar.gz -C $CATALINA_HOME --strip-components=1
58+
59+
echo "Giving tomcat user ownership of tomcat directory contents"
60+
chown -R tomcat:tomcat $CATALINA_HOME
61+
62+
echo "Giving tomcat user execute permission on tomcat bin folder"
63+
chmod -R u+x $CATALINA_HOME/bin
64+
65+
echo "Copying tomcat service file to /etc/systemd/system"
66+
cp $BUILD_FILES/api/tomcat.service /etc/systemd/system/tomcat.service
4967

5068
echo "Removing Tomcat ROOT folder"
5169
rm -rf $CATALINA_HOME/webapps/ROOT
5270

5371
echo "Add https to Tomcat server.xml"
5472
sed 's/<Connector port="8080"/<Connector port="8080" scheme="https"/' -i $CATALINA_HOME/conf/server.xml
5573

56-
echo "Copying setenv.sh file to Tomcat bin folder"
57-
cp $BUILD_FILES/api/setenv.sh /usr/share/tomcat9/bin/setenv.sh
74+
echo "Reloading daemon"
75+
systemctl daemon-reload
76+
77+
echo "Starting Tomcat"
78+
systemctl start tomcat
5879

59-
echo "Restarting Tomcat"
60-
service tomcat9 restart
80+
echo "Enabling Tomcat on startup"
81+
systemctl enable tomcat
6182

6283
echo "Creating Tomcat curriculum and studentuploads folders"
6384
sudo -u tomcat -g tomcat mkdir $CATALINA_HOME/webapps/curriculum
@@ -146,7 +167,7 @@ systemctl start sysstat
146167
echo "Set log file max size to 1G"
147168
sed 's/{/{\n maxsize 1G/g' -i /etc/logrotate.d/rsyslog
148169
sed 's/{/{\n maxsize 1G/g' -i /etc/logrotate.d/nginx
149-
sed 's/{/{\n maxsize 1G/g' -i /etc/logrotate.d/tomcat9
170+
sed 's/{/{\n maxsize 1G/g' -i /etc/logrotate.d/tomcat
150171

151172
echo "Installing Clam AV"
152173
apt-get install clamav clamav-daemon -y

0 commit comments

Comments
 (0)