cleaning a bit, including moving out some old docs, and renaming
[feisty_meow.git] / infobase / configuration / services / team_city_startup
1 #!/bin/bash
2 #
3 # team_city_startup by Chris Koeritz
4 #
5 # /etc/init.d/team_city_startup
6 #
7 #uhhh chkconfig: 2345 01 99
8 # description: Starts the Team City Agent as our swbuild user.
9 #
10 ### BEGIN INIT INFO
11 # Provides: team_city_startup
12 # Required-Start:
13 # Required-Stop:
14 # Default-Start: 3 4 5
15 # Default-Stop: 0 1 2 6
16 # Short-Description: Team City Agent initialization
17 # Description: team city rc file. This rc script runs the agent as the
18 #       swbuild user.
19 ### END INIT INFO
20
21 usage() {
22     echo "Usage: $0 {start|stop|status|kill}"
23 }
24
25 function teamcity_action()
26 {
27   export JAVA_HOME=/usr/lib/jvm/java-6-sun
28   export HOME=/home/swbuild
29
30   # should become the swbuild user and tell team city the proper action.
31   su -m -c "/home/swbuild/teamcity_agent/bin/agent.sh $*" swbuild
32 }
33
34 test -x ${PARSER} || exit 0 # by debian policy
35
36 case "$1" in
37         start)
38                 teamcity_action start
39                 rc=$?
40                 ;;
41         stop)
42                 teamcity_action stop
43                 rc=$?
44                 ;;
45         kill)
46                 teamcity_action stop kill
47                 rc=$?
48                 ;;
49         status)
50                 procs_found=$(ps wuax | grep teamcity | grep -v grep)
51                 if [ -z "$procs_found" ]; then
52                   echo "Team City Agent is not running."
53                 else
54                   echo "Team City Agent is running."
55                 fi
56                 rc=$?
57                 ;;
58         *)
59                 usage
60                 exit 1
61                 ;;
62         esac
63 exit $rc
64
65