@@ -4,7 +4,7 @@ export HOME=/home/ubuntu
44export BUILD_DIR=$HOME /build-folder
55export LEGACY_BUILD_DIR=$HOME /legacy-build-folder
66export BUILD_FILES=$HOME /wise-build-files
7- export CATALINA_HOME=/var/lib/tomcat9
7+ export CATALINA_HOME=/opt/tomcat
88
99if [[ " $DEPLOYMENT_GROUP_NAME " == " qa-wise-api-deployment-group" ]]; then
1010 export ENV=" qa"
@@ -28,9 +28,9 @@ echo "Installing AWS CLI"
2828apt-get install awscli -y
2929
3030echo " 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
3535echo " Installing Java 11"
3636apt-get install openjdk-11-jdk-headless -y
@@ -39,25 +39,46 @@ echo "Create tomcat group"
3939groupadd -g 1001 tomcat
4040
4141echo " 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
4444echo " Adding ubuntu user to tomcat group"
4545usermod -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
5068echo " Removing Tomcat ROOT folder"
5169rm -rf $CATALINA_HOME /webapps/ROOT
5270
5371echo " Add https to Tomcat server.xml"
5472sed ' 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
6283echo " Creating Tomcat curriculum and studentuploads folders"
6384sudo -u tomcat -g tomcat mkdir $CATALINA_HOME /webapps/curriculum
@@ -146,7 +167,7 @@ systemctl start sysstat
146167echo " Set log file max size to 1G"
147168sed ' s/{/{\n maxsize 1G/g' -i /etc/logrotate.d/rsyslog
148169sed ' 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
151172echo " Installing Clam AV"
152173apt-get install clamav clamav-daemon -y
0 commit comments