Re: how to Turn on SpamAssassi for all accounts (i.e. with yes option to di
For SpamAssassin to be enabled, you'd have to add the file .spamassassinenable to /home/username, then add the folder .spamassassin to /home/username with a user_prefs file in it. You could enable it on one account to see the file contents for the /home/username/.spamassassin/user_prefs file.
You could copy that file to /root/spamassassin/user_prefs then create a postwwwacct script for that to enable when the user account is created:
Code:
mkdir /root/spamassassin
cp /home/username/.spamassassin/user_prefs /root/spamassassin
Above, replace
username with the cPanel username in that above command
only. Any other instances in the lines below should not be replaced but entered exactly as input.
Code:
vi /usr/local/cpanel/scripts/postwwwacct
In that file put the following:
Code:
#!/usr/bin/perl
my %OPTS = @ARGV;
$ENV{USER} = “$OPTS{‘user’}”;
system q(mkdir /home/$USER/.spamassassin);
system q(touch /home/$USER/.spamassassinenable);
system q(cp /root/spamassassin/user_prefs /home/$USER/.spamassassin/);
system q(chown $USER:$USER /home/$USER/.spamassassinenable);
system q(chown -R $USER:$USER /home/$USER/.spamassassin);
system q(chmod 700 /home/$USER/.spamassassin);
After creating that file, ensure it can execute:
Code:
chmod +x /usr/local/cpanel/scripts/postwwwacct
I tested the above, and it does work for account creation. As for enabling this on all existing accounts, you could run the following commands:
Code:
for i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do mkdir /home/$i/.spamassassin && touch /home/$i/.spamassassinenable ;done
for i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do cp /root/spamassassin/user_prefs /home/$i/.spamassassin/ ;done
for i in `cat /etc/trueuserdomains | cut -d: -d' ' -f2-` ;do chown $i:$i /home/$i/.spamassassinenable && chown -R $i:$i /home/$i/.spamassassin ;done