#!/bin/sh
#
# Start camera stream after boot (manually trigger the mdev event)
#
set -x

DEVNAME="video0"

start() {
    if [ -e "/dev/$DEVNAME" ]
    then
        DEVNAME="$DEVNAME" ACTION="add" /usr/libexec/camera-autostart.sh
    fi
}

stop() {
    if [ -e "/dev/$DEVNAME" ]
    then
        DEVNAME="$DEVNAME" ACTION="remove" /usr/libexec/camera-autostart.sh
    fi
}

restart() {
    stop
    sleep 1
    start
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart|reload)
        restart
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

exit $?
