On 22/10/2012 21:28, Gustavo Etchudez wrote:
i'm using policyd with Accounting module under server with PLesk and i'm
running this simple script every 12 hours, i'll modify this to check and
add/remove only new or deleted domains for a new version
#!/bin/bash
mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa -e "SELECT name FROM
domains" > /home/scripts/list_doms.txt
mysql -uadmin -p`cat /etc/psa/.psa.shadow` policyd -e "DELETE FROM
policy_group_members WHERE PolicyGroupID='2'";
for a in `cat /home/scripts/list_doms.txt`; do
B="@"$a
mysql -uadmin -p`cat /etc/psa/.psa.shadow` policyd -e "INSERT INTO
policy_group_members VALUES (NULL,'2','$B', '0', NULL)"
done
Thank you very much for the code above. It has really helped me very much.
I am using ispconfig from http://www.ispconfig.org/.
Here is the script for use with ispconfig. Hope it helps someone.
---------------- start ---------------------------------
#!/bin/bash
$ispconfig_database_user = ispconfig_database_user
$ispconfig_password = ispconfig_password
$ispconfig_database = ispconfig_database
$policyd_database_username = policyd_database_username
$policyd_database_password = policyd_database_password
$policyd_database_name = policyd_database_name
# get the mail domains from the database into a text file.
mysql --skip-column-names -u$ispconfig_database_user
-p$ispconfig_password $ispconfig_database_name -e "SELECT domain FROM
mail_domain;" > /tmp/list_domains.txt
# delete all the internal domains from the group in policyd database.
mysql -u$policyd_database_username
--password="$policyd_database_password" $policyd_database_name -e
"DELETE FROM policy_group_members WHERE PolicyGroupID='2'";
# insert into the mail domains into the policyd database from the text file.
for a in `cat /tmp/list_domains.txt`; do
B="@"$a
mysql -u$policyd_database_username
--password="$policyd_database_password" $policyd_database_name -e
"INSERT INTO policy_group_members VALUES (NULL,'2','$B', '0', NULL)"
done
# Then delete the text file.
rm -f /tmp/list_domains.txt
----------------- end ----------------------------------
P.V.Anthony
_______________________________________________
Users mailing list
[email protected]
http://lists.policyd.org/mailman/listinfo/users_lists.policyd.org