8

I've successfully installed TeamCity ib CentOS 6.2 Minimal. I'm stuck on trying to run a script automatically on system startup:

/opt/TeamCity/bin/teamcity-server.sh start

I've googled around and tried various methods all of which seems to fail. Most of the methods points to adding the startup script to one of the rc.local files:

/etc/rc.d/rc.local
/etc/rc.local

And the contents of rc.local contains the line:

/opt/TeamCity/bin/teamcity-server.sh start

None of which will start the teamcity server

There are no problems if i run the script manually.

Seems simple but how do i get a shell script to auto run?

6
  • 1
    You'll need to describe what you mean by 'none of which works'. Because without it, everyone's guessing. Maybe describe in more detail what you've done and what output or failure messages or events occurred? May 14, 2012 at 17:06
  • that is the correct place to put it, so it seems that something is not kosher with the /etc/rc.d/rc.local entry or with the script itself. Are you able to post the contents of the script & the rc.local? Also, does the teamcity-server.sh shell script run when you do it manually? May 14, 2012 at 17:09
  • Yes, the teamcity-server runs fine manually. But its not practical to do this every time the server is restarted...
    – atp03
    May 14, 2012 at 17:15
  • Getting it to run manually but not through rc.local implies environmental differences. What's your PATH? Any other env variables?
    – cjc
    May 14, 2012 at 18:00
  • @cjc Not sure what you mean by 'PATH' - However if i run /etc/rc.d/rc.local manually the teamcity server can also start fine. Does this still make a difference?
    – atp03
    May 15, 2012 at 2:04

3 Answers 3

15

If the teamcity start script is a LSB-compliant init script (that is, if it provides start, stop and other arguments), you can just copy the script to /etc/init.d folder and run (as root):

# chkconfig --add <script_name>
# chkconfig <script_name> on

A symbolic link for the file should be OK too. So try (as root):

# ln -s /opt/TeamCity/bin/teamcity-server.sh /etc/init.d/teamcity-server
# chkconfig --add teamcity-server
# chkconfig teamcity-server on

If it doesn't start on initialization, but starting manually without problems, you should check:

  1. permissions (maybe the program can not be run as root. Try to log on as root and run it), and;
  2. your PATH (maybe the script need something but it does not know where it is).

To print the content of your PATH just run:

echo $PATH

To check if the reason to the script not start is the PATH, try:

$ cd /
$ PATH= /opt/TeamCity/bin/teamcity-server.sh

This command will temporary clear your PATH and run the command. If the command need some specific info on the PATH it will fail (be careful to run exactly as stated above, THERE IS a space between PATH= and the remaining of the command).

6

in Fedora 17 command

# chkconfig --add teamcity-server

say: service teamcity-server does not support chkconfig you should add header like:

#! /bin/bash
# chkconfig: - 10 90

only after that run first command.

1
  • 2
    And make sure your script is located in /etc/init.d/ :-) Oct 2, 2012 at 12:42
2

When the script is run manually, it works correctly. But, when run automatically it doesn't work.

I've found the culprit: TeamCity runs under the user teamcity. It must be present in the /etc/sudoers file and you should add, using visudo a line like this:

Defaults:teamcity !requiretty

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .