mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
email: Manage known installation conflicts
Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com> [sunil: Don't show warning on conflict] [sunil: Add statement to description about conflicts] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
4b2162f3fd
commit
376fe5a85b
@ -15,14 +15,26 @@ from plinth.modules.apache.components import Webserver
|
|||||||
from plinth.modules.config import get_domainname
|
from plinth.modules.config import get_domainname
|
||||||
from plinth.modules.firewall.components import Firewall
|
from plinth.modules.firewall.components import Firewall
|
||||||
from plinth.modules.letsencrypt.components import LetsEncrypt
|
from plinth.modules.letsencrypt.components import LetsEncrypt
|
||||||
|
from plinth.package import packages_installed, remove
|
||||||
|
|
||||||
from . import audit, manifest
|
from . import audit, manifest
|
||||||
|
|
||||||
version = 1
|
version = 1
|
||||||
|
|
||||||
|
# Other likely install conflicts have been discarded:
|
||||||
|
# - msmtp, nullmailer, sendmail don't cause install faults.
|
||||||
|
# - qmail and smail are missing in Bullseye (Not tested,
|
||||||
|
# but less likely due to that).
|
||||||
|
package_conflicts = ('exim4-base', 'exim4-config', 'exim4-daemon-light')
|
||||||
|
package_conflicts_action = 'ignore'
|
||||||
|
|
||||||
packages = [
|
packages = [
|
||||||
'postfix-ldap', 'dovecot-pop3d', 'dovecot-imapd',
|
'postfix-ldap',
|
||||||
'dovecot-ldap', 'dovecot-lmtpd', 'dovecot-managesieved',
|
'dovecot-pop3d',
|
||||||
|
'dovecot-imapd',
|
||||||
|
'dovecot-ldap',
|
||||||
|
'dovecot-lmtpd',
|
||||||
|
'dovecot-managesieved',
|
||||||
]
|
]
|
||||||
|
|
||||||
packages_bloat = ['rspamd']
|
packages_bloat = ['rspamd']
|
||||||
@ -38,6 +50,12 @@ port_info = {
|
|||||||
managed_services = ['postfix', 'dovecot', 'rspamd']
|
managed_services = ['postfix', 'dovecot', 'rspamd']
|
||||||
|
|
||||||
managed_packages = packages + packages_bloat
|
managed_packages = packages + packages_bloat
|
||||||
|
|
||||||
|
_description = [
|
||||||
|
_('During installation, any other email servers in the system will be '
|
||||||
|
'uninstalled.')
|
||||||
|
]
|
||||||
|
|
||||||
app = None
|
app = None
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -55,18 +73,19 @@ class EmailServerApp(plinth.app.App):
|
|||||||
self._add_firewall_ports()
|
self._add_firewall_ports()
|
||||||
|
|
||||||
# /rspamd location
|
# /rspamd location
|
||||||
webserver = Webserver('webserver-email', # unique id
|
webserver = Webserver(
|
||||||
'email-server-freedombox', # config file name
|
'webserver-email', # unique id
|
||||||
urls=['https://{host}/rspamd'])
|
'email-server-freedombox', # config file name
|
||||||
|
urls=['https://{host}/rspamd'])
|
||||||
self.add(webserver)
|
self.add(webserver)
|
||||||
|
|
||||||
# Let's Encrypt event hook
|
# Let's Encrypt event hook
|
||||||
default_domain = get_domainname()
|
default_domain = get_domainname()
|
||||||
domains = [default_domain] if default_domain else []
|
domains = [default_domain] if default_domain else []
|
||||||
letsencrypt = LetsEncrypt(
|
letsencrypt = LetsEncrypt('letsencrypt-email-server', domains=domains,
|
||||||
'letsencrypt-email-server', domains=domains,
|
daemons=['postfix', 'dovecot'],
|
||||||
daemons=['postfix', 'dovecot'], should_copy_certificates=False,
|
should_copy_certificates=False,
|
||||||
managing_app='email_server')
|
managing_app='email_server')
|
||||||
self.add(letsencrypt)
|
self.add(letsencrypt)
|
||||||
|
|
||||||
if not domains:
|
if not domains:
|
||||||
@ -74,14 +93,11 @@ class EmailServerApp(plinth.app.App):
|
|||||||
|
|
||||||
def _add_ui_components(self):
|
def _add_ui_components(self):
|
||||||
info = plinth.app.Info(
|
info = plinth.app.Info(
|
||||||
app_id=self.app_id,
|
app_id=self.app_id, version=version, name=self.app_name,
|
||||||
version=version,
|
|
||||||
name=self.app_name,
|
|
||||||
short_description=_('Powered by Postfix, Dovecot & Rspamd'),
|
short_description=_('Powered by Postfix, Dovecot & Rspamd'),
|
||||||
manual_page='EmailServer',
|
description=_description, manual_page='EmailServer',
|
||||||
clients=manifest.clients,
|
clients=manifest.clients,
|
||||||
donation_url='https://freedomboxfoundation.org/donate/'
|
donation_url='https://freedomboxfoundation.org/donate/')
|
||||||
)
|
|
||||||
self.add(info)
|
self.add(info)
|
||||||
|
|
||||||
menu_item = plinth.menu.Menu(
|
menu_item = plinth.menu.Menu(
|
||||||
@ -90,19 +106,14 @@ class EmailServerApp(plinth.app.App):
|
|||||||
info.short_description, # app description
|
info.short_description, # app description
|
||||||
'roundcube', # icon name in `static/theme/icons/`
|
'roundcube', # icon name in `static/theme/icons/`
|
||||||
'email_server:index', # view name
|
'email_server:index', # view name
|
||||||
parent_url_name='apps'
|
parent_url_name='apps')
|
||||||
)
|
|
||||||
self.add(menu_item)
|
self.add(menu_item)
|
||||||
|
|
||||||
shortcut = plinth.frontpage.Shortcut(
|
shortcut = plinth.frontpage.Shortcut(
|
||||||
'shortcut_' + self.app_id,
|
'shortcut_' + self.app_id, name=info.name,
|
||||||
name=info.name,
|
short_description=info.short_description, icon='roundcube',
|
||||||
short_description=info.short_description,
|
url=reverse_lazy('email_server:my_mail'), clients=manifest.clients,
|
||||||
icon='roundcube',
|
login_required=True)
|
||||||
url=reverse_lazy('email_server:my_mail'),
|
|
||||||
clients=manifest.clients,
|
|
||||||
login_required=True
|
|
||||||
)
|
|
||||||
self.add(shortcut)
|
self.add(shortcut)
|
||||||
|
|
||||||
def _add_daemons(self):
|
def _add_daemons(self):
|
||||||
@ -142,14 +153,29 @@ class EmailServerApp(plinth.app.App):
|
|||||||
|
|
||||||
def setup(helper, old_version=None):
|
def setup(helper, old_version=None):
|
||||||
"""Installs and configures module"""
|
"""Installs and configures module"""
|
||||||
|
|
||||||
|
def _clear_conflicts():
|
||||||
|
packages_to_remove = packages_installed(package_conflicts)
|
||||||
|
if packages_to_remove:
|
||||||
|
logger.info('Removing conflicting packages: %s',
|
||||||
|
packages_to_remove)
|
||||||
|
remove(packages_to_remove)
|
||||||
|
|
||||||
|
# Install
|
||||||
|
helper.call('pre', _clear_conflicts)
|
||||||
helper.install(packages)
|
helper.install(packages)
|
||||||
helper.install(packages_bloat, skip_recommends=True)
|
helper.install(packages_bloat, skip_recommends=True)
|
||||||
|
|
||||||
|
# Setup
|
||||||
helper.call('post', audit.domain.repair)
|
helper.call('post', audit.domain.repair)
|
||||||
helper.call('post', audit.ldap.repair)
|
helper.call('post', audit.ldap.repair)
|
||||||
helper.call('post', audit.spam.repair)
|
helper.call('post', audit.spam.repair)
|
||||||
helper.call('post', audit.tls.repair)
|
helper.call('post', audit.tls.repair)
|
||||||
helper.call('post', audit.rcube.repair)
|
helper.call('post', audit.rcube.repair)
|
||||||
|
|
||||||
|
# Reload
|
||||||
for srvname in managed_services:
|
for srvname in managed_services:
|
||||||
actions.superuser_run('service', ['reload', srvname])
|
actions.superuser_run('service', ['reload', srvname])
|
||||||
# Final step: expose service daemons to public internet
|
|
||||||
|
# Expose to public internet
|
||||||
helper.call('post', app.enable)
|
helper.call('post', app.enable)
|
||||||
|
|||||||
@ -121,6 +121,7 @@ class EmailServerView(TabMixin, AppView):
|
|||||||
return redirect(request.path)
|
return redirect(request.path)
|
||||||
|
|
||||||
def _repair(self, module_name, action_name):
|
def _repair(self, module_name, action_name):
|
||||||
|
"""Repair the configuration of the given audit module."""
|
||||||
module = getattr(audit, module_name)
|
module = getattr(audit, module_name)
|
||||||
if not hasattr(module, 'repair_component'):
|
if not hasattr(module, 'repair_component'):
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user