bf_copy and bf_compact
David Relson
relson at osagesoftware.com
Sat Nov 13 01:03:46 CET 2004
Matthias,
Below are my latest versions of bf_copy and bf_compact. What's missing?
David
PS. IMHO, quoting directory and file names is truly ugly. Spaces
should be not be allowed in names.
######## bf_copy ########
#!/bin/sh
# bf_copy
if [ -z "$2" ] ; then
echo usage: db_copy source_dir dest_dir
exit
fi
SRC="$1"
DST="$2"
if [ ! -d "$DST" ] ; then
echo Directory "$DST" does not exist.
exit
fi
cp -p "$SRC"/log* "$SRC"/__db.* $DST
for FILE in "$SRC"/*.db ; do
NAME=`basename $FILE`
SIZE=`db_stat -h "$SRC" -d $NAME | grep "page size" | awk '{print
$1}'`
dd bs=$SIZE if="$FILE" of="$DST/"`basename "$FILE"`
done
for FILE in "$SRC"/*.db ; do
ls -l "$DST"/`basename "$FILE"`
done
#checkpoint and remove unneeded log files
db_checkpoint -1h $DST
db_archive -dh $DST
######## bf_compact ########
#!/bin/sh -x
# db_compact
if [ -z "$1" ] ; then
echo usage: db_compact source_dir [wordlist_name]
exit
fi
ORIG="$1"
if [ -z "$2" ] ; then
FILE="wordlist.db"
else
FILE="$2"
fi
TEMP="bf_compact.$$"
if [ -d $TEMP ] ; then
echo Directory $TEMP already exists.
echo exiting.
exit
else
mkdir $TEMP
fi
cp "$ORIG"/DB_CONFIG $TEMP || true
bogoutil -d "$ORIG"/"$FILE" | bogoutil -l $TEMP/"$FILE"
#checkpoint and remove unneeded log files
db_checkpoint -1h $TEMP
db_archive -dh $TEMP
mv "$ORIG" "$ORIG.old"
mv $TEMP "$ORIG"
More information about the bogofilter-dev
mailing list