# Script to email list of new Gallery Photos
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin

#RECIPENTS=`cat /addresses`
RECIPENTS=address@domain.com
SITENAME=YOURSITE

mv /home/tmp/thegallery.size.new /home/tmp/thegallery.size.old

du -h /home/thegallery > /home/tmp/thegallery.size.new

diff /home/tmp/thegallery.size.old /home/tmp/thegallery.size.new | grep -v "<" | grep ">" | sed "s/\/home\/thegallery\///" | sed "s/\/home\/thegallery//" | awk '{print "http://www.domain.net/photogallery/"$3}' > /home/tmp/thegallery.diff

sed '$s/http:\/\/www.domain.net\/photogallery\/$//' /home/tmp/thegallery.diff > /home/tmp/thegallery.sed
#sed '$s/http:\/\/www.domain.net\/photogallery\/$/' /home/tmp/thegallery.diff > /home/tmp/thegallery.sed

echo "
New Photographs have been uploaded to the PhotoGallery.
You may view the new photos at the link(s) below:

" > /home/tmp/thegallery.mail

cat /home/tmp/thegallery.sed >> /home/tmp/thegallery.mail

echo "
Please feel free to share your comments on any of the photos you
see on our site.  This can be done by clicking on the 'add comment'
link which can be found on each photographs page.

"  >> /home/tmp/thegallery.mail

# Mail results
MAILFILE=`cat /home/tmp/thegallery.sed | wc -l`
NUM=0

if [ $NUM -lt $MAILFILE ]
then
cat /home/tmp/thegallery.mail | mail -s "New Photos posted on `date +%m/%d` to the $SITENAME PhotoGallery"  $RECIPENTS
fi

# Clean up
#rm /tmp/thegallery.mail

exit 0


