blob: 0c90ee725b732582001b1b3aa9859852a9cfc3fe [file] [log] [blame]
mblighabd7e482009-09-04 16:32:45 +00001#!/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
8BASE_DIR=/usr/local/autotest
9BECOME_USER=autotest
10
11if (test -r /lib/lsb/init-functions)
12then
13 . /lib/lsb/init-functions
14else
15 echo "This script requires /lib/lsb/init-functions"
16 exit 1
17fi
18
19# ---
20
21autotest_start() {
22 cd /tmp
23
24 log_daemon_msg "Starting tcpserver"
25 start-stop-daemon --start --quiet --chuid $BECOME_USER \
26 --background --exec $BASE_DIR/tcpserver/run_server.py
27
28 log_daemon_msg "Starting monitor_db_babysitter"
29 start-stop-daemon --start --quiet --chuid $BECOME_USER \
30 --background --exec $BASE_DIR/scheduler/monitor_db_babysitter
31}
32
33stop_daemon() {
34 PID_NAME=$1
35 DAEMON_NAME=$2
36 log_daemon_msg "Stopping $DAEMON_NAME"
37 start-stop-daemon --stop --quiet --pidfile $BASE_DIR/$PID_NAME.pid
38}
39
40autotest_stop() {
41 stop_daemon monitor_db_babysitter babysitter
42 stop_daemon monitor_db scheduler
43 stop_daemon run_server tcpserver
44}
45
46case "$1" in
47 start)
48 autotest_start
49 ;;
50
51 stop)
52 autotest_stop
53 ;;
54
55 restart)
56 autotest_stop
57 sleep 2
58 autotest_start
59 ;;
60
61 *)
62 echo "Usage: $0 start|stop|restart"
63 exit 1
64
65esac