Atlassian JIRA — Automating the Standalone Install on MySQL

I’ve started thinking of my coding wanderings as akin to Alice’s rabbit holes — magical new places I play around in for probably a little too long. Automating sysadmin-type work with shell scripts has become my latest rabbit hole. Quickly running new services on Amazon’s EC2 is my inspiration.

So, this is the first little snippet, a simple initial building block that will become a part of larger scripts down the road. For those who don’t know, Atlassian has started giving away free licenses to all of their products to open source projects, so this gives you access to JIRA, Bamboo, Confluence, FishEye, Clover, Crowd, etc. These tools are amazingly useful and are all the best or amongst the best at what they do. Check out the Atlassian web site for more info.

This script automates the two trickiest parts of installing JIRA:

  1. Connecting to your database. In this case we connect to MySQL.
  2. Customizing the port to run JIRA on.

In the first instance, the script automatically downloads the MySQL JDBC driver, creates the JIRA database, and configures the JIRA user name and password for MySQL. The port customization is something you frequently want because so much runs on 8080 by default. These tasks are more annoying than tricky, but this script makes them a breeze.


  1. MySQL already running on the default port.
  2. You need to know your MySQL root password. The script will use it to create the JIRA database and to set permissions for the JIRA MySQL user.
  3. A downloaded version of JIRA standalone from the Atlassian web site. This will be a file called atlassian-jira-VERSION-standalone.tar.gz. The script just looks for a file starting with “atlassian-jira” and ending in “tar.gz” in the current directory.
  4. Java installed with JAVA_HOME set.

Future scripts will also include automated installing and configuring of MySQL as well as Java, but for now you need them configured ahead of time. I chose to run JIRA standalone because in my experience getting the separate wars to play nicely with my existing wars was tricky. In particular, some of the Atlassian war files take awhile to start up and don’t shut down as cleanly as they should. Using the standalone versions insures they won’t interfere with your other webapps.

When you have JIRA downloaded, MySQL running, and Java configured, go ahead and download the script from the LittleShoot web site.

Here’s all you need to run:


The script will guide you through the process of configuring and running JIRA, and it should be really self-explanatory. When the script is done, you’ll still need to run through JIRA’s configuration procedure within the browser, but the script has taken care of the hard part.

If you need to install JIRA from another script, you can also run something like the following, modifying it for your values of course.

./jira.bash jirauser jirapwd yourMySql_root_password adamfisk

The last argument is the user name of the user on the system who should own the jira directory.

Below is the full script.

#!/usr/bin/env bash
# This script performs all the JIRA configuration and setup for running
# JIRA on MYSQL.  This includes creating the JIRA database and creating
# a user on the database.
# If no arguments are passed to the script, it prompts you for the
# data it needs.  Otherwise, you must pass all the required data on the
# command line.  This makes it easier to incorporate this script into
# other scripts if desired.
# If you decide to pass in arguments, they are (in order):
# 1) The name of the new jira user in the database.
# 2) The password of the new jira user in the database.
# 3) Your MYSQL root password to create the JIRA database.
# 4) The user account to install JIRA under.  This account should
#    already exist on the system.
# To run this script:
# That file should be the downloaded copy of JIRA standalone.
# If you have any problems, please see the excellent guide at:

function die
echo $1
exit 1

ls ./atlassian-jira-*.tar.gz > /dev/null || die "The Atlassian JIRA tar.gz file must be in the current directory.  Have you successfully downloaded JIRA standalone?"

netstat -na | grep 3306 > /dev/null || die "MySQL does not appear to be running on port 3306.  JIRA cannot be installed without MySQL running"

function askUser
echo "Please enter your JIRA database user name:"

echo "Please enter your JIRA database password:"

echo "Please enter your MySQL root password:"

echo "What's the name of the user account on this machine you'd like to install JIRA under?"

if [ $# -ne "$ARGS" ]
    if [ $# -ne "0" ]
        echo "Usage: jira.bash jira_mysql_user_name jira_mysql_password mysql_root_password user_account"
        echo "You can also just run ./jira.bash to have the script guide you through the setup process."

echo "............................................................"
echo "  Hello $USER, let's start setting up JIRA standalone."
echo "............................................................"

function modifyPort
  echo "What port would you like to use for JIRA?  The default is 8080."
  echo "What shutdown port would you like to use for JIRA?  The default is 8005."
  echo "OK, got it.  Proceeding with install."

echo "Would you like to change the port JIRA runs on from the default of 8080? [y/n]"
case $CHANGE_PORT in
  modifyPort || die "Could not modify port"
  modifyPort || die "Could not modify port"
  echo "OK, using default port of 8080.  Proceeding with install."

function installJira
echo "Expanding `ls ./atlassian-jira-*.tar.gz`..."
tar xzf `ls ./atlassian-jira-*.tar.gz` || die "Could not open jira tgz file.  Aborting."

# Add a symbolic link to whichever version of JIRA we're running.
ln -s `ls | grep atlassian-jira-` jira

echo "Downloading MYSQL JDBC connector..."

# Somewhat bad to hard code this, but I don't think JIRA users alone will have much of an impact on this server.
curl -o mysqlj.tgz
tar xzf mysqlj.tgz
mv mysql-connector-java-5.1.5/mysql-connector-java-5.1.5-bin.jar jira/common/lib || die "Could not move myql jdbc jar"

echo "Customizing server.xml..."
cp jira/conf/server.xml jira/server.xml.copy
perl -pi -e s/Server\ port=\"8005\"/Server\ port=\"$CUSTOM_SHUTDOWN_PORT\"/g jira/conf/server.xml || die "Could not set shutdown port"
perl -pi -e s/Connector\ port=\"8080\"/Connector\ port=\"$CUSTOM_PORT\"/g jira/conf/server.xml || die "Could not set JIRA port"
perl -pi -e s/username=\"sa\"/username=\"$JIRA_USER_NAME\"/g jira/conf/server.xml || die "Could not modify jira user name"
perl -pi -e s/password=\"\"/password=\"$JIRA_PWD\"/g jira/conf/server.xml || die "Could not modify jira password"
perl -pi -e s/driverClassName=\"org.hsqldb.jdbcDriver/driverClassName=\"com.mysql.jdbc.Driver/g jira/conf/server.xml
perl -pi -e s/jdbc:hsqldb:\\$\{catalina.home\}\\/database\\/jiradb\"/jdbc:mysql:\\/\\/localhost\\/jiradb?autoReconnect\=true\&\;useUnicode\=true\&\;characterEncoding\=UTF8\"\\/\>/g jira/conf/server.xml || die "Could not set jdbc"
perl -pi -e s/minEvictableIdleTimeMillis\=/\/\"20\"\ \\/\>--\>/g jira/conf/server.xml || die "Could not finish comment"

echo "Customizing entityengine.xml..."
cp jira/atlassian-jira/WEB-INF/classes/entityengine.xml jira/entityengine.xml.copy || die "Could not make entityengine backup"
cp jira/atlassian-jira/WEB-INF/classes/entityengine.xml . || die "Could not copy entityengine to current directory"

perl -pi -e s/name=\"defaultDS\"\ field-type-name=\"hsql\"/name=\"defaultDS\"\ field-type-name=\"mysql\"/g entityengine.xml || die "Could not set entityengine database to MYSQL"
perl -pi -e s/schema-name=\"PUBLIC\"//g entityengine.xml || die "Could not remove public schema from entiry engine"

mv entityengine.xml jira/atlassian-jira/WEB-INF/classes/ || die "Could not move entity engine"

chown -R $USER_ACCOUNT jira || die "Could not set permissions to specified user: $USER_ACCOUNT"

cat < jira.sql
create database if not exists jiradb character set utf8;
flush privileges;
mysql -uroot -p$MYSQL_ROOT_PWD < jira.sql || die "Could not set up database for JIRA.  Is your root password correct?"
echo "Starting JIRA on port $CUSTOM_PORT..."
./jira/bin/ || die "Could not start JIRA"

echo ""
echo "-----------------------------------------------------------------------------------------------------------------"
echo "  Great, JIRA's starting up.  You should be able to access it momentarily on port $CUSTOM_PORT on this machine."
echo "-----------------------------------------------------------------------------------------------------------------"


exit 0

16 Responses to Atlassian JIRA — Automating the Standalone Install on MySQL

  1. Travis B. says:

    Hello. I just wanted to let you know that after about 2 weeks of trying to edit two files (I have been doing UNIX administration for about 15 years) to get jira to work with mysql I was ready to throw my computer out the window! I tried everything and followed their instructions to a “T” and nothing…it would just come up and say that it could not find the source directory…I went over everything and it would only work with the hsql database. Then tonight, I decide to do my millionth google search for help and typed in “jira mysql install” and bang, your page came up. I copied your script, removed all my original installation stuff and ran your script…WORKING!!!! I just wanted to say ‘Thank you!’ and let you know that it is individuals like yourself who make the www so awesome. So thank you for taking the time to put together a flawless installation script and getting our jira up and running on mysql in about 30 minutes…after I spun my wheels for weeks 🙂 I wish you had one of those ubiquitous PayPal buttons to donate, because this script is worth a donation…thank you!!!


  2. adamfisk says:

    Glad it worked for you Travis! I was actually a little worried newer JIRA releases might break the script, so I’m pleased to hear it’s still working.

    Best of luck.


  3. devrim says:

    Hi Adam, i can’t get around this error right after running your script,

    `Detecting JVM PermGen support…
    PermGen switch is NOT supported and will NOT be set automatically.
    If you encounter issues starting up JIRA Standalone Edition, please see the Troubleshooting guide at
    Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
    At least one of these environment variable is needed to run this program
    Could not start JIRA’

    I did ‘yum install JAVA’ (i don’t know any other way) and i guess it didn’t set the home variable, I checked directories but there was no Java there. My knowledge is not excellent on Linux matters yet, so i’d appreciate your input.


  4. adamfisk says:

    Hi Devrim- Ahhh, yes, the script should ideally check to make sure you have JAVA_HOME set I think. Mine’s set to /usr/java/default on my development machine (where I recently re-ran my JIRA script). You can check if java’s installed with:

    which java


    java –version

    If you don’t get anything, it’s not installed. Installing Java is traditionally a little squirrelly on the various Linux distributions, and I don’t think yum install java works. I believe your best bet is to download the binary from Sun at:

    The tricky thing is actually getting it on your machine (amazing how hard that is since that’s what Sun wants, right?) because of all the browser-based hoops you have to jump through. Try copying the link and using curl -o java.bin copied_link_here, but that might just give you some bogus redirect file or something because curl won’t have the cookies they’ve shoved in the browser. So, you may have to download it using the browser and then upload to your server, unless you’re actually browsing with Linux as well.

    Once you’ve got the bin or the rpm.bin up on your machine, then you can just follow Sun’s instructions here:

    Once you’ve got that working, running “which java” will tell you where java is. Set JAVA_HOME in .bashrc or wherever to the *directory above that (without the “bin” most likely).

    Hope that helps. Google for those various steps for anything that’s not clear. Check out my app/site at while you’re at it — releasing any day now!

  5. devrim says:

    Hi Adam,
    Thanks for your reply… I m so surprised of common idiocy is included in installing and running linux programs, especially now with Java.

    Well anyways..

    $ yum install java-1.7.0-icedtea-devel.i586
    $ ./jira.bash


    But i don’t know how to see jira now.. localhost:8080 doesn’t work..

    I think i am going to give up on this.

  6. adamfisk says:

    Do you see anything in your JIRA log file in the directory you’re running jira from? Very odd the script would complete fine and you wouldn’t see it running. Did you choose a custom port?

  7. devrim says:

    your script ends with:

    Customizing server.xml…
    Customizing entityengine.xml…
    Starting JIRA on port 8080…
    Detecting JVM PermGen support…
    PermGen switch is NOT supported and will NOT be set automatically.
    If you encounter issues starting up JIRA Standalone Edition, please see the Troubleshooting guide at
    Using CATALINA_BASE: /mnt/_downloads/jira
    Using CATALINA_HOME: /mnt/_downloads/jira
    Using CATALINA_TMPDIR: /mnt/_downloads/jira/temp
    Using JRE_HOME: /usr/java/jdk1.5.0_07/bin/java

    Great, JIRA’s starting up. You should be able to access it momentarily on port 8080 on this machine.

    i found one line in logs/catalina.out :
    /mnt/_downloads/jira/bin/ line 275: /usr/java/jdk1.5.0_07/bin/java/bin/java: No such file or directory

    and indeed i have no such directory.

    my whichjava is : /usr/bin/java
    my java -version is
    java version “1.7.0”
    IcedTea Runtime Environment (build 1.7.0-b21)
    IcedTea Client VM (build 1.7.0-b21, mixed mode)

    sorry to bother, but i guess you want to know it as well..

  8. adamfisk says:

    Sounds like your JAVA_HOME is wrong. What does echo $JAVA_HOME give you? Presumably it’s:


    it looks like it should be:


    You just need to edit that (.bashrc or .bash_profile or something else =) and then run ./ from jira’s bin directory.

  9. devrim says:

    it seems to me that my yum install didn’t create those directories,
    i used lynx and downloaded JDK (it’s a very funny program 🙂
    installed it, and it worked…
    Thanks again for your help.

    Ps: Littleshoot is very impressive.. I will install and try it asap. By the way, we will launch another free tool very soon with similar philosophy, we will definitely promote it there.

  10. adamfisk says:

    Great it’s working for you, and glad you like LittleShoot! There should be some stories coming out today on it, actually, so you’re ahead of the curve on it’s release.

    Good luck with the launch on your end.


  11. This is quite a up-to-date information. I’ll share it on Twitter.

  12. Kamal Ahmed says:

    tried your script… got errors
    Expanding ./atlassian-jira-4.4.tar.gz…
    Downloading MYSQL JDBC connector…

    curl: (7) couldn’t connect to host
    tar: mysqlj.tgz: Cannot open: No such file or directory
    tar: Error is not recoverable: exiting now
    tar: Child returned status 2
    tar: Exiting with failure status due to previous errors
    mv: cannot stat `mysql-connector-java-5.1.5/mysql-connector-java-5.1.5-bin.jar’: No such file or directory
    Could not move myql jdbc jar

    • adamfisk says:

      Yeah, this is super old now — I’d imagine some things it links to aren’t up anymore (like mysql-connector it sounds like — they’re probably only supporting newer versions).

      Jira has also had a bunch of new releases since I wrote this. I would just use it as a general guide, but it’s probably not going to work as a do-it-all script anymore. Sorry!!

  13. Hi there! I know this is kinda off topic but I’d figured I’d ask.
    Would you be interested in exchanging links or maybe guest authoring a blog post
    or vice-versa? My site goes over a lot of the same
    subjects as yours and I think we could greatly benefit from each other.
    If you are interested feel free to send me an email.
    I look forward to hearing from you! Awesome blog by the way!

  14. freddy says:

    # ./jira.bash
    ./jira.bash: line 1: !DOCTYPE: No such file or directory
    ./jira.bash: line 2: syntax error near unexpected token `newline’
    ./jira.bash: line 2: ` “”>’

  15. very helpful social media management in hull

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: