Friday, April 16, 2010

Setting the treatment of spam for all users for LFS

Create the script

1. Telnet into the LFS server and log in as an administrative user.

2. Move to a directory where you can safely store files. For example:

cd /home/root/Files

3. Using your favorite Linux text editor, create a file called setallspamactions.pl.

4. Within the file, enter the following code:

#!/bin/sh
DEFPROB="$1"
ACTION="$2"
usage()
{
prog=$(basename $0)
echo "usage: $prog "
exit 0
}
if [ -z "$DEFPROB" -o -z "$ACTION" ]; then
usage
fi
if [ "$DEFPROB" != "definite" -a "$DEFPROB" != "probable" ]; then
usage
fi
if [ "$ACTION" != "Mark" \
-a "$ACTION" != "None" \
-a "$ACTION" != "Move" \
-a "$ACTION" != "Delete" ]; then
usage
fi
for u in /home/*; do
user=$(basename $u)
echo -n "$user = "
wv set [$DEFPROB spam action]$user=$ACTION
done
wv kick

5. Save the file.


Run the script

1. Before running the script, the permissions associated with the file must be changed so that it may be executable. To do this type:

chmod +x setallspamactions.pl

2. Run the script with the setting you wish to set globally. The syntax for running the script is as follows:

./setallspamactions.pl TYPE ACTION

The options for the TYPE of spam detected are definite and probable and the options for the spam treatment ACTION are Mark, None, Move and Delete. Therefore, adjust the script according to your preference. For example, if you would like to have all definite spam deleted from the server, type:

./setallspamactions.pl definite Delete

If you want to move all probable spam, type:

./setallspamactions.pl probable Move

3. The script shows all user accounts in LFS being modified to use the settings you have just set.

No comments: