Detect and respond to a Thumbdrive getting inserted on Ubuntu.

I decided to start automating my TV show setup. I have a separate Mythbox at my office and a different XBMC at home. Why? well XBMC is a far better Media center than MythTV will ever hope to be. Myth is an awesome TV recording system but it royally sucks at a media center.

I got tired of manually copying. so I wrote the following script...



DRIVEIN=$(ls /media | grep -c TV)
if [ $DRIVEIN = "1" ]; then
beep -f 200
beep -f 600
echo "Drive named TV detected. Starting move operation..."
mv $VIDEODIR/*.avi $DRIVEDIR 1> /dev/null 2> /dev/null
echo "File Move operation complete. Unmounting drive..."
beep -f 900
beep -f 1200
beep -f 600
umount /media/TV

It runs from crontab every minute (* * * * * /location/ and will do a copy to the drive from the mythbuntu box. The reverse at the XBMC linux box will move all files off and to the storage location there.


Popular Posts