Add some cleanup functions for use when cloning rattail DBs

i.e. disable some email config
This commit is contained in:
Lance Edgar 2019-02-19 22:15:16 -06:00
parent bc4a8a686e
commit 0a33e7569b

View file

@ -28,7 +28,7 @@ from __future__ import unicode_literals, absolute_import
import os import os
from rattail_fabric2 import make_deploy, make_system_user, mkdir from rattail_fabric2 import postgresql, make_deploy, make_system_user, mkdir
deploy = make_deploy(__file__) deploy = make_deploy(__file__)
@ -54,3 +54,19 @@ def bootstrap_rattail(c, home='/var/lib/rattail', uid=None, shell='/bin/bash'):
deploy(c, 'bouncer', '/srv/rattail/init/bouncer', use_sudo=True) deploy(c, 'bouncer', '/srv/rattail/init/bouncer', use_sudo=True)
deploy(c, 'datasync', '/srv/rattail/init/datasync', use_sudo=True) deploy(c, 'datasync', '/srv/rattail/init/datasync', use_sudo=True)
deploy(c, 'filemon', '/srv/rattail/init/filemon', use_sudo=True) deploy(c, 'filemon', '/srv/rattail/init/filemon', use_sudo=True)
def delete_email_recipients(c, dbname):
"""
Purge all email recipient settings for the given database.
"""
postgresql.sql(c, "delete from setting where name like 'rattail.mail.%.to';", database=dbname)
postgresql.sql(c, "delete from setting where name like 'rattail.mail.%.cc';", database=dbname)
postgresql.sql(c, "delete from setting where name like 'rattail.mail.%.bcc';", database=dbname)
def disable_emails(c, dbname):
"""
Disable all emails for the given database.
"""
postgresql.sql(c, "update setting set value = 'false' where name like 'rattail.mail.%.enabled';", database=dbname)