mbligh | abd7e48 | 2009-09-04 16:32:45 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # autotest control init script, intended for Debian/Ubuntu type boxes. |
| 3 | # |
| 4 | # copy this to /etc/init.d/autotest, then run this: |
| 5 | # |
| 6 | # update-rc.d autotest start 95 2 3 4 5 . stop 90 0 1 6 . |
| 7 | |
| 8 | BASE_DIR=/usr/local/autotest |
| 9 | BECOME_USER=autotest |
| 10 | |
| 11 | if (test -r /lib/lsb/init-functions) |
| 12 | then |
| 13 | . /lib/lsb/init-functions |
| 14 | else |
| 15 | echo "This script requires /lib/lsb/init-functions" |
| 16 | exit 1 |
| 17 | fi |
| 18 | |
| 19 | # --- |
| 20 | |
| 21 | autotest_start() { |
| 22 | cd /tmp |
| 23 | |
mbligh | abd7e48 | 2009-09-04 16:32:45 +0000 | [diff] [blame] | 24 | log_daemon_msg "Starting monitor_db_babysitter" |
mbligh | 8b2655c | 2009-12-29 02:41:13 +0000 | [diff] [blame^] | 25 | ( ulimit -v 819200 ; \ |
| 26 | start-stop-daemon --start --quiet --chuid $BECOME_USER \ |
| 27 | --background --exec $BASE_DIR/scheduler/monitor_db_babysitter ) |
mbligh | abd7e48 | 2009-09-04 16:32:45 +0000 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | stop_daemon() { |
| 31 | PID_NAME=$1 |
| 32 | DAEMON_NAME=$2 |
| 33 | log_daemon_msg "Stopping $DAEMON_NAME" |
| 34 | start-stop-daemon --stop --quiet --pidfile $BASE_DIR/$PID_NAME.pid |
| 35 | } |
| 36 | |
| 37 | autotest_stop() { |
| 38 | stop_daemon monitor_db_babysitter babysitter |
| 39 | stop_daemon monitor_db scheduler |
mbligh | abd7e48 | 2009-09-04 16:32:45 +0000 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | case "$1" in |
| 43 | start) |
| 44 | autotest_start |
| 45 | ;; |
| 46 | |
| 47 | stop) |
| 48 | autotest_stop |
| 49 | ;; |
| 50 | |
| 51 | restart) |
| 52 | autotest_stop |
| 53 | sleep 2 |
| 54 | autotest_start |
| 55 | ;; |
| 56 | |
| 57 | *) |
| 58 | echo "Usage: $0 start|stop|restart" |
| 59 | exit 1 |
| 60 | |
| 61 | esac |