Dale Curtis | 74a314b | 2011-06-23 14:55:46 -0700 | [diff] [blame^] | 1 | #!/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 | |
| 34 | PROG="autotest" |
| 35 | BECOME_USER=$PROG |
| 36 | LOCKFILE=/var/lock/subsys/$PROG |
| 37 | |
| 38 | # Autotest paths |
| 39 | AUTOTEST_DIR="/usr/local/$PROG" |
| 40 | BABYSITTER="$AUTOTEST_DIR/scheduler/monitor_db_babysitter" |
| 41 | SCHEDULER="$AUTOTEST_DIR/scheduler/monitor_db.py" |
| 42 | |
| 43 | # Scheduler options |
| 44 | OPTIONS="--background" |
| 45 | |
| 46 | # Where to locate PID files |
| 47 | PID_PATH="$AUTOTEST_DIR" # "/var/run/$PROG" |
| 48 | BABYSITTER_PIDFILE="$PID_PATH/monitor_db_babysitter.pid" |
| 49 | SCHEDULER_PIDFILE="$PID_PATH/monitor_db.pid" |
| 50 | |
| 51 | # Assume pass |
| 52 | RETVAL=0 |
| 53 | |
| 54 | start() |
| 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 | |
| 66 | stop() |
| 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 | |
| 82 | reload() |
| 83 | { |
| 84 | echo -n $"Reloading $PROG: " |
| 85 | killproc -p $BABYSITTER_PIDFILE $PROG -HUP |
| 86 | RETVAL=$? |
| 87 | echo |
| 88 | return $RETVAL |
| 89 | } |
| 90 | |
| 91 | restart() { |
| 92 | stop |
| 93 | start |
| 94 | } |
| 95 | |
| 96 | force_reload() { |
| 97 | restart |
| 98 | } |
| 99 | |
| 100 | case "$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 |
| 134 | esac |
| 135 | exit $RETVAL |