Thursday, February 25, 2010

Auto start Atlassian Bamboo on CentOs

Earlier I wrote how to auto start several Atlassian products using a non root user. This time I'll tell you how to get Bamboo auto started on a CentOs environment.

Basically all elements from the earlier posts are present again, here we go. Create a dedicated user and give this user ownership of the Bamboo folders (change folder names as required).

useradd -m bamboo
chown -R bamboo /var/bamboo
chown -R bamboo /opt/Bamboo

Create the service script (thanks to wweis, script found here). Replace the variables as required. I used /opt/Bamboo for both home and install. The user value is bamboo in our case. Unfortunately my blog format seems to add extra line-feeds which corrupt the script, so maybe better copy it from the original blog post.

#!/bin/sh
# Startup script for bamboo
#
# chkconfig: 2345 99 01
# description: Atlassian Bamboo
# pidfile: /var/run/bamboo.pid
. /etc/rc.d/init.d/functions
BAMBOO_HOME=
BAMBOO_INSTALL=
BAMBOO_USER=
export BAMBOO_HOME
NAME=bamboo
BPID=${BAMBOO_INSTALL}/bamboo.pid
PID=/var/run/${NAME}.pid
cd ${BAMBOO_INSTALL}
if [ _$1 = _condrestart ]; then
su - ${BAMBOO_USER} -c "
cd ${BAMBOO_INSTALL} &&
${BAMBOO_INSTALL}/bamboo.sh stop &&
${BAMBOO_INSTALL}/bamboo.sh start
"
else
su - ${BAMBOO_USER} -c "
cd ${BAMBOO_INSTALL} &&
${BAMBOO_INSTALL}/bamboo.sh $@
"
fi
RC=$?
if [ -f $BPID ]; then
cp -- $BPID $PID
touch /var/lock/subsys/${NAME}
else
rm -- $PID /var/lock/subsys/${NAME} 2>/dev/null
fi
exit $RC

Now make the script executable, add it as a service, switch it on and start the service.

chmod +x /etc/init.d/bamboo
service --add bamboo
chkconfig bamboo on
service bamboo start

That should be it! If Bamboo does not work then check the log file and make sure that your database is running.

If you want the service to be reachable via port 80 then you can do so as follows. First open port 80 and 8085 - which is default for Bamboo.

system-config-securitylevel

Now add a redirect using iptables (this is one command line, not two commands)

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8085

Save the change.

/sbin/service iptables save

Please leave a comment if you have a suggestion.

No comments:

Post a Comment