File:  [Repository] / foxridge-archiver / archivemany.sh
Revision 1.5: download - view: text, annotated - select for diffs - revision graph
Fri Jun 23 09:58:17 2006 UTC (17 years, 10 months ago) by casties
Branches: MAIN
CVS tags: HEAD
added error message for empty list file

#!/bin/bash

VERSION="archivemany V0.3 (23.6.2006 ROC)"

#set -x

if [ -z "$1$2" ]
then
    echo $VERSION
    echo "use: $0 docdir dirlist [params...]"
    echo "  Archives the directories given in the file dirlist inside docdir."
    exit 1
fi

BASEDIR="$1"
DIRLIST="$2"
PARAM1="$3"
PARAM2="$4"
PARAM3="$5"

if [ ! -d $BASEDIR ]
then
    echo "ERROR: base directory $BASEDIR not found!"
    exit 1
fi

if [ ! -f $DIRLIST ]
then
    echo "ERROR: directory list file $DIRLIST not found!"
    exit 1
fi

CNT=0

# read directories from DIRLIST
while read DIR
do
    CNT=$(( $CNT + 1 ))
    if [ -d "$BASEDIR/$DIR" ]
    then
	echo "archiving document $CNT: $DIR..."
	if /usr/local/mpiwg/archive/archiver "$PARAM1" "$PARAM2" "$PARAM3" "$BASEDIR/$DIR"
	then
	    echo "  done on `date`"
	else
	    echo "FAILED!"
	    # abort?
	fi
    else
	echo "$CNT ERROR: document directory $BASEDIR/$DIR not found!"
    fi
done < $DIRLIST

if [ $CNT = 0 ]
then
    echo "ERROR: the list file $DIRLIST seems to be empty!"
fi

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>