Created
December 3, 2011 21:51
-
-
Save geowa4/1428257 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 hidden or 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 hidden or 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 |
Change this two lines:
TOMCAT=apache-tomcat-8.5.41
TOMCAT_URL=http://ftp.unicamp.br/pub/apache/tomcat/tomcat-8/v8.5.41/bin/$TOMCAT_ARCHIVE
what is whatever.war
what is whatever.war
Example path to your .war file intended to be changed for your needs.
Suppose I have vm where I need to run this same scrpit, but that vm don't have internet connection. Then how can we install and deploy the file?
Is user data/cloud config an option?
Not sure,
One more point, I am trying another approach where I am putting the Apache tomcat.gz.tz file and using the script I am unzipping it and copy the UI code into webapps folder but don't know it's not working.
Giving me error.
I checked it again..
It's working.. thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DO U HAVE SAME SCRIPT FOR TOMCAT 8 ?