3 # This script supports multiple slaves in parallel with
4 # different configurations. Simply create a symlink from
5 # bitten-slave to bitten-foo, add the configuration in
6 # /etc/conf.d/bitten-foo and add bitten-foo to the DAEMONS
9 DAEMON_NAME
=$
(basename $0)
14 [ -f /etc
/conf.d
/$DAEMON_NAME ] && .
/etc
/conf.d
/$DAEMON_NAME
16 : ${BITTEN_USER:="bitten-slave"}
17 : ${BITTEN_URL:="http://localhost/trac/builds"}
21 : ${NAME:="$DAEMON_NAME"}
24 if [ -f /var
/run
/daemons
/$NAME ]; then
25 PID
=$
(cat /var
/run
/daemons
/$NAME)
26 if [ -f /proc
/$PID/cmdline
] && grep -q "$PATTERN" /proc
/$PID/cmdline
; then
38 nice setsid sudo
-u $BITTEN_USER LANG
=C HOME
=/home
/$BITTEN_USER USER
=$BITTEN_USER LOGNAME
=$BITTEN_USER bitten-slave
$BITTEN_OPTS "$BITTEN_URL" > /var
/log
/$DAEMON_NAME.log
2>&1 &
41 if [ -f /proc
/$PID/cmdline
] && grep -q bitten-slave
/proc
/$PID/cmdline
; then
42 echo $PID > /var
/run
/daemons
/$DAEMON_NAME
50 PID
=$
(getpid
$DAEMON_NAME "$BITTEN_URL")
51 if [ $PID -gt 0 ]; then
54 while [ $count -lt 5 ] && [ $
(getpid
$DAEMON_NAME "$BITTEN_URL") -gt 0 ]; do
56 count
=$
(expr $count + 1)
58 if [ $
(getpid
$DAEMON_NAME "$BITTEN_URL") -gt 0 ]; then
61 rm -f /var
/run
/daemons
/$DAEMON_NAME
67 stat_busy
"Starting $DAEMON_NAME: "
68 if [ $
(getpid
$DAEMON_NAME "$BITTEN_URL") -gt 0 ]; then
79 PID
=$
(getpid
$DAEMON_NAME "$BITTEN_URL")
80 if [ $PID -gt 0 ]; then
81 echo $DAEMON_NAME is running with PID
$PID.
84 echo $DAEMON_NAME is stopped.
89 stat_busy
"Shutting down $DAEMON_NAME: "
96 echo Failed to restart
$DAEMON_NAME >&2
104 if [ $
(getpid
$DAEMON_NAME "$BITTEN_URL") -gt 0 ]; then
107 echo Failed to restart
$DAEMON_NAME >&2
112 echo "Usage: $0 {start|stop|status|restart|reload|cond-restart}"