version 1.1, 2006/06/29 07:38:52
|
version 1.2, 2006/12/11 18:09:39
|
Line 1
|
Line 1
|
#!/bin/bash |
#!/bin/bash |
|
|
VERSION="changemany V0.1 (29.6.2006 ROC)" |
VERSION="changemany V0.2 (11.12.2006 ROC)" |
|
|
#set -x |
#set -x |
|
|
if [ -z "$1$2" ] |
if [ -z "$1$2" ] |
then |
then |
echo $VERSION |
echo $VERSION |
echo "use: $0 dirlist [params...]" |
echo "use: $0 dirlist [-debug] [-dry-run] [-long] [params...]" |
echo " Changes the document directories given in the file dirlist." |
echo " Changes the document directories given in the file dirlist." |
echo " The list has the full pathname first and then one column per parameter, separated with spaces." |
echo " The list has the full pathname first and then one column per parameter, separated with spaces." |
|
echo " -debug: is passed to changemeta script" |
|
echo " -dry-run: only print out script calls" |
|
echo " -long: pass only one parameter but its value can contain spaces" |
exit 1 |
exit 1 |
fi |
fi |
|
|
DIRLIST="$1" |
DIRLIST="$1" |
|
if [ "$2" == "-debug" ] |
|
then |
|
shift |
|
DEBUG="-debug" |
|
fi |
|
if [ "$2" == "-dry-run" ] |
|
then |
|
shift |
|
DRY_RUN=1 |
|
fi |
|
if [ "$2" == "-long" ] |
|
then |
|
shift |
|
LONG=1 |
|
fi |
PARAM1="$2" |
PARAM1="$2" |
PARAM2="$3" |
PARAM2="$3" |
PARAM3="$4" |
PARAM3="$4" |
Line 26 fi
|
Line 44 fi
|
|
|
CNT=0 |
CNT=0 |
|
|
|
if [ -z $LONG ] |
|
then |
|
# short options |
# read directories and options from DIRLIST |
# read directories and options from DIRLIST |
while read DIR OPT1 OPT2 OPT3 |
while read DIR OPT1 OPT2 OPT3 |
do |
do |
Line 33 do
|
Line 54 do
|
if [ -d "$DIR" ] |
if [ -d "$DIR" ] |
then |
then |
echo "changing document $CNT: $DIR..." |
echo "changing document $CNT: $DIR..." |
if /usr/local/mpiwg/archive/changemeta "${PARAM1:+$PARAM1=$OPT1}" "${PARAM2:+$PARAM2=$OPT2}" "${PARAM3:+$PARAM3=$OPT3}" "$DIR" |
if [ -n "$DRY_RUN" ] |
|
then |
|
echo "/usr/local/mpiwg/archive/changemeta ${PARAM1:+$PARAM1=$OPT1} ${PARAM2:+$PARAM2=$OPT2} ${PARAM3:+$PARAM3=$OPT3} $DEBUG $DIR" |
|
echo " FAKED" |
|
else |
|
if /usr/local/mpiwg/archive/changemeta "${PARAM1:+$PARAM1=$OPT1}" "${PARAM2:+$PARAM2=$OPT2}" "${PARAM3:+$PARAM3=$OPT3}" "$DEBUG" "$DIR" |
then |
then |
echo " OK" |
echo " OK" |
else |
else |
echo "FAILED!" |
echo "FAILED!" |
# abort? |
# abort? |
fi |
fi |
|
fi |
else |
else |
echo "$CNT ERROR: document directory $DIR not found!" |
echo "$CNT ERROR: document directory $DIR not found!" |
fi |
fi |
done < $DIRLIST |
done < $DIRLIST |
|
else |
|
# long option |
|
# read directories and options from DIRLIST |
|
while read DIR OPT |
|
do |
|
CNT=$(( $CNT + 1 )) |
|
if [ -d "$DIR" ] |
|
then |
|
echo "changing document $CNT: $DIR..." |
|
if [ -n "$DRY_RUN" ] |
|
then |
|
echo "/usr/local/mpiwg/archive/changemeta ${PARAM1:+$PARAM1=$OPT} $DEBUG $DIR" |
|
echo " FAKED" |
|
else |
|
if /usr/local/mpiwg/archive_devel/changemeta.pl "${PARAM1:+$PARAM1=$OPT}" "$DEBUG" "$DIR" |
|
then |
|
echo " OK" |
|
else |
|
echo "FAILED!" |
|
# abort? |
|
fi |
|
fi |
|
else |
|
echo "$CNT ERROR: document directory $DIR not found!" |
|
fi |
|
done < $DIRLIST |
|
fi |
|
|
if [ $CNT = 0 ] |
if [ $CNT = 0 ] |
then |
then |