Wednesday, November 30, 2011

Motion - adding a dongle

I forgot to turn Motion off the other day and found a lot of pictures to sort through the next day, mostly of me picking my nose on the couch. So I did this.

Below is an Ubuntu script that stops Motion whenever I insert a USB - and starts it whenever I remove it.


CHECKUSB=
ITSON=1
while :
do
        while [ $ITSON == 1 ]
        do
                sleep 5
                if [ -d /media/$CHECKUSB/ ]
                then
                        ITSON=0
                        /etc/init.d/motion stop
                fi
        done
        while [ $ITSON == 0 ]
        do
                sleep 5
                if [ ! -d /media/$CHECKUSB/ ]
                then
                        ITSON=1
                        motion
                fi
        done
done


The daemon 'stop' command appears to kill a regular process as well as the daemon.

This basically works like a simple security dongle - take the USB with you on your way out and plug it in on your way home to ensure that only relevant activity is being captured. Very basic but it works.

0 comments:

Post a Comment