From 11998102579808735255689e3a64b03e8f592c9a Mon Sep 17 00:00:00 2001 From: Peter van Arkel Date: Sun, 22 Nov 2026 22:23:55 +0100 Subject: [PATCH 1/3] Show installation details to server administrators --- src/coulobre/hosting/installation_views.py | 60 +++++++++++++++++++ src/coulobre/hosting/static/hosting/panel.css | 8 +++ .../hosting/templates/hosting/base.html | 10 +++- .../templates/hosting/installation.html | 35 +++++++++++ src/coulobre/hosting/test_service_health.py | 31 ++++++++++ src/coulobre/hosting/urls.py | 2 + 6 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 src/coulobre/hosting/installation_views.py create mode 100644 src/coulobre/hosting/templates/hosting/installation.html diff --git a/src/coulobre/hosting/installation_views.py b/src/coulobre/hosting/installation_views.py new file mode 100644 index 0000000..8c437e1 --- /dev/null +++ b/src/coulobre/hosting/installation_views.py @@ -0,0 +1,60 @@ +from importlib.metadata import PackageNotFoundError, version + +from django.conf import settings +from django.contrib.auth.mixins import PermissionRequiredMixin +from django.utils.decorators import method_decorator +from django.views.decorators.cache import never_cache +from django.views.generic import TemplateView + +from .access import OperatorOnlyMixin + + +@method_decorator(never_cache, name="dispatch") +class InstallationView( + OperatorOnlyMixin, PermissionRequiredMixin, TemplateView +): + permission_required = "hosting.view_servicehealth" + template_name = "hosting/installation.html" + + def get_context_data(self, **kwargs): + try: + installed_version = version("coulobre-panel") + except PackageNotFoundError: + installed_version = "Unavailable" + + features = ( + ("Local website provisioning", settings.LOCAL_WEB_ACTIVATION), + ("Managed website certificates", settings.LOCAL_WEB_HTTPS), + ("Website file manager", settings.WEB_FILE_MANAGER), + ("Website scheduled tasks", settings.WEBSITE_JOBS), + ("Local DNS publishing", settings.LOCAL_DNS_PUBLISHING), + ( + "Default managed DNS zones for new accounts", + settings.LOCAL_DNS_PUBLISHING + and settings.HOSTING_NAMESERVERS + and settings.HOSTING_PUBLIC_ADDRESSES, + ), + ( + "Local mailbox provisioning", + settings.LOCAL_MAILBOX_PROVISIONING, + ), + ("Managed mail DNS records", settings.MANAGE_MAIL_DNS), + ( + "Local database provisioning", + settings.LOCAL_DATABASE_PROVISIONING, + ), + ("Local account backups", settings.LOCAL_ACCOUNT_BACKUPS), + ( + "Off-site backup destinations", + settings.OFFSITE_BACKUP_DESTINATIONS, + ), + ("phpMyAdmin sign-in", settings.PHPMYADMIN_URL), + ("Roundcube sign-in", settings.ROUNDCUBE_URL), + ) + return super().get_context_data( + installed_version=installed_version, + features=[ + (name, bool(configured)) for name, configured in features + ], + **kwargs, + ) diff --git a/src/coulobre/hosting/static/hosting/panel.css b/src/coulobre/hosting/static/hosting/panel.css index 87ecf81..2bb54df 100644 --- a/src/coulobre/hosting/static/hosting/panel.css +++ b/src/coulobre/hosting/static/hosting/panel.css @@ -273,6 +273,14 @@ button, input, select, textarea { linear-gradient(currentColor, currentColor) 75% bottom / 1px 55% no-repeat; } +.nav-icon-information { + display: grid; + place-content: center; + border-radius: 50%; + font-size: 0.7rem; + font-weight: 700; +} + .nav-icon-customers { position: relative; height: 0.46rem; diff --git a/src/coulobre/hosting/templates/hosting/base.html b/src/coulobre/hosting/templates/hosting/base.html index 57a9644..31170d0 100644 --- a/src/coulobre/hosting/templates/hosting/base.html +++ b/src/coulobre/hosting/templates/hosting/base.html @@ -52,8 +52,8 @@ {% endif %} {% if group_customer_navigation %}{% endif %} - {% if is_operator and perms.hosting.view_webprovisioningplan and perms.hosting.view_servicehealth %} - {% endif %} {% endwith %} {% empty %} -

No services are configured for health checks.

+
+

Set COULOBRE_SERVICE_HEALTH in /etc/coulobre/panel.env and enable coulobre-health.timer to collect service observations.

+
{% endfor %} {% endblock %} diff --git a/src/coulobre/service_health.py b/src/coulobre/service_health.py index fc934f4..c5d1976 100644 --- a/src/coulobre/service_health.py +++ b/src/coulobre/service_health.py @@ -29,6 +29,8 @@ SERVICES = { "bind9": ("BIND9", "named.service"), "postfix": ("Postfix", "postfix.service"), "dovecot": ("Dovecot", "dovecot.service"), + "rspamd": ("Rspamd", "rspamd.service"), + "redis": ("Redis", "redis-server.service"), "spamd": ("SpamAssassin", "spamd.service"), "spamass-milter": ("SpamAssassin milter", "spamass-milter.service"), "firewall": ("Coulobre firewall", "coulobre-firewall.service"), @@ -38,6 +40,8 @@ REMOTE_SERVICES = ( "bind9", "postfix", "dovecot", + "rspamd", + "redis", "spamd", "spamass-milter", "firewall", diff --git a/tests/test_panel_installer.py b/tests/test_panel_installer.py index 2501a1f..8be1843 100644 --- a/tests/test_panel_installer.py +++ b/tests/test_panel_installer.py @@ -1,3 +1,4 @@ +import json import stat import tempfile import unittest @@ -12,6 +13,7 @@ from deploy.panel_installer.config import ( read_password, read_plan, ) +from deploy.panel_installer.engine import Installer from deploy.panel_installer.web import Wizard, WizardHandler, form_plan PROXY = { @@ -24,6 +26,53 @@ ADMIN = {"username": "operator", "email": "ops@example.net"} class InstallerParametersTests(unittest.TestCase): + def test_default_health_targets_follow_locally_installed_roles(self): + cases = ( + ({}, None, []), + ( + { + "dns": {"mode": "local"}, + "mail": { + "mode": "local", + "host": "panel.example.net", + "tls": "acme", + }, + }, + "8.5", + ["php-fpm", "bind9", "postfix", "dovecot", "rspamd", "redis"], + ), + ) + for roles, php, extras in cases: + with ( + self.subTest(roles=roles), + patch( + "deploy.panel_installer.engine.platform_settings", + return_value=(php, True), + ), + ): + plan = parse_plan({"panel": PROXY, "admin": ADMIN, **roles}) + installer = Installer(plan, "test-only", Mock()) + installer.state = dict.fromkeys( + ("secret_key", "database_password", "broker_password"), + "test-only", + ) + env = dict( + line.split("=", 1) + for line in installer.environment().splitlines() + ) + base = [ + "panel", + "worker", + "scheduler", + "apache", + "mariadb", + "rabbitmq", + ] + self.assertEqual( + json.loads(env["COULOBRE_SERVICE_HEALTH"]), + {"panel": {"local": base + extras}}, + ) + def test_interactive_export_reuses_the_same_plan(self): plan = parse_plan( { -- 2.43.0