wood burning stoves 2.0*
The moose likes Linux / UNIX and the fly likes Make script to install war files on EC2 instance from Maven Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Make script to install war files on EC2 instance from Maven " Watch "Make script to install war files on EC2 instance from Maven " New topic
Author

Make script to install war files on EC2 instance from Maven

James Akins
Greenhorn

Joined: Jun 06, 2013
Posts: 15
Hi,


So right now I am writing a script to have my instances download war files from my maven respository. This is what I have so far. This is written in Unix and I am having trouble getting started on the instructions on how to get the files from my Maven repository as well as JBoss. Any help would be appreciated! thanks in advance!


###############################
#BASIC START UP
###############################


sudo yum install httpd mysql mysql-server tomcat* java* apache*
chkconfig httpd on # turn on the web service
/etc/init.d/httpd start
if [ ! -f /var/www/html/
cd /var/www/html
#Maven and JBoss installation
wget http://download.jboss.org/jbossas/7.0/jboss-as-7.0.2.Final/jboss-as-web-7.0.2.Final.tar.gz
tar xvfz jboss-as-web-7.0.2.Final.tar.gz
wget http://www.poolsaboveground.com/apache/maven/maven-2/2.2.1/binaries/apache-maven-2.2.1-bin.tar.gz
tar xvfz apache-maven-2.2.1-bin.tar.gz
fi
yum -y update
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Hello James,

writing a script to have my instances download war files from my maven respository


I assume that you have your very own proxy repository where you store your artifacts and war files. The first thing coming to mind at the moment is to retrieve the war file via wget . You must already know the path to where your war file is on the repository so just issue a "wget" to retrieve the war file and then copy it ( scp ) to the ec2 instance.

However, just to share my experience , I also have a somewhat similar dev environment and what I do is that I have a parent pom where I am using the tomcat-maven-plugin to remote deploy my war to any remote server. Here is the maven-plugin for JBOSS . With these plugins you can also stop/start your jboss server instance remotely.


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
James Akins
Greenhorn

Joined: Jun 06, 2013
Posts: 15
Hi Saif,

Thank you for the reply! I really appreciate it. Could you elaborate a little more on your "similiar dev environment"

Also, when i am copying (scp) to the ec2 instance, what command is that? would it just be:

scp <url>/path/to/file(s) ?

or

in my script would it be ok to have like my Index of /maven/internal/releases/com/0.0.1/etc..

scp -r <url>

thanks for helping out!
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Hi James,
Sorry for the delay in the reply , I was caught up in some work . In-case you are still working out on the problem
As for my "similar dev environment" , I have setup a central proxy repository with nexus in which all the developed artifacts are pushed once tested and staged. Then I have a maven module project in which I have defined all the modules of the web-application that exist as artifacts on the cached repo. A simple bash script retrieves the war files and then copies them to the respective tomcat servers deployed on seperate ec2 instances .

The command for scp will be like


the -r flag (recursive) is used when copying a directory.

Do post back for any further queries.
James Akins
Greenhorn

Joined: Jun 06, 2013
Posts: 15
Hey Saif,

That's no worries. I was able to gain some progress for this bash script.

Would it be possible if I could see the simple bash script that retrieves the war files and then cpies them to the respective tomcat servers deployed on separate ec2 instances?

In my discoveries, I was able to find similiar scripts, but it may seem that aws has a bug for writing a simple bash script that preconfigures your instance such as installing packages(so you dont have to do it yourself every time you start a new instance). Did you have a similiar problem with this?

Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

In my discoveries, I was able to find similiar scripts, but it may seem that aws has a bug for writing a simple bash script that preconfigures your instance such as installing packages(so you dont have to do it yourself every time you start a new instance). Did you have a similiar problem with this?


Well I didnt have any startup scripts running when the instance starts up , the scripts I have made have to be executed manually so I cant realy confirm about this problem, I will , how-ever do a bit of re-search myself to look further into this problem



Do post back for any further queries
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Saif Asif wrote:
In my discoveries, I was able to find similiar scripts, but it may seem that aws has a bug for writing a simple bash script that preconfigures your instance such as installing packages(so you dont have to do it yourself every time you start a new instance). Did you have a similiar problem with this?


Well I didnt have any startup scripts running when the instance starts up , the scripts I have made have to be executed manually so I cant realy confirm about this problem, I will , how-ever do a bit of re-search myself to look further into this problem



Do post back for any further queries


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Make script to install war files on EC2 instance from Maven