blob: e5618a0abc12aae110b63c4c82922f2055718a94 [file] [log] [blame]
Dale Curtis74a314b2011-06-23 14:55:46 -07001#!/bin/bash
2#
3# autotestd Start up the autotest scheduler daemon
4#
5# Copyright 2009 Red Hat, Inc.
6#
7# This software may be freely redistributed under the terms of the GNU
8# general public license.
9#
10# You should have received a copy of the GNU General Public License
11# along with this program; if not, write to the Free Software
12# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
13#
14# chkconfig: - 65 25
15# description: Autotest is a framework for fully automated testing.
16# processname: monitor_db.py
17# pidfile: /var/run/autotest/monitor_db_babysitter.pid
18#
19### BEGIN INIT INFO
20# Provides: autotest
21# Required-Start: $syslog $local_fs
22# Required-Stop: $syslog $local_fs
23# Default-Stop: 0 1 6
24# Short-Description: Start the autotest scheduler daemon
25# Description: Autotest is a framework for fully automated testing.
26### END INIT INFO
27
28# source function library
29. /etc/rc.d/init.d/functions
30
31# pull in sysconfig settings
32[ -f /etc/sysconfig/autotest ] && . /etc/sysconfig/autotest
33
34PROG="autotest"
35BECOME_USER=$PROG
36LOCKFILE=/var/lock/subsys/$PROG
37
38# Autotest paths
39AUTOTEST_DIR="/usr/local/$PROG"
40BABYSITTER="$AUTOTEST_DIR/scheduler/monitor_db_babysitter"
41SCHEDULER="$AUTOTEST_DIR/scheduler/monitor_db.py"
42
43# Scheduler options
44OPTIONS="--background"
45
46# Where to locate PID files
47PID_PATH="$AUTOTEST_DIR" # "/var/run/$PROG"
48BABYSITTER_PIDFILE="$PID_PATH/monitor_db_babysitter.pid"
49SCHEDULER_PIDFILE="$PID_PATH/monitor_db.pid"
50
51# Assume pass
52RETVAL=0
53
54start()
55{
56 [ -f $BABYSITTER ] || exit 5
57
58 echo -n $"Starting $PROG: "
59 daemon --user $BECOME_USER --check $PROG $BABYSITTER $OPTIONS
60 RETVAL=$?
61 echo
62 [ "$RETVAL" = 0 ] && touch $LOCKFILE
63 return $RETVAL
64}
65
66stop()
67{
68 echo -n $"Stopping $PROG: "
69
70 killproc $BABYSITTER
71
72 RETVAL=$?
73 echo
74 if [ "$RETVAL" = 0 ]; then
75 rm -f $LOCKFILE
76 rm -f $BABYSITTER_PIDFILE
77 rm -f $SCHEDULER_PIDFILE
78 fi
79 return $RETVAL
80}
81
82reload()
83{
84 echo -n $"Reloading $PROG: "
85 killproc -p $BABYSITTER_PIDFILE $PROG -HUP
86 RETVAL=$?
87 echo
88 return $RETVAL
89}
90
91restart() {
92 stop
93 start
94}
95
96force_reload() {
97 restart
98}
99
100case "$1" in
101 start)
102 start
103 ;;
104 stop)
105 stop
106 ;;
107 restart)
108 restart
109 ;;
110 reload)
111 reload
112 ;;
113 condrestart|try-restart)
114 if [ -f $LOCKFILE ] ; then
115 if [ "$RETVAL" = 0 ] ; then
116 stop
117 # avoid race
118 sleep 3
119 start
120 else
121 RETVAL=6
122 fi
123 fi
124 ;;
125 status)
126 # status -p $PIDFILE $PROG
127 status $BABYSITTER
128 status $SCHEDULER
129 RETVAL=$?
130 ;;
131 *)
132 echo $"Usage: $0 {start|stop|restart|reload|condrestart|try-restart|status}"
133 RETVAL=2
134esac
135exit $RETVAL