On ubuntu, upstart has replaced the System-V init.
There should be a bunch of existing scripts in /etc/init/. Copy one of them and modify it to suit your needs.
Sometimes the daemon you want to run should be run as a different user. Use the start-stop-daemon command for this. In the case below the 'teamcity' user will be running the daemon.
I've placed this in /etc/init/teamcity.conf
# Ubuntu upstart file at /etc/init/teamcity.conf start on runlevel  stop on runlevel  script exec start-stop-daemon --start --quiet --chuid teamcity --exec /home/teamcity/TeamCity/bin/teamcity-server.sh run end script
Test out the start-stop-daemon command manually.
# start-stop-daemon --start --chuid teamcity --exec /home/teamcity/TeamCity/bin/teamcity-server.sh run
If it is working fine then your script is ready.
Kill the job and in the next step start it via the upstart command.
Use the start command. The name of your job must match the name of your conf file in /etc/init.
# start teamcity teamcity start/running, process 7407 #
Reboot and check that your service automatically starts.
Use the stop command. If your job has forked upstart may have trouble stopping it.