Skip to content

Instantly share code, notes, and snippets.

@smaslennikov
Last active December 18, 2015 15:19
Show Gist options
  • Save smaslennikov/5803317 to your computer and use it in GitHub Desktop.
Save smaslennikov/5803317 to your computer and use it in GitHub Desktop.
#!/bin/bash
LOCATION=/home/pi/vids
PART=/home
USB=0
while :; do
TEMP=$(/opt/vc/bin/vcgencmd measure_temp)
DATE=$(date +"%m-%d-%y-%T")
echo "! $DATE-$TEMP.h264 starting..."
sudo raspivid -t 1200000 -o $LOCATION/$DATE-$TEMP.h264 -b 8000000
DISKUSAGE=$(df -h $PART | grep dev | awk '{ print $5}' | sed 's/%//g')
echo "! $DATE-$TEMP.h264 done at $(date +"%m-%d-%y-%T"), disk at $DISKUSAGE."
if [ $DISKUSAGE -ge 99 ]
then
if [ $USB == "2" ]
then
echo "Out of space!"
break
fi
if [ $USB == "1" ]
then
echo "Changing destination to USB 2"
sudo umount /media
sudo mount -o sync /dev/sdb1 /media
LOCATION=/media/vids
PART=/media
USB=2
fi
if [ $USB == "0" ]
then
echo "Changing destination to USB 1"
sudo mount -o sync /dev/sda1 /media
LOCATION=/media/vids
PART=/media
USB=1
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment