TeamCity Start/Stop Script for Linux

I am using Teamcity on Ubuntu 14.04. Here is a simple script to start / stop TeamCity server.

#!/bin/sh
# /etc/init.d/teamcity – startup script for teamcity
export TEAMCITY_DATA_PATH=”/home/teamcity/.BuildServer”
export TEAMCITY_SERVER_OPTS=-Djava.awt.headless=true # Configure TeamCity for use on a headless OS.

case $1 in
start)
start-stop-daemon –start -c teamcity –exec /home/teamcity/TeamCity/bin/runAll.sh start
;;

stop)
start-stop-daemon –start -c teamcity –exec /home/teamcity/TeamCity/bin/runAll.sh stop
;;

esac

exit 0

Copy the script (teamcity) to etc/init.d.

Register the file as a startup script

sudo update-rc.d teamcity defaults

Make the file executable

sudo chmod +x /etc/init.d/teamcity

Now you can start teamcity with sudo service teamcity start or stop ist with sudo service teamcity stop