diff options
author | lmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4> | 2011-05-25 20:13:36 +0000 |
---|---|---|
committer | lmr <lmr@592f7852-d20e-0410-864c-8624ca9c26a4> | 2011-05-25 20:13:36 +0000 |
commit | 5293a46205e7167aa2ff86b191fee3f802064276 (patch) | |
tree | 6c70a7378c73e453aeaa1fdbb30bef9c7ca179aa /utils/autotest-rh.init | |
parent | 2b095237a634a9865e324b5b46c15b089e64ba67 (diff) |
Add a RH-style init script for the autotest scheduler
This init script is meant to start the autotest scheduler
and run it on background automatically, during bootup.
Signed-off-by: James Laska <jlaska@redhat.com>
git-svn-id: svn://test.kernel.org/autotest/trunk@5381 592f7852-d20e-0410-864c-8624ca9c26a4
Diffstat (limited to 'utils/autotest-rh.init')
-rwxr-xr-x | utils/autotest-rh.init | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/utils/autotest-rh.init b/utils/autotest-rh.init new file mode 100755 index 00000000..e5618a0a --- /dev/null +++ b/utils/autotest-rh.init @@ -0,0 +1,135 @@ +#!/bin/bash +# +# autotestd Start up the autotest scheduler daemon +# +# Copyright 2009 Red Hat, Inc. +# +# This software may be freely redistributed under the terms of the GNU +# general public license. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# chkconfig: - 65 25 +# description: Autotest is a framework for fully automated testing. +# processname: monitor_db.py +# pidfile: /var/run/autotest/monitor_db_babysitter.pid +# +### BEGIN INIT INFO +# Provides: autotest +# Required-Start: $syslog $local_fs +# Required-Stop: $syslog $local_fs +# Default-Stop: 0 1 6 +# Short-Description: Start the autotest scheduler daemon +# Description: Autotest is a framework for fully automated testing. +### END INIT INFO + +# source function library +. /etc/rc.d/init.d/functions + +# pull in sysconfig settings +[ -f /etc/sysconfig/autotest ] && . /etc/sysconfig/autotest + +PROG="autotest" +BECOME_USER=$PROG +LOCKFILE=/var/lock/subsys/$PROG + +# Autotest paths +AUTOTEST_DIR="/usr/local/$PROG" +BABYSITTER="$AUTOTEST_DIR/scheduler/monitor_db_babysitter" +SCHEDULER="$AUTOTEST_DIR/scheduler/monitor_db.py" + +# Scheduler options +OPTIONS="--background" + +# Where to locate PID files +PID_PATH="$AUTOTEST_DIR" # "/var/run/$PROG" +BABYSITTER_PIDFILE="$PID_PATH/monitor_db_babysitter.pid" +SCHEDULER_PIDFILE="$PID_PATH/monitor_db.pid" + +# Assume pass +RETVAL=0 + +start() +{ + [ -f $BABYSITTER ] || exit 5 + + echo -n $"Starting $PROG: " + daemon --user $BECOME_USER --check $PROG $BABYSITTER $OPTIONS + RETVAL=$? + echo + [ "$RETVAL" = 0 ] && touch $LOCKFILE + return $RETVAL +} + +stop() +{ + echo -n $"Stopping $PROG: " + + killproc $BABYSITTER + + RETVAL=$? + echo + if [ "$RETVAL" = 0 ]; then + rm -f $LOCKFILE + rm -f $BABYSITTER_PIDFILE + rm -f $SCHEDULER_PIDFILE + fi + return $RETVAL +} + +reload() +{ + echo -n $"Reloading $PROG: " + killproc -p $BABYSITTER_PIDFILE $PROG -HUP + RETVAL=$? + echo + return $RETVAL +} + +restart() { + stop + start +} + +force_reload() { + restart +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + reload) + reload + ;; + condrestart|try-restart) + if [ -f $LOCKFILE ] ; then + if [ "$RETVAL" = 0 ] ; then + stop + # avoid race + sleep 3 + start + else + RETVAL=6 + fi + fi + ;; + status) + # status -p $PIDFILE $PROG + status $BABYSITTER + status $SCHEDULER + RETVAL=$? + ;; + *) + echo $"Usage: $0 {start|stop|restart|reload|condrestart|try-restart|status}" + RETVAL=2 +esac +exit $RETVAL |