#!/bin/sh
# $Id$
# Copyright 2015 Matthew Wall, all rights reserved
# startup script for getimg in daemon mode

### BEGIN INIT INFO
# Provides:          eyesee
# Required-Start:    $local_fs $remote_fs $syslog $ntp
# Required-Stop:     $local_fs $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: image capture system
# Description:       Manages the image capture system
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
APP=/opt/eyesee/bin/getimg.pl
PIDFILE=/var/run/getimg.pid
LOGFILE=/var/log/eyesee/getimg

[ -x "$APP" ] || exit 0

case "$1" in
     start)
        echo -n "Starting getimg..."
        $APP --daemon --cam "dlink DCS932" --host 192.168.0.10 --odir /var/www/img/192.168.0.10 >> $LOGFILE 2>&1 &
        pid=$!
        echo $pid > $PIDFILE
        echo "done"
        ;;

     stop)
        echo -n "Stopping getimg..."
        if [ -f $PIDFILE ]; then
            kill `cat $PIDFILE`
            rm $PIDFILE
        fi
        echo "done."
        ;;

     status)
        ;;

     *)
        echo "Usage: eyesee {start|stop}"
        exit 3
        ;;
esac

exit 0
