Linux system administration is outside the scope of Atlassian support. This page is provided for your information only.
On Linux/Solaris, the best practice is to install, configure and run each service (including Bamboo) as a dedicated user with only the permissions they require.
To install, configure and get Bamboo to start automatically on Linux/Solaris:
Create a bamboo user account which will be used to run Bamboo. For example, enter the following at a Linux console:
sudo useradd --create-home -c "Bamboo role account" bamboo
Create a directory into which Bamboo will be installed. For example:
sudo mkdir /opt/atlassian/bamboo sudo chown bamboo: /opt/atlassian/bamboo
Log in as the bamboo user to install Bamboo:
sudo su - bamboo
You need to extract Bamboo:
cd /opt/atlassian/bamboo tar zxvf /tmp/atlassian-bamboo-X.Y.tar.gz ln -s atlassian-bamboo-X.Y/ current
- Edit
current/atlassian-bamboo/WEB-INF/classes/bamboo-init.propertiesand setbamboo.home=/var/atlassian/application-data/bamboo (or any other directory of your choice, but not the same as Bamboo's installation directory) Then back as root, create the file
/etc/init.d/bamboo(code shown below), which will be responsible for starting up bamboo after a reboot (or when manually invoked).#!/bin/sh -e # bamboo startup script #chkconfig: 2345 80 05 #description: bamboo # Define some variables # Name of app ( bamboo, Confluence, etc ) APP=bamboo # Name of the user to run as USER=bamboo # Location of application's bin directory BASE=/opt/atlassian/bamboo/current # Location of Java JDK export JAVA_HOME=/usr/lib/jvm/java-6-sun case "$1" in # Start command start) echo "Starting $APP" /bin/su -m $USER -c "cd $BASE/logs && $BASE/bin/startup.sh &> /dev/null" ;; # Stop command stop) echo "Stopping $APP" /bin/su -m $USER -c "$BASE/bin/shutdown.sh &> /dev/null" echo "$APP stopped successfully" ;; # Restart command restart) $0 stop sleep 5 $0 start ;; *) echo "Usage: /etc/init.d/$APP {start|restart|stop}" exit 1 ;; esac exit 0初期化スクリプトを実行可能にします:
chmod \+x /etc/init.d/bamboo
- シンボリックリンクをランレベルのディレクトリに配置し、このスクリプトの開始と停止を自動的に行えるようにします。
Debian ベースのシステムの場合:
update-rc.d bamboo defaults
上記のコマンドを実行する事で、シンボリックリンクをランレベルのディレクトリに配置します:
Adding system startup for /etc/init.d/bamboo ... /etc/rc0.d/K20bamboo -> ../init.d/bamboo /etc/rc1.d/K20bamboo -> ../init.d/bamboo /etc/rc6.d/K20bamboo -> ../init.d/bamboo /etc/rc2.d/S20bamboo -> ../init.d/bamboo /etc/rc3.d/S20bamboo -> ../init.d/bamboo /etc/rc4.d/S20bamboo -> ../init.d/bamboo /etc/rc5.d/S20bamboo -> ../init.d/bamboo
RedHat ベースのシステムの場合:
init.d スクリプトに chkconfig 設定が含まれています
sudo /sbin/chkconfig --add bamboo
- スクリプトが正しい順序で実行されるようにします (特にデータベースの起動スクリプトの後に実行されるように)。
15 Comments
Martin
Oct 23, 2013I would suggest not to export JAVA_HOME in the init script by default unless the JDK path found by setclasspath.sh doesn't match the preferred one.
Ronald Bolante
Oct 24, 2013I don't see the point of going to the logs directory ($BASE/logs) before executing the init script in this line:
/bin/su -m $USER -c"cd $BASE/logs && $BASE/bin/startup.sh &> /dev/null"Is it to make sure that the logs directory exist because of the '&&' ? To think that this directory is created by default.
Anyway, no biggie just a thought.
Anonymous
Dec 10, 2013If service bamboo start is ran while bamboo is running it creates a new bamboo process.
ArmenA
Dec 11, 2013Running more than one Bamboo instances on the same machine is allowed. That's why Bamboo doesn't care if there is already another Bamboo instance running. However, if you are using the same port for both of them, there will be conflicts.
Wahid Atif
Dec 11, 2013Hi Nathan,
your init script is not LSB conform. That why Debian users will become this warning:
Just replace that block:
Tested on Debian Wheezy.
Wahid Atif
Jan 28, 2014Here is my version with "status" command:
#!/bin/sh set -e ### BEGIN INIT INFO # Provides: bamboo # Required-Start: $local_fs $remote_fs $network $time # Required-Stop: $local_fs $remote_fs $network $time # Should-Start: $syslog # Should-Stop: $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Atlassian Bamboo Server ### END INIT INFO # INIT Script ###################################### # Define some variables # Name of app ( bamboo, Confluence, etc ) APP=bamboo # Name of the user to run as USER=bamboo # Location of application's bin directory BASE=/opt/bamboo tomcat_pid() { echo `ps aux | grep "Dcatalina.base=/opt/bamboo" | grep -v grep | awk '{ print $2 }'` } case "$1" in # Start command start) echo "Starting $APP" /bin/su - $USER -c "export JAVA_HOME=/opt/jdk && cd $BASE/logs && $BASE/bin/startup.sh &> /dev/null" ;; # Stop command stop) echo "Stopping $APP" /bin/su - $USER -c "export JAVA_HOME=/opt/jdk && $BASE/bin/shutdown.sh &> /dev/null" echo "$APP stopped successfully" ;; # Restart command restart) $0 stop sleep 5 $0 start ;; status) pid=$(tomcat_pid) if [ -n "$pid" ] then echo "Your Bamboo Instance is running with pid: $pid" else echo "Your Bamboo Instance is not running" fi ;; *) echo "Usage: /etc/init.d/$APP {start|restart|stop|status}" exit 1 ;; esac exit 0Stephen Moretti
Jan 28, 2014Nice idea to add the status command. Unfortunately there are two problems.
The first is that this code is incomplete and so will error.
The second is that using catalina bootstrap as the trigger for PID is flawed. We run JIRA, Crowd and Confluence on one server, so this command returns a number of PIDs and doesn't determine directly whether bamboo is running.
If I get a chance I'll try to come up with a working version of this script.
Wahid Atif
Jan 28, 2014Hi Stephen,
I've just edited the script code into my current working version, it was a copy/paste typo.
For your second note, I had also to change the grep expression into
to get the unique PID of the running bamboo instance.
Daniel Hopper
Dec 14, 2013Why would the -m (preserve environment) be on this startup script. That seems like that will cause issues if this script is run as root and it generally is as it will then have all the root user environment instead of the bamboo user.
Gary Kennedy
Dec 19, 2013The -m argument indeed causes problems. The one we are getting at the moment is git is looking in the $HOME folder for config and of course can't access it because it is running as a different user. ($HOME is still pointing to /root because of this switch)
We are doing some other bamboo user changeover stuff at the moment, but we'll be removing that switch when we next use the service script. I'll let you know how it goes.
Daniel Hopper
Dec 19, 2013Exactly, I removed the -m flag and instead use
/bin/su-$USER, that way the proper users environment is used instead of whoever is running the commandGary Kennedy
Dec 19, 2013I think the only use for the flag is to keep the JAVA_HOME setting.
In which case you can set this up in the user profile, which also allows you to setup other tool config easily - seems better to me
Daniel Hopper
Dec 19, 2013So to be completely clear this is actually what I use
/bin/su - $USER -c"export JAVA_HOME=/usr/java/latest/ && cd $BASE/logs && $BASE/bin/startup.sh &> /dev/null"Thus setting the JAVA_HOME value for the particular user. Which could as well be accomplished in their particular shell profile as you mentioned (i.e. .bash_profile) but I don't particular like to rely on that myself and prefer to have the startup script be pretty deterministic in itself.
Wahid Atif
Dec 20, 2013You are abolutely right! I just got a failed Bamboo build because Bamboo tried to look for Maven settings.xml on /root/.m2/ instead of /home/<BAMBOO-USER>/.m2/! Here is the build output:
Found the following extra environment variables:
Thank you for the helpful hint!
ArmenA
Jan 06, 2014Regarding the -m option, we decided to leave it as it is now to avoid any possible misbehavior that can happen in some specific environments. If anybody is confident of changing it in his own instance and being responsible for maintenance and troubleshooting, feel free to do so.
Armen