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] [rattail.mail]
smtp.server = localhost smtp.server = localhost
templates = rattail:templates/mail templates = rattail:templates/mail
default.from = root default.from = ${getattr(env, 'email_default_sender', 'rattail@localhost')}
default.to = root default.to = ${', '.join(getattr(env, 'email_default_recipients', ['root@localhost']))}
${'#'}############################# ${'#'}#############################
@ -88,7 +88,7 @@ formatter = console
[handler_email] [handler_email]
class = handlers.SMTPHandler 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 formatter = generic
level = ERROR 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', deploy(c, 'rattail/rattail.conf.mako', '/etc/rattail/rattail.conf',
use_sudo=True, context=context) use_sudo=True, context=context)
else: else:
deploy_machine_conf(c, timezone=timezone) deploy_machine_conf(c, timezone=timezone, context=context)
# python # python
python.bootstrap_python(c, deploy, 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) 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. Deploy the standard machine-wide ``rattail.conf`` file.
""" """
mkdir(c, '/etc/rattail', use_sudo=True) 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, 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): def delete_email_recipients(c, dbname):