Skip to content

Instantly share code, notes, and snippets.

@zparnold
Created October 9, 2017 14:13
Show Gist options
  • Save zparnold/db91328fb9dfd6d85ad48fe7c8b4baf9 to your computer and use it in GitHub Desktop.
Save zparnold/db91328fb9dfd6d85ad48fe7c8b4baf9 to your computer and use it in GitHub Desktop.
A script to bootstrap Bamboo master server and attach an EFS instance to it.
#!/bin/bash
#### SET VARS
BAMBOO_VERSION=6.2.1
EFS_DNS=YOUR_EFS_ID.efs.YOUR_AWS_REGION.amazonaws.com
AWS_S3_BUCKET=your-aws-bucket-name
#### INSTALL DEPS
yum update -y
yum install -y java-1.8.0 docker git
yum remove -y java-1.7.0-openjdk
curl -L https://github.com/docker/compose/releases/download/1.15.0/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
service docker start
gpasswd -a bamboo docker
#### INSTALL THE NEW USER
useradd --create-home --home-dir /usr/local/bamboo --shell /bin/bash bamboo
#### INSTALL BAMBOO
wget https://www.atlassian.com/software/bamboo/downloads/binary/atlassian-bamboo-${BAMBOO_VERSION}.tar.gz
tar -xvzf atlassian-bamboo-${BAMBOO_VERSION}.tar.gz
mkdir -p /opt/bamboo/
mv atlassian-bamboo-${BAMBOO_VERSION}/ /opt/bamboo/
ln -nfs /opt/bamboo/atlassian-bamboo-${BAMBOO_VERSION} /opt/bamboo/current
#### INSTALL A USABLE DIRECTORY FOR APPLICATION DATA
mkdir -p /var/atlassian/application-data/bamboo
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 ${EFS_DNS}:/ /var/atlassian/application-data/bamboo
#### POTENTIAL MANUAL STEPS
# Verify that the following files are in the correct place with the correct values:
# YOU WILL HAVE TO SETUP THE FOLLOWING FILES IN YOUR OWN S3 BUCKET BEFORE USING THEM BELOW
aws s3 cp s3://${AWS_S3_BUCKET}/bamboo.cfg.xml /var/atlassian/application-data/bamboo/
aws s3 cp s3://${AWS_S3_BUCKET}/server.xml /opt/bamboo/current/conf/
aws s3 cp s3://${AWS_S3_BUCKET}/bamboo-init.properties /opt/bamboo/current/atlassian-bamboo/WEB-INF/classes/
BAMBOO_IP=`curl http://169.254.169.254/latest/meta-data/local-ipv4`
sed -i.bak s/BAMBOO_IP/"$BAMBOO_IP"/g /var/atlassian/application-data/bamboo/bamboo.cfg.xml
#### GET THE MYSQL JAR
aws s3 cp s3://ygrene-bamboo-terraform-state/mysql-connector-java-5.1.44-bin.jar /opt/bamboo/current/lib/
#### SET PROPER PERMISSIONS
chown -R bamboo:bamboo /var/atlassian/application-data/bamboo/bamboo.cfg.xml
chown -R bamboo:bamboo /opt/bamboo/*
# Start with this command:
/bin/su - bamboo -c "/opt/bamboo/current/bin/start-bamboo.sh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment