From e658bf5b302cd7d0e4b83ef69c56762104e82dd7 Mon Sep 17 00:00:00 2001 From: Peter van Arkel Date: Tue, 24 Nov 2026 12:15:16 +0100 Subject: [PATCH] Explain setup choices and database service failures --- deploy/panel-install.toml.example | 8 ++++ deploy/panel_installer/cli.py | 61 ++++++++++++++++++------ deploy/panel_installer/engine.py | 11 ++++- deploy/panel_installer/guidance.py | 68 ++++++++++++++++++++++++++ deploy/panel_installer/web.py | 76 +++++++++++++++++++++++------- tests/test_panel_installer.py | 60 ++++++++++++++++++++++- 6 files changed, 247 insertions(+), 37 deletions(-) create mode 100644 deploy/panel_installer/guidance.py diff --git a/deploy/panel-install.toml.example b/deploy/panel-install.toml.example index 5f773b8..844b156 100644 --- a/deploy/panel-install.toml.example +++ b/deploy/panel-install.toml.example @@ -31,3 +31,11 @@ mode = "off" # ssh_identity. ssh_identity is a root-owned 0600 file on the panel host. # For remote mail installation, set mail_hostname to the public service # hostname. Provide tls = "acme" or certificate and key paths on that host. + +[hosting] +# Addresses clients use for hosted websites. Used in default A and AAAA records. +# public_addresses = ["192.0.2.21", "2001:db8::21"] +# Authoritative nameservers for new NS records. Set delegation at the registrar. +# nameservers = ["ns1.example.net", "ns2.example.net"] +# Public outbound SMTP addresses, including the NAT address if used. Used for SPF. +# mail_sending_addresses = ["192.0.2.25"] diff --git a/deploy/panel_installer/cli.py b/deploy/panel_installer/cli.py index 1db2c64..35374a2 100644 --- a/deploy/panel_installer/cli.py +++ b/deploy/panel_installer/cli.py @@ -6,6 +6,7 @@ from getpass import getpass from pathlib import Path from tempfile import TemporaryDirectory +from . import guidance from .config import ( REMOTE_MODES, InstallError, @@ -18,7 +19,9 @@ from .config import ( from .engine import Installer -def prompt(label, default=""): +def prompt(label, default="", *, hint=""): + if hint: + print(f" {hint}", flush=True) value = input(f"{label}{f' [{default}]' if default else ''}: ").strip() return value or default @@ -37,7 +40,9 @@ def comma_separated(values): def interactive_plan(previous=None): if previous is None: preset = prompt( - "Installation profile (full-service or custom)", "full-service" + "Installation profile (full-service or custom)", + "full-service", + hint=guidance.PROFILE, ) if preset not in {"full-service", "custom"}: raise InstallError("Choose full-service or custom.") @@ -46,18 +51,25 @@ def interactive_plan(previous=None): preset = "custom" defaults = export_parameters(previous, None) - def ask(label, section, name, fallback=""): + def ask(label, section, name, fallback="", *, hint=""): return prompt( - label, str(defaults.get(section, {}).get(name, fallback)) + label, + str(defaults.get(section, {}).get(name, fallback)), + hint=hint, ) full_service = preset == "full-service" - panel = {"hostname": ask("Panel hostname", "panel", "hostname")} + panel = { + "hostname": ask( + "Panel hostname", "panel", "hostname", hint=guidance.PANEL_HOSTNAME + ) + } access = panel["access"] = ask( "Panel access (tls, acme, or proxy)", "panel", "access", "acme" if full_service else "tls", + hint=guidance.PANEL_ACCESS, ) if access == "tls": panel["certificate"] = ask( @@ -66,9 +78,17 @@ def interactive_plan(previous=None): panel["key"] = ask("Panel private key path", "panel", "key") elif access == "proxy": panel["origin_ip"] = ask( - "Private origin address", "panel", "origin_ip" + "Private origin address", + "panel", + "origin_ip", + hint=guidance.ORIGIN_ADDRESS, + ) + panel["proxy_ip"] = ask( + "Trusted proxy address", + "panel", + "proxy_ip", + hint=guidance.PROXY_ADDRESS, ) - panel["proxy_ip"] = ask("Trusted proxy address", "panel", "proxy_ip") panel["origin_port"] = number( ask("Origin port", "panel", "origin_port", "8080"), "the origin" ) @@ -78,7 +98,12 @@ def interactive_plan(previous=None): "username": ask( "Administrator username", "admin", "username", "operator" ), - "email": ask("Administrator email", "admin", "email"), + "email": ask( + "Administrator email", + "admin", + "email", + hint=guidance.ADMIN_EMAIL, + ), }, } for name in ("dns", "mail"): @@ -87,6 +112,7 @@ def interactive_plan(previous=None): name, "mode", "local" if full_service else "off", + hint=guidance.DNS_ROLE if name == "dns" else guidance.MAIL_ROLE, ) target = data[name] = {"mode": mode} if mode in REMOTE_MODES: @@ -97,14 +123,20 @@ def interactive_plan(previous=None): ask("SSH port", name, "port", "22"), f"the {name} node" ) target["host_key"] = ask( - "Verified SSH host public key file", name, "host_key" + "Verified SSH host public key file", + name, + "host_key", + hint=guidance.SSH_HOST_KEY, ) if mode == "remote-install": target["ssh_user"] = ask( "SSH administrator username", name, "ssh_user" ) target["ssh_identity"] = ask( - "SSH administrator private key file", name, "ssh_identity" + "SSH administrator private key file", + name, + "ssh_identity", + hint=guidance.SSH_IDENTITY, ) if name == "mail" and mode in {"local", "remote-install"}: field = "host" if mode == "local" else "mail_hostname" @@ -113,12 +145,14 @@ def interactive_plan(previous=None): name, field, panel["hostname"] if mode == "local" else "", + hint=guidance.MAIL_HOSTNAME, ) target["tls"] = ask( "Mail TLS (provided or acme)", name, "tls", "acme" if access == "acme" and mode == "local" else "provided", + hint=guidance.MAIL_TLS, ) if target["tls"] == "provided": target["certificate"] = ask( @@ -128,11 +162,7 @@ def interactive_plan(previous=None): "Private key path on the mail host", name, "key" ) hosting = data["hosting"] = {} - for name, label in ( - ("public_addresses", "IP addresses for hosted websites"), - ("nameservers", "Nameservers for new DNS zones"), - ("mail_sending_addresses", "Public sending IPs for hosted email"), - ): + for name, label, hint in guidance.HOSTING_FIELDS: if name == "nameservers" and data["dns"]["mode"] == "off": continue if name == "mail_sending_addresses" and data["mail"]["mode"] not in { @@ -144,6 +174,7 @@ def interactive_plan(previous=None): value = prompt( f"{label} (comma-separated, or none)", ", ".join(previous_values) or "none", + hint=hint, ) hosting[name] = [] if value == "none" else comma_separated(value) return parse_plan(data) diff --git a/deploy/panel_installer/engine.py b/deploy/panel_installer/engine.py index a95b319..b7a95ea 100644 --- a/deploy/panel_installer/engine.py +++ b/deploy/panel_installer/engine.py @@ -485,8 +485,15 @@ class Installer: ("RabbitMQ", "rabbitmq-server.service"), ): with self.step(f"Starting {name} on loopback"): - systemctl("enable", "--now", unit) - systemctl("restart", unit) + try: + systemctl("enable", "--now", unit) + systemctl("restart", unit) + except InstallError: + self.progress( + f"Read the {name} service log with " + f"sudo journalctl -b -u {unit} -n 60 --no-pager" + ) + raise def mariadb(sql): return run( diff --git a/deploy/panel_installer/guidance.py b/deploy/panel_installer/guidance.py new file mode 100644 index 0000000..00cd352 --- /dev/null +++ b/deploy/panel_installer/guidance.py @@ -0,0 +1,68 @@ +"""Help text shared by the interactive installer and browser wizard.""" + +PROFILE = ( + "Full-service preselects local DNS and mail with Let's Encrypt. " + "Custom starts with DNS and mail off." +) +PANEL_HOSTNAME = ( + "The full DNS name administrators and customers use to sign in." +) +PANEL_ACCESS = ( + "Use acme for Let's Encrypt, tls for an existing certificate on this " + "server, or proxy when a trusted reverse proxy handles HTTPS." +) +ORIGIN_ADDRESS = ( + "The private address on this server that the proxy connects to." +) +PROXY_ADDRESS = "The source IP of the trusted proxy as seen by this server." +ADMIN_EMAIL = ( + "Use an inbox you can open now. Coulobre uses this address for notices " + "and Let's Encrypt registration when enabled." +) +DNS_ROLE = ( + "Use local to serve zones here, or off to manage DNS elsewhere. " + "Use remote for an existing Coulobre DNS node or remote-install to " + "set one up over SSH." +) +MAIL_ROLE = ( + "Use local to host mail here, or off to use a separate mail provider. " + "Use remote for an existing Coulobre mail node or remote-install to " + "set one up over SSH." +) +MAIL_HOSTNAME = ( + "The public name mail clients and other mail servers use to reach " + "this mail service." +) +MAIL_TLS = ( + "Use acme for Let's Encrypt or provided for certificate and key files " + "already available on the mail server." +) +SSH_HOST_KEY = "A file with the verified public host key of the remote server." +SSH_IDENTITY = ( + "The private key file on this panel server used to sign in as the " + "SSH administrator." +) + +HOSTING_FIELDS = ( + ( + "public_addresses", + "IP addresses for hosted websites", + "Public IPv4 or IPv6 addresses used in default A and AAAA records. " + "Use the addresses visitors connect to, or leave unset to add them " + "later.", + ), + ( + "nameservers", + "Nameservers for new DNS zones", + "Authoritative nameserver hostnames, such as ns1.example.net. " + "Coulobre uses them in new NS records. Set public delegation " + "separately at the registrar, or leave unset to configure later.", + ), + ( + "mail_sending_addresses", + "Public sending IPs for hosted email", + "The public outbound SMTP addresses, including the NAT address " + "if used. Coulobre uses them to prepare SPF and managed mail DNS. " + "Leave unset to configure those records separately.", + ), +) diff --git a/deploy/panel_installer/web.py b/deploy/panel_installer/web.py index 01078a4..068e30d 100644 --- a/deploy/panel_installer/web.py +++ b/deploy/panel_installer/web.py @@ -9,6 +9,7 @@ from http.server import BaseHTTPRequestHandler, HTTPServer from threading import Thread from urllib.parse import parse_qs +from . import guidance from .cli import comma_separated, number from .config import REMOTE_MODES, InstallError, parse_plan, port from .engine import SOURCE, Installer @@ -21,28 +22,34 @@ FORM = """
websites, databases, DNS and mail run locally. Adjust the settings below for a different deployment.

Panel - - +{hostname_hint} + +{access_hint} - - + +{origin_hint} + +{proxy_hint}
Administrator - + +{email_hint}
{dns}{mail}
New hosting accounts -

Separate multiple values with commas. You can also set these later.

- - - +

Separate multiple values with commas.

+{hosting}
""" STYLE = """:root{color-scheme:light} @@ -51,6 +58,8 @@ h1 img{width:1.9rem;height:1.9rem;flex:none} body{font:1rem system-ui,sans-serif;max-width:46rem;margin:auto; padding:1rem;color:#14372e} fieldset{margin:1rem 0;border:1px solid #a9beb2; border-radius:.4rem;padding:1rem} label{display:block;margin-bottom:.75rem} +label:has(+.field-hint){margin-bottom:.25rem} +.field-hint{display:block;margin-bottom:.75rem;color:#3f5c52} input,select{display:block;box-sizing:border-box;width:100%;padding:.45rem; margin-top:.25rem} button{background:#195a46;color:white;border:0; border-radius:.3rem;padding:.75rem 1.1rem;font:inherit} summary{cursor:pointer} @@ -58,15 +67,26 @@ border-radius:.3rem;padding:.75rem 1.1rem;font:inherit} summary{cursor:pointer} [role=alert]{color:#8c2828}""" +def field_hint(name, message): + return ( + f'{escape(message)}' + ) + + def role_form(name): title = name.upper() if name == "dns" else "Mail" local = ( "' - '" + f"{field_hint('mail_local_host', guidance.MAIL_HOSTNAME)}" + '" + f"{field_hint('mail_tls', guidance.MAIL_TLS)}" "' "