first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / database / configuration / init.d / team_city_startup_example
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 buildor 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 #       buildor 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/buildor
29   export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
30
31   # should become the buildor user and tell team city the proper action.
32   su -m -c "/home/buildor/teamcity_agent/bin/agent.sh $*" buildor
33 }
34
35 test -x ${PARSER} || exit 0 # by debian policy
36
37 case "$1" in
38         start)
39                 teamcity_action start
40                 rc=$?
41                 ;;
42         stop)
43                 teamcity_action stop
44                 rc=$?
45                 ;;
46         kill)
47                 teamcity_action stop kill
48                 rc=$?
49                 ;;
50         status)
51                 procs_found=$(ps wuax | grep teamcity | grep -v grep)
52                 if [ -z "$procs_found" ]; then
53                   echo "Team City Agent is not running."
54                 else
55                   echo "Team City Agent is running."
56                 fi
57                 rc=$?
58                 ;;
59         *)
60                 usage
61                 exit 1
62                 ;;
63         esac
64 exit $rc
65
66