#!/bin/bash -x # # $Id: photolog.sh,v 1.3 2004/07/24 01:58:58 AM $ # Copyright (c) 2002-2004, Dan Roscoe # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # Redistributions of source code must retain the above copyright notice, this # list of conditions and the following disclaimer. # # Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # # Neither the name of Dan Roscoe nor the names of its contributors may be used # to endorse or promote products derived from this software without specific # prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # Set some variables # Local Variables # Used to determine Directory structure YEAR=`date +%Y` MONTH=`date +%B` DAY=`date +%d` # Used to date the photolog TODAY=`date '+%B %d %Y'` # Who are you? USER=`whoami` # Where does the photocard/camera get mounted? MOUNT_POINT=/mnt/card # Where are the photos once the card is mounted? PHOTO_PATH=/mnt/card/dcim/*canon # Permanent Storeage location for the raw images PERMDIR=/home/dan/camera/$YEAR/$MONTH/$DAY # Size of the tunmbnails THUMB_WIDTH=102 THUMB_HEIGHT=77 # Size of the photos PHOTO_WIDTH=800 PHOTO_HEIGHT=600 # Working Directory. DIRECTORY=/home/dan/www/photolog # Temp file to write the (x)HTML too TMP_FILE=/home/dan/www/photolog/dat/photos.tmp # Data file to upload DAT_FILE=/home/dan/www/photolog/dat/photos.dat UPDATED_FILE=/home/dan/www/dat/photolog.dat # Remote Variables (on the server) # Address to upload the photos too REMOTE_HOST=threegeeks.dyndns.org # Username on the remote machine REMOTE_USER=dan # Where should the dat file be uploaded too REMOTE_DAT_FILE=/home/dan/www/photolog/dat/photos.dat # Relative URL to the website that the photos are displayed on WEBDIR=/photolog ############################################################################## # No changes are needed past this point, everything that you may or may # # not need to tweak is in the variables above. # ############################################################################## # Make the directories for the new image archives mkdir -p $DIRECTORY/$YEAR/$MONTH/$DAY/small $DIRECTORY/$YEAR/$MONTH/$DAY/thumbs $PERMDIR # Get the images from the card mount $MOUNT_POINT mv $PHOTO_PATH/* $PERMDIR umount $MOUNT_POINT # Temporary directory where the images are stored cd $PERMDIR chmod 644 * #generate the image archives for i in *.[Jj][Pp][Gg] do nice -n 10 convert -resize "$THUMB_WIDTH"x"$THUMB_HEIGHT" $i $DIRECTORY/$YEAR/$MONTH/$DAY/thumbs/$i nice -n 10 convert -resize "$PHOTO_WIDTH"x"$PHOTO_HEIGHT" $i $DIRECTORY/$YEAR/$MONTH/$DAY/small/$i done # Start to write the HTML echo "" >> $TMP_FILE echo "" >> $TMP_FILE echo "
$TODAY
" >> $TMP_FILE echo "Photolog last updated, $TODAY
" > $UPDATED_FILE scp -r $DIRECTORY/$YEAR/$MONTH/$DAY $REMOTE_USER@$REMOTE_HOST:$DIRECTORY/$YEAR/$MONTH scp $DAT_FILE $REMOTE_USER@$REMOTE_HOST:$DAT_FILE scp $UPDATED_FILE $REMOTE_USER@$REMOTE_HOST:$UPDATED_FILE