21st November
2009
written by Chris

I had occassion to run across the following question recently:

"Plesk was just upgraded to version 9.2.x and all domains now have an overuse policy set to not allow overuse. I can manually change this to allow overuse, but is there a way to do this through the database so I don't have to do it a domain at a time?".

The answer is yes, sort of. Plesk provides a 'domain_pref' utility that allows the setting of many of the parameters related to domain preferences. This allows one to change parameters for domains using the command line instead of logging into the interface. It works on one domain at a time, so some scripting foo is necessary in order to accomplish this on multiple domains.

In regards to the overuse policy, this handy little one-liner will allow the updating of all domains to a specific overuse policy.

mysql -Ns -uadmin -p<plesk_admin_password_here> psa -e "select name from domains" | awk '{printf("/usr/local/psa/bin/domain_pref –update %s -overuse block\n", $1)}' | sh

There are three options available for the overuse policy.

  • Block: Do not allow overuse
  • Notify: Allow overuse and notify the domain administrator when overuse has occurred.
  • Normal: Allow overuse with no notification.

The script above does the following things:
1. Connects to the Plesk database and selects a list of all domains from the 'domains' table.
2. Runs the 'domain_pref' CLI and sets the overuse policy to 'block'.

It has also come to my attention that the clients will have to have their overuse policy set as well.

mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` psa -e "select login from clients" | awk '{printf("/usr/local/psa/bin/client_pref –update %s -overuse normal\n", $1)}' | sh

As always, BACK UP the psa database before doing anything with the CLI.

Leave a Reply