Skip to content

Instantly share code, notes, and snippets.

@btompkins
Last active December 23, 2015 05:09
Show Gist options
  • Save btompkins/6584831 to your computer and use it in GitHub Desktop.
Save btompkins/6584831 to your computer and use it in GitHub Desktop.
from fabric.api import *
from fabric.contrib.files import *
env.user = 'your_user'
env.host_string = 'your_host'
def add_teamcity_user():
runcmd('adduser --system --shell /bin/bash --gecos \'TeamCity Build Control\' --group --disabled-password --home /opt/teamcity teamcity')
def download_teamcity():
with cd('/opt/teamcity'):
runcmd('wget http://download.jetbrains.com/teamcity/TeamCity-7.1.3.tar.gz')
runcmd('tar -xzvf TeamCity-7.1.3.tar.gz')
def install_sun_java():
runcmd('apt-get -y install software-properties-common')
runcmd('apt-add-repository ppa:webupd8team/java')
runcmd('apt-get -y update')
runcmd('echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections')
runcmd('echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections')
runcmd('DEBIAN_FRONTEND=noninteractive apt-get -y install oracle-java7-installer')
def start_on_startup():
runcmd('chown -R www-data /opt/teamcity')
upload_template('teamcity', '/etc/init.d/teamcity', use_sudo=True) # see template file
runcmd('chmod 775 /etc/init.d/teamcity')
runcmd('update-rc.d teamcity defaults')
runcmd('/etc/init.d/teamcity start')
# Helpers
def runcmd(arg):
if env.user != "root":
sudo("%s" % arg, pty=True)
else:
run("%s" % arg, pty=True)
# Run entire setup
def setup_teamcity():
install_sun_java()
add_teamcity_user()
download_teamcity()
start_on_startup()
setup_teamcity()
# you should now be able to browse to 'http://localhost:8111/' to complete your teamcity installation...
# then I did this http://linuxconfig.org/linux-lvm-logical-volume-manager
"""
Thanks to
http://datagrams.blogspot.com/2013/02/install-teamcity-server-on-ubuntu-1204.html
http://askubuntu.com/questions/190582/installing-java-automatically-with-silent-option
"""
#!/bin/sh
# /etc/init.d/teamcity - startup script for teamcity
export TEAMCITY_DATA_PATH="/opt/teamcity/data/.BuildServer"
case $1 in
start)
start-stop-daemon --start -c www-data --exec /opt/teamcity/TeamCity/bin/teamcity-server.sh start
;;
stop)
start-stop-daemon --start -c www-data --exec /opt/teamcity/TeamCity/bin/teamcity-server.sh stop
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment