1#!/bin/sh 2# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5# 6# autotest control init script, intended for Debian/Ubuntu type boxes. 7# 8# copy this to /etc/init.d/autotest, then run this: 9# 10# update-rc.d autotest start 95 2 3 4 5 . stop 90 0 1 6 . 11 12BASE_DIR=/usr/local/autotest 13BECOME_USER=chromeos-test 14 15# Setup PATH so Autotest can run gsutil and cros_sdk for stack trace generation. 16PATH_EXTRAS=$PATH:/usr/local/google/gsutil:/usr/local/google/depot_tools 17 18if (test -r /lib/lsb/init-functions) 19then 20 . /lib/lsb/init-functions 21else 22 echo "This script requires /lib/lsb/init-functions" 23 exit 1 24fi 25 26# --- 27 28autotest_start() { 29 cd /tmp 30 31 log_daemon_msg "Starting monitor_db_babysitter" 32 ( ulimit -v 2048000 ; PATH=$PATH_EXTRAS USER=$BECOME_USER USERNAME=$USER \ 33 start-stop-daemon --start --quiet --chuid $BECOME_USER \ 34 --background --exec $BASE_DIR/scheduler/monitor_db_babysitter ) 35} 36 37stop_daemon() { 38 PID_NAME=$1 39 DAEMON_NAME=$2 40 log_daemon_msg "Stopping $DAEMON_NAME" 41 start-stop-daemon --stop --quiet --pidfile $BASE_DIR/$PID_NAME.pid 42} 43 44autotest_stop() { 45 stop_daemon monitor_db_babysitter babysitter 46 stop_daemon monitor_db scheduler 47} 48 49case "$1" in 50 start) 51 autotest_start 52 ;; 53 54 stop) 55 autotest_stop 56 ;; 57 58 restart) 59 autotest_stop 60 sleep 2 61 autotest_start 62 ;; 63 64 *) 65 echo "Usage: $0 start|stop|restart" 66 exit 1 67 68esac 69