email: Rename app from email_server to email

For simplicity and consistency. Eliminate '_' in the name.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2022-01-28 18:50:33 -08:00 committed by James Valleroy
parent d35ec339d1
commit 32737a16ed
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
48 changed files with 77 additions and 76 deletions

View File

@ -10,7 +10,7 @@ import os
import sys
import plinth.log
from plinth.modules.email_server import audit
from plinth.modules.email import audit
EXIT_SYNTAX = 10
EXIT_PERM = 20

View File

@ -36,9 +36,9 @@ app = None
logger = logging.getLogger(__name__)
class EmailServerApp(plinth.app.App):
"""FreedomBox email server app"""
app_id = 'email_server'
class EmailApp(plinth.app.App):
"""FreedomBox app for an email server."""
app_id = 'email'
_version = 1
@ -46,25 +46,26 @@ class EmailServerApp(plinth.app.App):
"""The app's constructor"""
super().__init__()
info = plinth.app.Info(
app_id=self.app_id, version=self._version,
name=_('Postfix/Dovecot'), icon_filename='roundcube',
short_description=_('Email Server'), description=_description,
manual_page='EmailServer', clients=manifest.clients,
donation_url='https://rspamd.com/support.html')
info = plinth.app.Info(app_id=self.app_id, version=self._version,
name=_('Postfix/Dovecot'),
icon_filename='roundcube',
short_description=_('Email Server'),
description=_description, manual_page='Email',
clients=manifest.clients,
donation_url='https://rspamd.com/support.html')
self.add(info)
menu_item = menu.Menu('menu-email-server', info.name,
info.short_description, info.icon_filename,
'email_server:index', parent_url_name='apps')
menu_item = menu.Menu('menu-email', info.name, info.short_description,
info.icon_filename, 'email:index',
parent_url_name='apps')
self.add(menu_item)
shortcut = frontpage.Shortcut(
'shortcut-email-server', info.name,
'shortcut-email', info.name,
short_description=info.short_description, icon=info.icon_filename,
description=info.description,
configure_url=reverse_lazy('email_server:index'),
clients=info.clients, login_required=True)
configure_url=reverse_lazy('email:index'), clients=info.clients,
login_required=True)
self.add(shortcut)
# Other likely install conflicts have been discarded:
@ -72,7 +73,7 @@ class EmailServerApp(plinth.app.App):
# - qmail and smail are missing in Bullseye (Not tested,
# but less likely due to that).
packages = Packages(
'packages-email-server', [
'packages-email', [
'postfix', 'postfix-ldap', 'postfix-sqlite', 'dovecot-pop3d',
'dovecot-imapd', 'dovecot-ldap', 'dovecot-lmtpd',
'dovecot-managesieved'
@ -80,13 +81,13 @@ class EmailServerApp(plinth.app.App):
conflicts_action=Packages.ConflictsAction.IGNORE)
self.add(packages)
packages = Packages('packages-email-server-skip-rec', ['rspamd'],
packages = Packages('packages-email-skip-rec', ['rspamd'],
skip_recommends=True)
self.add(packages)
listen_ports = [(25, 'tcp4'), (25, 'tcp6'), (465, 'tcp4'),
(465, 'tcp6'), (587, 'tcp4'), (587, 'tcp6')]
daemon = Daemon('daemon-email-server-postfix', 'postfix',
daemon = Daemon('daemon-email-postfix', 'postfix',
listen_ports=listen_ports)
self.add(daemon)
@ -94,13 +95,13 @@ class EmailServerApp(plinth.app.App):
(993, 'tcp6'), (110, 'tcp4'), (110, 'tcp6'),
(995, 'tcp4'), (995, 'tcp6'), (4190, 'tcp4'),
(4190, 'tcp6')]
daemon = Daemon('daemon-email-server-dovecot', 'dovecot',
daemon = Daemon('daemon-email-dovecot', 'dovecot',
listen_ports=listen_ports)
self.add(daemon)
listen_ports = [(11332, 'tcp4'), (11332, 'tcp6'), (11333, 'tcp4'),
(11333, 'tcp6'), (11334, 'tcp4'), (11334, 'tcp6')]
daemon = Daemon('daemon-email-server-rspamd', 'rspamd',
daemon = Daemon('daemon-email-rspamd', 'rspamd',
listen_ports=listen_ports)
self.add(daemon)
@ -112,25 +113,25 @@ class EmailServerApp(plinth.app.App):
# /rspamd location
webserver = Webserver(
'webserver-email', # unique id
'email-server-freedombox', # config file name
'email-freedombox', # config file name
urls=['https://{host}/rspamd'])
self.add(webserver)
# Let's Encrypt event hook
letsencrypt = LetsEncrypt(
'letsencrypt-email-server-postfix', domains='*',
daemons=['postfix'], should_copy_certificates=True,
'letsencrypt-email-postfix', domains='*', daemons=['postfix'],
should_copy_certificates=True,
private_key_path='/etc/postfix/letsencrypt/{domain}/chain.pem',
certificate_path='/etc/postfix/letsencrypt/{domain}/chain.pem',
user_owner='root', group_owner='root', managing_app='email_server')
user_owner='root', group_owner='root', managing_app='email')
self.add(letsencrypt)
letsencrypt = LetsEncrypt(
'letsencrypt-email-server-dovecot', domains='*',
daemons=['dovecot'], should_copy_certificates=True,
'letsencrypt-email-dovecot', domains='*', daemons=['dovecot'],
should_copy_certificates=True,
private_key_path='/etc/dovecot/letsencrypt/{domain}/privkey.pem',
certificate_path='/etc/dovecot/letsencrypt/{domain}/cert.pem',
user_owner='root', group_owner='root', managing_app='email_server')
user_owner='root', group_owner='root', managing_app='email')
self.add(letsencrypt)
@staticmethod
@ -157,7 +158,7 @@ def setup(helper, old_version=None):
"""Installs and configures module"""
def _clear_conflicts():
component = app.get_component('packages-email-server')
component = app.get_component('packages-email')
packages_to_remove = component.find_conflicts()
if packages_to_remove:
logger.info('Removing conflicting packages: %s',
@ -170,8 +171,8 @@ def setup(helper, old_version=None):
# Setup
helper.call('post', audit.home.repair)
app.get_component('letsencrypt-email-server-postfix').setup_certificates()
app.get_component('letsencrypt-email-server-dovecot').setup_certificates()
app.get_component('letsencrypt-email-postfix').setup_certificates()
app.get_component('letsencrypt-email-dovecot').setup_certificates()
helper.call('post', audit.domain.set_domains)
helper.call('post', audit.ldap.repair)
helper.call('post', audit.spam.repair)

View File

@ -98,7 +98,7 @@ def _set_status(username, aliases, status):
def first_setup():
"""Create the database file and schema inside it."""
actions.superuser_run('email_server', ['aliases', 'setup'])
actions.superuser_run('email', ['aliases', 'setup'])
# Create schema if not exists
query = '''

View File

@ -7,7 +7,7 @@ import subprocess
from plinth.actions import superuser_run
from plinth.modules import config
from plinth.modules.email_server import postconf
from plinth.modules.email import postconf
from plinth.modules.names.components import DomainName
from . import tls
@ -31,7 +31,7 @@ def set_domains(primary_domain=None):
primary_domain = config.get_domainname() or list(all_domains)[0]
superuser_run(
'email_server',
'email',
['domain', 'set_domains', primary_domain, ','.join(all_domains)])

View File

@ -14,7 +14,7 @@ def repair():
directory. Ensure that 'others' can access /var/mail/.
"""
actions.superuser_run('email_server', ['home', 'set_up'])
actions.superuser_run('email', ['home', 'set_up'])
def action_set_up():

View File

@ -6,8 +6,8 @@ import logging
from django.utils.translation import gettext_lazy as _
import plinth.modules.email_server.aliases as aliases
import plinth.modules.email_server.postconf as postconf
import plinth.modules.email.aliases as aliases
import plinth.modules.email.postconf as postconf
from plinth import actions
from . import models
@ -82,7 +82,7 @@ def repair():
POST /audit/ldap/repair
"""
aliases.first_setup()
actions.superuser_run('email_server', ['ldap', 'set_up'])
actions.superuser_run('email', ['ldap', 'set_up'])
def action_set_up():
@ -102,13 +102,13 @@ def fix_sasl(diagnosis):
def action_set_sasl():
"""Handles email_server -i ldap set_sasl"""
"""Handles email -i ldap set_sasl"""
with postconf.mutex.lock_all():
fix_sasl(check_sasl())
def action_set_submission():
"""Handles email_server -i ldap set_submission"""
"""Handles email -i ldap set_submission"""
postconf.set_master_cf_options(service_flags=submission_flags,
options=default_submission_options)
postconf.set_master_cf_options(service_flags=smtps_flags,
@ -140,6 +140,6 @@ def fix_alias_maps(diagnosis):
def action_set_ulookup():
"""Handles email_server -i ldap set_ulookup"""
"""Handles email -i ldap set_ulookup"""
with postconf.mutex.lock_all():
fix_alias_maps(check_alias_maps())

View File

@ -9,8 +9,8 @@ import subprocess
from django.utils.translation import gettext_lazy as _
from plinth import actions
from plinth.modules.email_server import interproc, lock, postconf
from plinth.modules.email_server.modconf import ConfigInjector
from plinth.modules.email import interproc, lock, postconf
from plinth.modules.email.modconf import ConfigInjector
from . import models
@ -94,7 +94,7 @@ def get():
def repair():
actions.superuser_run('email_server', ['spam', 'set_filter'])
actions.superuser_run('email', ['spam', 'set_filter'])
def check_filter(title=''):

View File

@ -1,7 +1,7 @@
"""TLS configuration for postfix and dovecot."""
# SPDX-License-Identifier: AGPL-3.0-or-later
from plinth.modules.email_server import interproc, postconf
from plinth.modules.email import interproc, postconf
# Mozilla Guideline v5.6, Postfix 1.17.7, OpenSSL 1.1.1d, intermediate
# Generated 2021-08

View File

@ -27,6 +27,6 @@
<Location "/.well-known/autoconfig/mail/config-v1.1.xml">
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^ /plinth/apps/email_server/config.xml [PT]
RewriteRule ^ /plinth/apps/email/config.xml [PT]
</IfModule>
</Location>

View File

@ -1,5 +1,5 @@
# Direct edits to this file will be lost!
# Manage your settings on Plinth <https://localhost/plinth/apps/email_server>
# Manage your settings on FreedomBox <https://localhost/plinth/apps/email/>
# Outlook and Windows Mail works only with LOGIN mechanism, not the standard
# PLAIN:

View File

@ -1,5 +1,5 @@
# Direct edits to this file will be lost!
# Manage your settings on Plinth <https://localhost/plinth/apps/email_server>
# Manage your settings on FreedomBox <https://localhost/plinth/apps/email/>
# Users in FreedomBox are not expected to access mail by logging into the
# system. Storing the mail in single location instead of home directories and

View File

@ -1,5 +1,5 @@
# Direct edits to this file will be lost!
# Manage your settings on Plinth <https://localhost/plinth/apps/email_server>
# Manage your settings on FreedomBox <https://localhost/plinth/apps/email/>
# Use sdbox, a format specific to dovecot, for storing mails. The format allows
# better performance with some IMAP queries. When this is combined with Full

View File

@ -1,5 +1,5 @@
# Direct edits to this file will be lost!
# Manage your settings on Plinth <https://localhost/plinth/apps/email_server>
# Manage your settings on FreedomBox <https://localhost/plinth/apps/email/>
protocol lmtp {
mail_plugins = $mail_plugins sieve

View File

@ -1,5 +1,5 @@
# Direct edits to this file will be lost!
# Manage your settings on Plinth <https://localhost/plinth/apps/email_server>
# Manage your settings on FreedomBox <https://localhost/plinth/apps/email/>
namespace inbox {
mailbox Archive {

View File

@ -1,5 +1,5 @@
# Direct edits to this file will be lost!
# Manage your settings on Plinth <https://localhost/plinth/apps/email_server>
# Manage your settings on FreedomBox <https://localhost/plinth/apps/email/>
service auth {
unix_listener /var/spool/postfix/private/auth {

View File

@ -1,5 +1,5 @@
# Direct edits to this file will be lost!
# Manage your settings on Plinth <https://localhost/plinth/apps/email_server>
# Manage your settings on FreedomBox <https://localhost/plinth/apps/email/>
plugin {
sieve_after = /etc/dovecot/freedombox-sieve-after

View File

@ -0,0 +1 @@
#plinth.modules.email

View File

@ -11,7 +11,7 @@
<span class="fa fa-external-link"></span>
</a>
<a class="btn btn-default" role="button"
href="{% url 'email_server:aliases' %}">
href="{% url 'email:aliases' %}">
{% trans "Manage Aliases" %}
</a>
{% endblock %}

View File

@ -0,0 +1,14 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.urls import path
from stronghold.decorators import public
from plinth.utils import non_admin_view
from . import views
urlpatterns = [
path('apps/email/', views.EmailAppView.as_view(), name='index'),
path('apps/email/aliases/', non_admin_view(views.AliasView.as_view()),
name='aliases'),
path('apps/email/config.xml', public(views.XmlView.as_view())),
]

View File

@ -15,11 +15,11 @@ from . import aliases as aliases_module
from . import audit, forms
class EmailServerView(AppView):
"""Server configuration page"""
app_id = 'email_server'
class EmailAppView(AppView):
"""Server configuration page."""
app_id = 'email'
form_class = forms.DomainForm
template_name = 'email_server.html'
template_name = 'email.html'
def get_initial(self):
"""Return the initial values to populate in the form."""
@ -52,9 +52,9 @@ class AliasView(FormView):
posted is detected using hidden form values and the appropriate form is
initialized for the FormView base class to work with.
"""
template_name = 'email_alias.html'
template_name = 'email-aliases.html'
form_classes = (forms.AliasCreateForm, forms.AliasListForm)
success_url = reverse_lazy('email_server:aliases')
success_url = reverse_lazy('email:aliases')
def __init__(self, *args, **kwargs):
"""Initialize the view."""
@ -125,7 +125,7 @@ class AliasView(FormView):
class XmlView(TemplateView):
template_name = 'email_autoconfig.xml'
template_name = 'email-autoconfig.xml'
def render_to_response(self, *args, **kwargs):
kwargs['content_type'] = 'text/xml; charset=utf-8'

View File

@ -1 +0,0 @@
#plinth.modules.email_server

View File

@ -1,14 +0,0 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
from django.urls import path
from stronghold.decorators import public
from plinth.utils import non_admin_view
from . import views
urlpatterns = [
path('apps/email_server/', views.EmailServerView.as_view(), name='index'),
path('apps/email_server/my_aliases',
non_admin_view(views.AliasView.as_view()), name='aliases'),
path('apps/email_server/config.xml', public(views.XmlView.as_view())),
]