What is the best way to autostart STASH on linux debian/ubuntu platform

I Want a script to statup stash on linux ubuntu/debian.

This is a self question. I know a possible answer, but I can't comment on the Stash Documentation (I think is disabled). I made this question to share my script and get feedback from others.

5 answers

1 accepted

Create a startup script on /etc/init.d/stash with the contents:


# RUN_AS: The user to run fisheye as. Its recommended that you create a separate user account for security reasons

# STASH_INSTALLATION: The path to the Stash installation. Its recommended to create a symbolic link to the latest version so 
# the process will still work after upgrades. 
stashctl() {
        if [ "x$USER" != "x$RUN_AS" ]; then
                su - "$RUN_AS" -c "export STASH_HOME=$STASH_HOME;$STASH_INSTALLATION/bin/$1"
                "export STASH_HOME=$STASH_HOME;$STASH_INSTALLATION/bin/$1"

case "$1" in
                stashctl start-stash.sh
                stashctl stop-stash.sh
                stashctl stop-stash.sh
                sleep 10
                stashctl start-stash.sh
                echo "Usage: $0 {start|stop|restart}"

exit 0

This script is based on a Fisheye startup script. I recommend create a stash user, set the permissions to that user, and create a symlink to easy upgrades:

adduser stash
cd /opt/atlassian
ln -s atlassian-stash-1.0.0 stash
chown stash.stash -R /opt/atlassian/stash
chown stash.stash /var/atlassian/application-data/stash/

To startup on the system boot:

update-rc.d stash defaults

In my opinion its better to give the stash user only on the logs, temp, work folder the rights.

cd /opt/atlassian/stash
sudo chown -R stash:root logs temp work

1 votes
Colin Goudie Community Champion May 17, 2012

Other alternative is to use something like daemontools. The benefit of this over the init script above is it will monitor the process and ensure it restarts if errors occur. Plus you can set it up to have much nicer environment variable handling etc..

It is more involved initially creating correct run scripts etc.. but I find superior to the init scripts

I agree with you Colin Goudie.

I you try to do this with init scripts. If you have some script ready and want share, I will be grateful

Yes, by all means, I'd love to see a daemontools tutorial for stash !

In the meantime, thanks Giovanni for this very usefull startup script.

FYI, I've submitted a documentation request here: https://jira.atlassian.com/browse/STASH-2731

Thx Melanie :)

And juste because I stumbled on that myself, when installing any atlassian product as a service on Debian flavored linuxes (Debian, Ubuntu), one can use the above script (I use it for Jira and Stash). It's not fully LSB compliant, but it works well.

One has to remember if said product uses a SSL connector (via catalina) to also copy the .keystore (after importing SSL certificate) to the "dedicated user account's homedir" (created for this script's usage) too.

Not stash specific, but as you opened a 'linux services' issue, might as well point that out.

Have a nice day

EDIT1 : cf this Running+JIRA+over+SSL+or+HTTPS

EDIT2 : following previous link, for the 'service user'

1 ) either generate the SSL cert and import it (.keystore) while logged under the service user's account, then in 'server.xml' specify its location with

<Connector port="443" maxHttpHeaderSize="8192"
           keystoreFile="/home/serviceuser/.keystore" />

Points "SSLEnabled", "KeystorePass", and "keystoreFile" are not documented in the referenced article's body, but are all compulsory. Omitting 'keystoreFile' won't result in any error in the 'catalina.log' file, the '.keystore' is found, but... it won't be loaded properly by tomcat.

I just released my deb-package to outside. It maybe usefull for installing Stash on Ubuntu:


Feel free to test and post issues to tracker.

Suggest an answer

Log in or Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

631 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot