Skip to content

Commit

Permalink
Fix Tomcat Deployment (#2212)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
jbronn authored and sputnam committed Mar 5, 2018
1 parent 6b6094a commit 97187cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
25 changes: 9 additions & 16 deletions scripts/tomcat/CopyWebAppsToTomcat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,18 @@ else # Centos
source ~/.bash_profile
fi

TOMCAT_USER=tomcat8
VMUSER=`id -u -n`
if [ "$VMUSER" = 'vagrant' ]
then
TOMCAT_USER=$VMUSER
fi

sudo -u $TOMCAT_USER rm -f $TOMCAT8_HOME/webapps/hoot-services.war
sudo -u $USER -g tomcat rm -f $TOMCAT8_HOME/webapps/hoot-services.war

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

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

sudo -u $TOMCAT_USER rm -rf $TOMCAT8_HOME/webapps/hootenanny-id/
sudo -u $TOMCAT_USER cp -R hoot-ui/dist $TOMCAT8_HOME/webapps/hootenanny-id
sudo -u $TOMCAT_USER mkdir -p $TOMCAT8_HOME/webapps/hootenanny-id/data
sudo -u $TOMCAT_USER cp hoot-ui/data/osm-plus-taginfo.csv $TOMCAT8_HOME/webapps/hootenanny-id/data
sudo -u $TOMCAT_USER cp hoot-ui/data/tdsv61_field_values.json $TOMCAT8_HOME/webapps/hootenanny-id/data
sudo -u $USER -g tomcat rm -rf $TOMCAT8_HOME/webapps/hootenanny-id/
sudo -u $USER -g tomcat cp -R hoot-ui/dist $TOMCAT8_HOME/webapps/hootenanny-id
sudo -u $USER -g tomcat mkdir -p $TOMCAT8_HOME/webapps/hootenanny-id/data
sudo -u $USER -g tomcat cp hoot-ui/data/osm-plus-taginfo.csv $TOMCAT8_HOME/webapps/hootenanny-id/data
sudo -u $USER -g tomcat cp hoot-ui/data/tdsv61_field_values.json $TOMCAT8_HOME/webapps/hootenanny-id/data

echo Web application files deployed.
12 changes: 6 additions & 6 deletions scripts/tomcat/centos7/tomcat8_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ fi
# Install Tomcat from our package in Hootenanny's dependency repo.
sudo yum install -y tomcat8

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

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

# Have the service run as the vagrant user and group.
sudo sed -i "s/User=tomcat/User=vagrant/g" $TOMCAT_SYSTEMD
sudo sed -i "s/Group=tomcat/Group=vagrant/g" $TOMCAT_SYSTEMD
# Have the service run as the development user and group.
sudo sed -i "s/User=tomcat/User=${USER}/g" $TOMCAT_SYSTEMD
sudo sed -i "s/Group=tomcat/Group=${USER}/g" $TOMCAT_SYSTEMD

sudo systemctl daemon-reload
sudo systemctl enable $TOMCAT_NAME
Expand All @@ -73,6 +73,6 @@ Please login to the host to view the logs:
sudo journalctl -u tomcat8
EOF
sudo chown vagrant:vagrant ${TOMCAT_LOGS}/catalina.out
sudo chown $USER:$USER ${TOMCAT_LOGS}/catalina.out

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

0 comments on commit 97187cd

Please sign in to comment.