camera_checker.initd 1.82 KB
Newer Older
Russ Fish's avatar
Russ Fish committed
1 2
#! /bin/sh

David Johnson's avatar
David Johnson committed
3 4
#
# Copyright (c) 2005-2006 University of Utah and the Flux Group.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
David Johnson's avatar
David Johnson committed
24 25
#

Russ Fish's avatar
Russ Fish committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39
# chkconfig: 2345 30 90
# description: Vision camera checker software.

# Source function library.
. /etc/rc.d/init.d/functions

PORTBASE=6100
CAMERAS="0 1 2 3"

case "$1" in
start)
	for cam in $CAMERAS; do
		mezzopt=/etc/mezzanine/mezzanine.opt.camera$cam
        	mezzvid=/tmp/mezz_instance/dev/video$cam.ipc
40 41
                # The Mezzanine camera numbers are 2&3 on trash, but ours are 6&7.
        	if [[ `hostname` == trash ]]; then cam=`expr $cam + 4`; fi
Russ Fish's avatar
Russ Fish committed
42 43
        	checklog=/var/log/check.camera$cam.log
		/usr/testbed/sbin/camera_checker \
44
		 -C $cam -f $mezzopt -F $checklog $mezzvid -M fish@cs.utah.edu 2>&1 &
Russ Fish's avatar
Russ Fish committed
45 46 47 48 49 50
		echo $! > /var/run/camera_checker.$cam.pid
		PORTBASE=`expr $PORTBASE + 1`
	done
        ;;
stop)
	for cam in $CAMERAS; do
51
        	if [[ `hostname` == trash ]]; then cam=`expr $cam + 4`; fi
Russ Fish's avatar
Russ Fish committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
		kill `cat /var/run/camera_checker.$cam.pid`
		rm /var/run/camera_checker.$cam.pid
	done
        ;;
restart)
	$0 stop
	$0 start
	;;
*)
        echo "Usage: `basename $0` {start|stop|restart}" >&2
        ;;
esac

exit 0