Change SpamAssassin Status
From brokenpoet.org wiki
This script enables or disables SpamAssassin for all users or all users with a list of exceptions
wget http://scripts.brokenpoet.org/chgsastatus.sh
#!/bin/bash # created by bcathy 2008.06.13 # # This script is designed to turn on or off spam assassin for all users or all users with exceptions, by username echo -n "Are we turning SA on or off? [ON/off]" echo "" read -e STATUS # If ON if [ -z "$STATUS" -o "$STATUS" = "on" ] || [ "$STATUS" = "ON" ] || [ "$STATUS" = "On" ]; then echo -n "Any User Exceptions? [N/y]" read -e EXCP if [ -z "$EXCP" -o "$EXCP" = "N" ] || [ "$EXCP" = "n" ]; then echo "We Can Continue Without Exceptions" for i in $(cat /etc/domainusers |cut -d':' -f1|sort) do file=/home/$i/.spamassassinenable if [ -a $file ] then : else echo "$i doesn't have .spamassassinenable. Creating . . . " touch /home/$i/.spamassassinenable chown $i:$i /home/$i/.spamassassinenable fi done # On with Exceptions elif [ "$EXCP" = "y" -o "$EXCP" = "Y" ]; then echo "What users (separate usernames with a space)?" read -e USERS newnames=$(echo $USERS|sed 's/\ /|/g') for i in $(cat /etc/domainusers |cut -d':' -f1|sort|awk '!/'$newnames'/') do file=/home/$i/.spamassassinenable if [ -a $file ] then : else echo "$i doesn't have .spamassassinenable. Creating . . . " touch /home/$i/.spamassassinenable chown $i:$i /home/$i/.spamassassinenable fi done # User did not enter Y or N else echo "Valid Input Not Entered, Please use 'y' or 'n'" break fi # If OFF elif [ "$STATUS" = "off" ] || [ "$STATUS" = "Off" ] || [ "$STATUS" = "OFF" ]; then echo -n "Any User Exceptions? [N/y]" read -e EXCP if [ -z "$EXCP" -o "$EXCP" = "N" ] || [ "$EXCP" = "n" ]; then echo "We Can Continue Without Exceptions" for i in $(cat /etc/domainusers |cut -d':' -f1|sort) do file=/home/$i/.spamassassinenable if [ -a $file ] then echo "$i has .spamassassinenable. Removing . . . " rm -rf /home/$i/.spamassassinenable fi done # Off with exceptions elif [ "$EXCP" = "y" -o "$EXCP" = "Y" ]; then echo "What users (separate usernames with a space)?" read -e USERS newnames=$(echo $USERS|sed 's/\ /|/g') for i in $(cat /etc/domainusers |cut -d':' -f1|sort|awk '!/'$newnames'/') do file=/home/$i/.spamassassinenable if [ -a $file ] then echo "$i has .spamassassinenable. Removing . . . " fi done # User did not enter Y or N else echo "Valid Input Not Entered, Please use 'y' or 'n'" break fi # User did not enter on or off else echo "Valid Input Not Entered, Please use 'on' or 'off" break fi
