Skip to content

Instantly share code, notes, and snippets.

@shaposhnikoff
Created January 13, 2015 11:42
Show Gist options
  • Save shaposhnikoff/296ff07eb66ecfa55be4 to your computer and use it in GitHub Desktop.
Save shaposhnikoff/296ff07eb66ecfa55be4 to your computer and use it in GitHub Desktop.
#!/bin/bash
current_usage=$( df -h | grep '/dev/root' | awk {'print $5'} )
max_usage=30%
DATE=`date +%Y-%m-%d_%Hh%Mm%Ss`
DIR="/srv/ftp"
echo "--- add sinc ---"
msmctl add sink cam5-mjpeg/704576/archive1 format=mp4 url=$DIR/cam5-640x480.mp4
echo "--- check disk space ---"
while true
do
if [ ${current_usage%?} -ge ${max_usage%?} ]; then
echo "--- no free space ---"
exit 1
elif [ ${current_usage%?} -lt ${max_usage%?} ]; then
echo "--- No problems ---"
fi
echo "--- stop record ---"
msmctl stop cam5-mjpeg/704576/archive1
echo "--- stop record ---"
if [[ -f $DIR/cam5-640x480.mp4 ]] ; then
timestamp=$(date --rfc-3339=seconds | tr ' ' '-');
newname=$DIR/cam5-640x480.${timestamp}.mp4
mv $DIR/cam5-640x480.mp4 $newname
fi.
msmctl start cam5-mjpeg/704576/archive1
sleep 60
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment