#!/bin/sh # cam.sh 0.8 # Copyright (C) 2005-2006 John Eriksson # # Description: # Makes a nice tar archive with images from the camera. # Just plug in the camera and run it. NAME="cam.sh" VERSION="0.8" usage() { echo "Usage: $NAME [GALLERYNAME] [DESCRIPTION] [OPTION]..." echo "Makes a nice tar archive with images from the camera." echo "Just plug in the camera and run it." echo echo " -s, --skip-mkthumb don't create the thumbnails" echo " -h, --help print this help and exit" echo " -v, --version output version information and exit" echo echo "Report bugs to ." exit 1 } version() { echo "$NAME $VERSION" exit 0 } if [ "$1" = "-v" -o "$1" = "--version" ]; then version fi if [ -z "$1" -o -z "$2" -o "$1" = "-h" -o "$1" = "--help" ]; then usage fi if [ ! -x /usr/bin/mkthumbs.sh -a "$3" != "-s" ]; then echo "No executable mkthumbs.sh found in /usr/bin." echo "Check the installation. Exiting..." exit 1 fi # set the first pwd here FIRSTPWD=$PWD echo "Starting $NAME $VERSION by Kohn." echo echo "Mounting camera filesystem..." if [ ! -d /tmp/tmpcam ]; then mkdir -p /tmp/tmpcam fi if ( ! mount /dev/sda1 /tmp/tmpcam ); then echo "Error: Mounting the camera filesystem failed." echo "Check connection between camera and computer." exit 1 fi echo "Copying and handling images..." if [ -f /tmp/tmppix ]; then echo "Error: Temporary directory /tmp/tmppix already exists." exit 1 fi # do the copying if [ -z "$3" ]; then cp -r /tmp/tmpcam/dcim/101msdcf /tmp/tmppix else cp -r /tmp/tmpcam/dcim/${3}msdcf /tmp/tmppix fi cd /tmp/tmppix echo "Unmounting and unloading USB-storage module..." umount /tmp/tmpcam rmdir /tmp/tmpcam echo "Copying done, unplugging the camera is OK." # put the images in the subdirectory mkdir "$1"; mv *.jpg "$1"; cd "$1" # create description file echo "$2" >info.txt # make web symlinks ln -s ../bildscript.php index.php ln -s ../bg.png # make thumbnails (call mkthumbs) if [ "$3" != "-s" ]; then echo "Making thumbnails..." mkthumbs.sh else echo "Skipping thumbnail making as desired." fi echo "Packing down the images..." cd ..; tar cvf "$FIRSTPWD/$1.tar" "$1" cd $FIRSTPWD echo "Cleaning up..." rm -rf /tmp/tmppix echo "Done." # EOF .