1#! /bin/bash
2#
3# hudson Start/Stop the Hudson Continuous Integration server.
4#
5# chkconfig: 345 91 10
6# description: Hudson is a Continuous Integration server. \
7# It monitors a source code repository and triggers builds \
8# when it detects any changes. See https://hudson.dev.java.net/ \
9# for more details.
10# processname: hudson
11# pidfile: /var/run/hudson.pid
12
13
14# Source function library.
15#. /etc/rc.d/init.d/functions
16
17# Get config.
18#. /etc/sysconfig/network
19
20# Check that networking is up.
21#[ "${NETWORKING}" = "no" ] && exit 0
22
23startup=/home/hudson/start.sh
24shutdown=/home/hudson/stop.sh
25#export JAVA_HOME=/usr/java/jdk1.6.0
26HUDSON_USER=hudson
27
28start(){
29 echo -n $"Starting Hudson service: "
30 su - $HUDSON_USER -c $startup
31 RETVAL=$?
32 echo
33}
34
35stop(){
36 echo $"Stopping Hudson service: "
37 su - $HUDSON_USER -c $shutdown
38 RETVAL=$?
39 echo
40}
41
42status(){
43 numproc=`ps -u $HUDSON_USER -f | grep hudson.war | grep -v "grep hudson.war" | wc -l`
44 if [ $numproc -gt 0 ]; then
45 echo "Hudson is running..."
46 else
47 echo "Hudson is stopped..."
48 fi
49}
50
51restart(){
52 stop
53 start
54}
55
56
57# See how we were called.
58case "$1" in
59start)
60 start
61 ;;
62stop)
63 stop
64 ;;
65status)
66 status
67 ;;
68restart)
69 restart
70 ;;
71*)
72 echo $"Usage: $0 {start|stop|status|restart}"
73 exit 1
74esac
75
76exit 0