Ramblings from MostlyChris

Tech stuff and a bit more

Browsing Posts in Plesk

Tonight I learned something. Yep! Still learning after all this time. What did I learn? Well I'm glad you asked. I had an occasion to have to delete all emails that were marked as spam but only for accounts that were forwarded to another email address.

The players:
RHEL 4
Plesk
Qmail

The magic:

for i in `find ./ -name .qmail | xargs grep '^\&' | cut -d: -f1 | sort | uniq `; do grep psa-spam
c $i > /dev/null; if [[ $? -eq "1" ]]; then sed -i '1i | /usr/local/psa/bin/psa-spamc reject' $i; fi; done

That's all there is to it. Wait? What? You don't understand? Well let me break it down for you. Actually, let me summarize for you. Time constraints don't permit me to write all day on this.

The one-liner above finds all .qmail files that have a forward email address in them. The forward address is denoted by a '&' at the beginning of a line. The cut command then strips off the beginning of the line and only shows the name of the file and the directory it is in. Since it is possible that there may be more than one line with '&' in the .qmail file, we sort uniq so that we don't enter the psa-spamc line more than once. Next, we use grep to check for the line '/usr/local/psa/bin/psa-spamc reject'. If that line already exists, we don't want to add it again. Finally, we use 'sed' to place that line at the top of the .qmail file. That's it. All done!

I recently was asked to allow access to a server's webmail. The problem was that there are no longer any domains pointed to the server. The solution, of course, was to connect to webmail via the IP address. Since this is a Plesk server, the following will allow access by IP.

Create a file in /etc/httpd/conf.d called zz012_horde.conf

Place the following in the file

<Directory /usr/share/psa-horde>
<IfModule sapi_apache2.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/etc/psa:/usr/share/psa-horde:/usr/share/psa-horde/config:/tmp"
php_admin_value include_path "/usr/share/psa-horde/lib:/usr/share/psa-horde/pear:."
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/etc/psa:/usr/share/psa-horde:/usr/share/psa-horde/config:/tmp"
php_admin_value include_path "/usr/share/psa-horde/lib:/usr/share/psa-horde/pear:."
</IfModule>
</Directory>
Alias /horde /usr/share/psa-horde

Restart apache and then access the file using the url http://ip.ad.dr.es/horde.

Ok.. so I am so going to plagiarize this but I needed a place to find it for easy reference. What better place than my blog. If psa fails to start after upgrade it is most likely a problem with a bug in the latest openssl package. Parallels has an update here:

http://kb.parallels.com/en/8338

Basically, you need to update the openssl package. Links for the various OS's are listed in the URL. Download the rpm, install it and then restart (or start) psa. Voila. Back to business as usual. I should also note that I experienced this in version 9.0.3 of Plesk. I don't know if it affects other versions.

Suppose you would like to send a copy of an incoming email to another account while the email still goes to the original account. You can do this by modifying the .qmail file of the original recipient and adding an entry that looks like the following:

&user@domain.com

On a Plesk server, a full .qmail file with the above changes looks like this:

| true
&user@domain.com
| /usr/bin/deliverquota ./Maildir

Keep in mind that if you do this on a Plesk server, these changes will be overwritten with mchk or upgrades so you will have to take measures to deal with this. I set the files immutable so they can't be changed by Plesk. This causes its own problems so you will have to decide if it is worth it.

If you need to change the TTLs on all domains in Plesk at once, you can massage the database with the following command:

mysql> UPDATE `dns_zone` SET `ttl` = '300', `ttl_unit` = '60' WHERE `id` >1;

Substitute the TTL values for what you need. Since the flat files are still used by named to provide DNS resolution, those will need to be updated as well. This command will do the trick:

mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -D psa -e 'select name from domains' | awk '{print "/usr/local/psa/admin/sbin/dnsmng update " $1 }' | sh