Created
February 25, 2018 16:00
-
-
Save spacekitcat/1bfb1f0b398da18097eefb4156150f5f to your computer and use it in GitHub Desktop.
Find an email the latest output image from the motion service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MOTION_TMP=/tmp/motion | |
TARGET_EMAIL=$TARGET_EMAIL_HERE | |
which motion | |
if [ ! $? -eq 0 ] | |
then | |
echo "Cannot find motion service in PATH, is it installed?" | |
exit 1 | |
fi | |
if [ ! -d $MOTION_TMP ] | |
then | |
echo "$MOTION_TMP for motion daemon doesn't exist, is it started?" | |
exit 1 | |
fi | |
IMAGES_TO_PROCESS=$(find $MOTION_TMP -name *.jpg -type f | wc -l) | |
if [ $IMAGES_TO_PROCESS -eq 0 ] | |
then | |
echo "No images to process" | |
exit 0 | |
fi | |
IMAGE_TO_POP=$(find $MOTION_TMP -name '*.jpg' -type f | sort | head -1) | |
echo "Sending $IMAGE_TO_POP to $TARGET_EMAIL" | |
mpack -s '[motion]' $IMAGE_TO_POP $TARGET_EMAIL | |
rm -f $IMAGE_TO_POP | |
echo "$(find $MOTION_TMP -name *.jpg -type f | wc -l) images left." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment