Have FishEye+Crucible start at boot on Ubuntu

As this question popped up again and the answers are now outdated since the switch to systemd by the major distributions I'll add my systemd service definition for JIRA:

/etc/systemd/system/jira.service

[Unit]
Description=Atlassian JIRA
After=syslog.target network.target

[Service]
Type=forking
EnvironmentFile=/etc/sysconfig/jira
ExecStart=/path/to/jira/bin/startup.sh
ExecStop=/path/to/jira/bin/shutdown.sh
PIDFile=/path/to/jira/work/catalina.pid
SuccessExitStatus=143
User=jira
Group=jira
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

/etc/sysconfig/jira

# Name of the user to run as
USER=jira
# Location of application's bin directory
CATALINA_HOME=/path/to/jira
# Location of Java JDK
export JAVA_HOME=/usr/lib/jvm/java-8-oracle

Replace /path/to/jira with your application directory.

For the other Atlassian tools it's basically the same, just the startup scripts and the PID file location differ slightly:

  • Confluence

    • $appdir/bin/startup.sh
    • $appdir/bin/shutdown.sh
    • $appdir/work/catalina.pid
  • FishEye

    • $appdir/bin/start.sh
    • $appdir/bin/stop.sh
  • Bamboo

    • $appdir/bin/start-bamboo.sh
    • $appdir/bin/stop-bamboo.sh
  • Crowd

    • $appdir/bin/startup.sh
    • $appdir/bin/shutdown.sh
    • $appdir/apache-tomcat/work/catalina.pid

FishEye doesn't have support for a PID file yet, so currently it is necessary to use the workaround from that issue and add this line to fisheyectl.sh after the nohop command:

echo $! > $FISHEYE_INST/var/fisheye.pid

For Bamboo the PID file has to be explicitly defined via the CATALINA_PID variable (see $appdir/bin/catalina.sh). I haven't tested it yet, but it should be possible to set this variable in the EnvironmentFile file.

After the service definitions are created:

# start JIRA
sudo systemctl start jira
# enable automatic start on boot
sudo systemctl enable jira