Inject default mail sender/recips for machine-wide rattail.conf

also tweak timezone handling
This commit is contained in:
Lance Edgar 2023-01-07 17:21:34 -06:00
parent 375cd1a36f
commit 5fcfc91d83
2 changed files with 8 additions and 6 deletions

View file

@ -20,8 +20,8 @@ configure_logging = true
[rattail.mail]
smtp.server = localhost
templates = rattail:templates/mail
default.from = root
default.to = root
default.from = ${getattr(env, 'email_default_sender', 'rattail@localhost')}
default.to = ${', '.join(getattr(env, 'email_default_recipients', ['root@localhost']))}
${'#'}#############################
@ -88,7 +88,7 @@ formatter = console
[handler_email]
class = handlers.SMTPHandler
args = ('localhost', 'root', ['root'], "[Rattail] Logging")
args = ('localhost', '${getattr(env, 'email_default_sender', 'rattail@localhost')}', ${getattr(env, 'email_default_recipients', ['root@localhost'])}, "[Rattail] Logging")
formatter = generic
level = ERROR

View file

@ -52,7 +52,7 @@ def bootstrap_rattail_base(c, deploy=None, timezone='America/Chicago',
deploy(c, 'rattail/rattail.conf.mako', '/etc/rattail/rattail.conf',
use_sudo=True, context=context)
else:
deploy_machine_conf(c, timezone=timezone)
deploy_machine_conf(c, timezone=timezone, context=context)
# python
python.bootstrap_python(c, deploy,
@ -93,13 +93,15 @@ def bootstrap_rattail(c, home='/var/lib/rattail', uid=None, shell='/bin/bash',
deploy_common(c, 'soffice', '/srv/rattail/init/soffice', use_sudo=True)
def deploy_machine_conf(c, timezone='America/Chicago'):
def deploy_machine_conf(c, env=None, timezone=None, context={}):
"""
Deploy the standard machine-wide ``rattail.conf`` file.
"""
mkdir(c, '/etc/rattail', use_sudo=True)
context['env'] = env
context['timezone'] = timezone or getattr(env, 'timezone', 'America/Chicago')
deploy_common(c, 'rattail/rattail.conf.mako', '/etc/rattail/rattail.conf', use_sudo=True,
context={'timezone': timezone})
context=context)
def delete_email_recipients(c, dbname):