bf_compact.in

来自「一个C语言写的快速贝叶斯垃圾邮件过滤工具」· IN 代码 · 共 82 行

IN
82
字号
#! @SHELL@#  bf_compact source_dir [wordlist_name...]##    use to compact wordlist.db#    replaces original directory with new one#    renames original directory with '.old' extension# $Id: bf_compact.in,v 1.4 2006/03/27 00:20:12 relson Exp $set -e # die on errorsif [ -z "$1" ] ; then    echo 'usage: bf_compact source_dir [wordlist_name...]'    exit 1fi# extract home directoryBOGOHOME="$1"shiftif [ ! -d "$BOGOHOME" ] ; then    echo $BOGOHOME must be a directory, not a file    exit 1fi# strip trailing slasheswhile true; do    case "$BOGOHOME" in	*/) BOGOHOME=${BOGOHOME%/} ;;	*)  break ;;    esacdone# find wordlistsif [ -n "$1" ] ; then    FILES="$@"else    DIR=`bogofilter -QQ | grep ^bogofilter_dir | @AWK@ '{print $3}'`    if [ "$BOGOHOME" != "$DIR" ] ; then	FILES=`ls "$BOGOHOME"/*.db`    else	FILES=`bogofilter -QQ | grep ^wordlist | cut -f3 -d,`    fifiBOGOTEMP="bf_compact.$$"mkdir "$BOGOTEMP" || {    echo "Cannot create directory $BOGOTEMP. Abort."    exit 1}# copy Berkeley DB configuration if presentif test -f "$BOGOHOME"/DB_CONFIG ; then    cp -p "$BOGOHOME"/DB_CONFIG "$BOGOTEMP"/fi# determine transactionsif test "`find "$BOGOHOME/" -name "log.??????????" -print`" = "" ; then    TXN=noelse    TXN=yesfi# reload filesfor FILE in $FILES ; do    NAME=`basename $FILE`    bogoutil -d $FILE | bogoutil --db-transaction=no -l $BOGOTEMP/$NAMEdoneif [ $TXN = "yes" ] ; then    #create database environment files    bogofilter -e -C -d $BOGOTEMP --db-transaction=yes < /dev/nullfi# remove $BOGOHOME.old so we don't move the new backup *into* it# rather than renaming the backup to it.rm -rf "$BOGOHOME.old"mv "$BOGOHOME" "$BOGOHOME.old"mv  $BOGOTEMP  "$BOGOHOME"

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?