Below is an Ubuntu script that stops Motion whenever I insert a USB - and starts it whenever I remove it.
CHECKUSB=
ITSON=1
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
fiwhile [ $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
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