Skip to content

Commit 97187cd

Browse files
jbronnsputnam
authored andcommitted
Fix Tomcat Deployment (#2212)
* Use permissions of vagrant:tomcat when deploying the web application files. * Don't assume the invoking user is `vagrant` when installing/deploying Tomcat. (cherry picked from commit 1fa3806)
1 parent 6b6094a commit 97187cd

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

scripts/tomcat/CopyWebAppsToTomcat.sh

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,18 @@ else # Centos
1313
source ~/.bash_profile
1414
fi
1515

16-
TOMCAT_USER=tomcat8
17-
VMUSER=`id -u -n`
18-
if [ "$VMUSER" = 'vagrant' ]
19-
then
20-
TOMCAT_USER=$VMUSER
21-
fi
22-
23-
sudo -u $TOMCAT_USER rm -f $TOMCAT8_HOME/webapps/hoot-services.war
16+
sudo -u $USER -g tomcat rm -f $TOMCAT8_HOME/webapps/hoot-services.war
2417

2518
# Need to make sure we don't die due to nfs funkyness
26-
sudo -u $TOMCAT_USER rm -rf $TOMCAT8_HOME/webapps/hoot-services/
27-
sudo -u $TOMCAT_USER rm -rf $TOMCAT8_HOME/webapps/hoot-services/
19+
sudo -u $USER -g tomcat rm -rf $TOMCAT8_HOME/webapps/hoot-services/
20+
sudo -u $USER -g tomcat rm -rf $TOMCAT8_HOME/webapps/hoot-services/
2821

29-
sudo -u $TOMCAT_USER cp `ls -t hoot-services/target/hoot-services-*.war | sed -n 1p` $TOMCAT8_HOME/webapps/hoot-services.war
22+
sudo -u $USER -g tomcat cp `ls -t hoot-services/target/hoot-services-*.war | sed -n 1p` $TOMCAT8_HOME/webapps/hoot-services.war
3023

31-
sudo -u $TOMCAT_USER rm -rf $TOMCAT8_HOME/webapps/hootenanny-id/
32-
sudo -u $TOMCAT_USER cp -R hoot-ui/dist $TOMCAT8_HOME/webapps/hootenanny-id
33-
sudo -u $TOMCAT_USER mkdir -p $TOMCAT8_HOME/webapps/hootenanny-id/data
34-
sudo -u $TOMCAT_USER cp hoot-ui/data/osm-plus-taginfo.csv $TOMCAT8_HOME/webapps/hootenanny-id/data
35-
sudo -u $TOMCAT_USER cp hoot-ui/data/tdsv61_field_values.json $TOMCAT8_HOME/webapps/hootenanny-id/data
24+
sudo -u $USER -g tomcat rm -rf $TOMCAT8_HOME/webapps/hootenanny-id/
25+
sudo -u $USER -g tomcat cp -R hoot-ui/dist $TOMCAT8_HOME/webapps/hootenanny-id
26+
sudo -u $USER -g tomcat mkdir -p $TOMCAT8_HOME/webapps/hootenanny-id/data
27+
sudo -u $USER -g tomcat cp hoot-ui/data/osm-plus-taginfo.csv $TOMCAT8_HOME/webapps/hootenanny-id/data
28+
sudo -u $USER -g tomcat cp hoot-ui/data/tdsv61_field_values.json $TOMCAT8_HOME/webapps/hootenanny-id/data
3629

3730
echo Web application files deployed.

scripts/tomcat/centos7/tomcat8_install.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ fi
3434
# Install Tomcat from our package in Hootenanny's dependency repo.
3535
sudo yum install -y tomcat8
3636

37-
# Modify the vagrant user to be a part of the tomcat group, so it
37+
# Modify the invoking user to be a part of the tomcat group, so it
3838
# can write same directories as the tomcat service user.
39-
sudo usermod -a -G tomcat vagrant
39+
sudo usermod -a -G tomcat $USER
4040

4141
# Add local configuration file that sets up environment variables
4242
# for Hootenanny development.
@@ -48,9 +48,9 @@ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib:${HOOT_HOME}/lib
4848
export PATH=${HOOT_HOME}/bin:${PATH}
4949
EOF
5050

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
51+
# Have the service run as the development user and group.
52+
sudo sed -i "s/User=tomcat/User=${USER}/g" $TOMCAT_SYSTEMD
53+
sudo sed -i "s/Group=tomcat/Group=${USER}/g" $TOMCAT_SYSTEMD
5454

5555
sudo systemctl daemon-reload
5656
sudo systemctl enable $TOMCAT_NAME
@@ -73,6 +73,6 @@ Please login to the host to view the logs:
7373
7474
sudo journalctl -u tomcat8
7575
EOF
76-
sudo chown vagrant:vagrant ${TOMCAT_LOGS}/catalina.out
76+
sudo chown $USER:$USER ${TOMCAT_LOGS}/catalina.out
7777

7878
echo "######## End ${TOMCAT_NAME} installation ########"

0 commit comments

Comments
 (0)