Skip to content

Commit 338106d

Browse files
authored
Merge pull request #2204 from ngageoint/2196
Use Tomcat RPM
2 parents 7323cc5 + cbc8ef0 commit 338106d

17 files changed

+86
-217
lines changed

VagrantProvisionCentOS7.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ echo "### Installing Tomcat8..."
301301
TOMCAT_HOME=/usr/share/tomcat8
302302

303303
# Install Tomcat 8
304-
$HOOT_HOME/scripts/tomcat/tomcat8/centos7/tomcat8_install.sh
304+
$HOOT_HOME/scripts/tomcat/centos7/tomcat8_install.sh
305305

306306
# Configure Tomcat for the user
307307
if ! grep --quiet TOMCAT8_HOME ~/.bash_profile; then

VagrantProvisionUbuntu1604.sh.old

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ fi
429429
TOMCAT_HOME=/usr/share/tomcat8
430430

431431
# Install Tomcat 8
432-
$HOOT_HOME/scripts/tomcat/tomcat8/ubuntu/tomcat8_install.sh
432+
$HOOT_HOME/scripts/tomcat/ubuntu/tomcat8_install.sh
433433

434434
# Configure Tomcat
435435
if ! grep --quiet TOMCAT8_HOME ~/.profile; then
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Set HOOT_HOME to another location prior to running this script
5+
# if ~/hoot isn't the correct location
6+
if [ -z "$HOOT_HOME" ]; then
7+
HOOT_HOME=~/hoot
8+
fi
9+
TOMCAT_NAME=tomcat8
10+
TOMCAT_LEGACY_SYSTEMD=/etc/systemd/system/${TOMCAT_NAME}.service
11+
TOMCAT_SYSTEMD=/usr/lib/systemd/system/${TOMCAT_NAME}.service
12+
TOMCAT_LOGS=/var/log/tomcat8 # logs go here
13+
TOMCAT_CONFIG=/etc/tomcat8 # config files go here
14+
15+
echo "######## Begin ${TOMCAT_NAME} installation ########"
16+
17+
# If old systemd service unit exists, then Tomcat was installed manually
18+
# and must be uninstalled.
19+
if test -f $TOMCAT_LEGACY_SYSTEMD; then
20+
# Disable, stop, and remove the previous systemd service.
21+
sudo systemctl disable tomcat8
22+
sudo systemctl stop tomcat8
23+
sudo rm -f $TOMCAT_LEGACY_SYSTEMD
24+
sudo systemctl daemon-reload
25+
26+
# Clean up all manually-installed folders.
27+
sudo rm -fr /usr/share/tomcat8
28+
sudo rm -fr /var/lib/tomcat8
29+
sudo rm -fr /var/cache/tomcat8
30+
sudo rm -fr $TOMCAT_LOGS
31+
sudo rm -fr $TOMCAT_CONFIG
32+
fi
33+
34+
# Install Tomcat from our package in Hootenanny's dependency repo.
35+
sudo yum install -y tomcat8
36+
37+
# Modify the vagrant user to be a part of the tomcat group, so it
38+
# can write same directories as the tomcat service user.
39+
sudo usermod -a -G tomcat vagrant
40+
41+
# Add local configuration file that sets up environment variables
42+
# for Hootenanny development.
43+
sudo bash -c "cat >> ${TOMCAT_CONFIG}/conf.d/hoot.conf" << EOF
44+
export GDAL_DATA=/usr/share/gdal
45+
export HOOT_HOME=${HOOT_HOME}
46+
export HOOT_WORKING_NAME=hootenanny
47+
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib:${HOOT_HOME}/lib
48+
export PATH=${HOOT_HOME}/bin:${PATH}
49+
EOF
50+
51+
# Have the service run as the vagrant user and group.
52+
sudo sed -i "s/User=tomcat/User=vagrant/g" $TOMCAT_SYSTEMD
53+
sudo sed -i "s/Group=tomcat/Group=vagrant/g" $TOMCAT_SYSTEMD
54+
55+
sudo systemctl daemon-reload
56+
sudo systemctl enable $TOMCAT_NAME
57+
58+
if ! grep -i --quiet 'ingest/processed' ${TOMCAT_CONFIG}/server.xml; then
59+
echo "Adding Tomcat context path for tile images..."
60+
sudo sed -i.bak 's@<\/Host>@ <Context docBase=\"'"$HOOT_HOME"'\/userfiles\/ingest\/processed\" path=\"\/static\" \/>\n &@' ${TOMCAT_CONFIG}/server.xml
61+
fi
62+
63+
# Note: tomcat8 package already has `allowLinking=true` set in:
64+
# ${TOMCAT_CONFIG}/context.xml
65+
66+
# Clean out tomcat logfile. We restart tomcat after provisioning.
67+
sudo systemctl stop $TOMCAT_NAME
68+
sudo rm -f ${TOMCAT_LOGS}/catalina.out
69+
70+
# Recreate catalina.out to prevent error pop-up.
71+
sudo bash -c "cat >> ${TOMCAT_LOGS}/catalina.out" <<EOF
72+
Please login to the host to view the logs:
73+
74+
sudo journalctl -u tomcat8
75+
EOF
76+
sudo chown vagrant:vagrant ${TOMCAT_LOGS}/catalina.out
77+
78+
echo "######## End ${TOMCAT_NAME} installation ########"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-9.03 MB
Binary file not shown.

scripts/tomcat/tomcat8/centos7/etc/systemd/system/tomcat8.service

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)