Files
server/opt/psa/PMM/sa_convert.sh
cutemeli 0bfc6c8425 Initial
2025-12-22 10:32:59 +00:00

42 lines
997 B
Bash
Executable File

#!/bin/bash
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.
# Converts spamassassin bases from db 1.85 to new db format or removes it if db utilities does not exist
#
# Argument is a directory with spamassassin bases
#
# Returns 1 if db format is not 1.85, 0 otherwise
[ -z "$1" ] && exit 1
LIST=`file $1/* | grep 1.85 | cut -f1 -d:`
[ -z "$LIST" ] && exit 1
if [ -x "/usr/bin/db_dump185" ]; then
DB_DUMP185=/usr/bin/db_dump185
elif [ -x "/usr/bin/db1_dump185" ]; then
DB_DUMP185=/usr/bin/db1_dump185
elif [ -x "/usr/bin/db3_dump185" ]; then
DB_DUMP185=/usr/bin/db3_dump185
fi
if [ -x "/usr/bin/db_load" ]; then
DB_LOAD=/usr/bin/db_load
elif [ -x "/usr/bin/db4.2_load" ]; then
DB_LOAD=/usr/bin/db4.2_load
elif [ -x "/usr/bin/db4.3_load" ]; then
DB_LOAD=/usr/bin/db4.3_load
fi
for F in $LIST; do
if [ -n "$DB_DUMP185" ] && [ -n "$DB_LOAD" ]; then
DB="$F.db"
$DB_DUMP185 $F | $DB_LOAD $DB
mv $DB $F
else
rm -f $F
fi
done
exit 0