-
-
Save jmcabandara/db7abf0ffd6c8651f120b1830ba474de to your computer and use it in GitHub Desktop.
Simple Bash script to download Tomcat 7.0.23 and deploy a WAR.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TOMCAT=apache-tomcat-7.0.23 | |
TOMCAT_WEBAPPS=$TOMCAT/webapps | |
TOMCAT_CONFIG=$TOMCAT/conf/server.xml | |
TOMCAT_START=$TOMCAT/bin/startup.sh | |
TOMCAT_ARCHIVE=$TOMCAT.tar.gz | |
TOMCAT_URL=http://apache.mirrorcatalogs.com/tomcat/tomcat-7/v7.0.23/bin/$TOMCAT_ARCHIVE | |
WAR_FILE=whatever.war | |
if [ ! -e $TOMCAT ]; then | |
if [ ! -r $TOMCAT_ARCHIVE ]; then | |
if [ -n "$(which curl)" ]; then | |
curl -O $TOMCAT_URL | |
elif [ -n "$(which wget)" ]; then | |
wget $TOMCAT_URL | |
fi | |
fi | |
if [ ! -r $TOMCAT_ARCHIVE ]; then | |
echo "Tomcat could not be downloaded." 1>&2 | |
echo "Verify that eiter curl or wget is installed." 1>&2 | |
echo "If they are, check your internet connection and try again." 1>&2 | |
echo "You may also download $TOMCAT_ARCHIVE and place it in this folder." 1>&2 | |
exit 1 | |
fi | |
tar -zxf $TOMCAT_ARCHIVE | |
rm $TOMCAT_ARCHIVE | |
fi | |
if [ ! -w $TOMCAT -o ! -w $TOMCAT_WEBAPPS ]; then | |
echo "$TOMCAT and $TOMCAT_WEBAPPS must be writable." 1>&2 | |
exit 1 | |
fi | |
if [ ! -r $WAR_FILE ]; then | |
echo "$WAR_FILE is missing. Download it and run this again to deploy it." 1>&2 | |
else | |
cp $WAR_FILE $TOMCAT_WEBAPPS | |
fi | |
# place tomcat customizations here | |
sed -i s/8080/9090/g $TOMCAT_CONFIG | |
$TOMCAT_START |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TOMCAT=apache-tomcat-7.0.23 | |
TOMCAT_SHUTDOWN=$TOMCAT/bin/shutdown.sh | |
$TOMCAT_SHUTDOWN | |
rm -fr $TOMCAT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment