Compare commits

...
5 Commits
Author SHA1 Message Date
parkel 970243c324 Merge pull request 'Prepare Coulobre Core 1.10.0 and refine panel workflows' (#318) from feature/panel-usability-1100 into main
Coulobre Panel CI / Checks (Python 3.12) (push) Successful in 2m11s
Coulobre Panel CI / Checks (Python 3.14) (push) Successful in 2m28s
Publish release to APT / publish (release) Successful in 4s
Reviewed-on: #318
2026-12-04 16:34:52 +01:00
parkel b6efae0cd8 Prepare Coulobre Core 1.10.0
Coulobre Panel CI / Checks (Python 3.12) (pull_request) Successful in 2m3s
Coulobre Panel CI / Checks (Python 3.14) (pull_request) Successful in 2m42s
2026-12-04 16:31:35 +01:00
parkel 528d62944e Unify panel feedback and polish hosting workflows 2026-12-04 16:31:35 +01:00
parkel ccf7c544ea Provide private import storage on APT upgrades 2026-12-04 16:31:35 +01:00
parkel 880b62e3d8 Allow DirectAdmin restore over an untouched starter page 2026-12-04 16:31:35 +01:00
46 changed files with 508 additions and 105 deletions

No files matched your search

@@ -9,7 +9,8 @@ Type=exec
User=coulobre-panel User=coulobre-panel
Group=coulobre-panel Group=coulobre-panel
SupplementaryGroups=coulobre-mail-provisioning SupplementaryGroups=coulobre-mail-provisioning
ReadWritePaths=-/var/lib/coulobre-panel-imports StateDirectory=coulobre-panel-imports
StateDirectoryMode=0700
EnvironmentFile=/etc/coulobre/panel.env EnvironmentFile=/etc/coulobre/panel.env
WorkingDirectory=/opt/coulobre WorkingDirectory=/opt/coulobre
UMask=0077 UMask=0077
@@ -0,0 +1,3 @@
[Service]
StateDirectory=coulobre-panel-imports
StateDirectoryMode=0700
+5 -3
View File
@@ -1534,9 +1534,11 @@ not modify or promote the live site.
### Import WordPress from a ZIP or TAR export ### Import WordPress from a ZIP or TAR export
New installer-managed panels already have a private WordPress upload inbox. New installer-managed panels have a private upload inbox for WordPress and
APT and web upgrades preserve the installed panel unit. If you are enabling DirectAdmin imports. Starting with Core 1.10, APT upgrades supply the inbox
imports on an upgraded panel and the unit does not list through a systemd drop-in without replacing local unit overrides. For a
manual or source archive upgrade, or if you override the inbox locally,
check the effective unit. If it does not list
`coulobre-panel-imports` in `systemctl show -p StateDirectory `coulobre-panel-imports` in `systemctl show -p StateDirectory
coulobre-panel.service`, add the inbox with `sudo systemctl edit coulobre-panel.service`, add the inbox with `sudo systemctl edit
coulobre-panel.service`: coulobre-panel.service`:
+5 -3
View File
@@ -736,9 +736,11 @@ domain has only one web root, Coulobre uses it. You can restore all supported
components or only what you need. Select a package with enough website components or only what you need. Select a package with enough website
slots when restoring more than one site. slots when restoring more than one site.
The destination can be a new hosting account or an existing empty account The destination can be a new hosting account or an existing empty account
whose primary domain exactly matches. Remove any existing starter page whose primary domain exactly matches. A document root containing only an
before restoring website files. Existing DNS can be left in place if you unchanged Coulobre starter page counts as empty. A modified starter page
do not select DNS import. New accounts do not include a new customer login. or any other file blocks the website restore. Existing DNS can be left in
place if you do not select DNS import. New accounts do not include a new
customer login.
Open the destination account after import to attach a customer or manager. Open the destination account after import to attach a customer or manager.
The selected component types apply to supported content across the selected The selected component types apply to supported content across the selected
+24 -1
View File
@@ -93,7 +93,9 @@ heading, help, fields, and actions should share a left edge.
workflow. Keep the final destructive confirmation visually distinct. workflow. Keep the final destructive confirmation visually distinct.
- Keep a record name and its secondary identifier in one table cell. Use a - Keep a record name and its secondary identifier in one table cell. Use a
wrapping row when space permits, and omit the identifier when it repeats wrapping row when space permits, and omit the identifier when it repeats
the name. The record name remains the link. the name. The record name remains the link. The local and cluster
hosting inventories use a separate, right-aligned **Primary domain**
column immediately before **Status** for easy comparison.
- Group table actions in a wrapping `.table-actions` container. Center - Group table actions in a wrapping `.table-actions` container. Center
them vertically within the row and allow labels to wrap instead of them vertically within the row and allow labels to wrap instead of
widening the whole table. Keep overflow within `.table-scroll`. widening the whole table. Keep overflow within `.table-scroll`.
@@ -135,6 +137,21 @@ Django's label association, error state, and description IDs.
<label><input type="checkbox" name="confirm" required> Confirm this change</label> <label><input type="checkbox" name="confirm" required> Confirm this change</label>
``` ```
### Action feedback
Use Django messages for the immediate outcome of signed-in actions.
The shared shell displays them as dismissible notifications with JavaScript
and in the page flow without it. Distinguish **queued** from **complete**.
Keep validation next to the relevant field and show a clear summary near
the start of long forms. Don't make notifications the only place to find
errors, progress, or recovery instructions.
Live regions may opt in to a notification on a meaningful state transition
using `data-live-state`, `data-live-notice` and an optional
`data-live-notice-level`. Notify only once for a transition, not for each
poll. Keep server or cluster announcements and impersonation indicators
in the page.
### Dependent operations ### Dependent operations
Show a blocked prerequisite beside the resource that needs it. Put the Show a blocked prerequisite beside the resource that needs it. Put the
@@ -148,6 +165,12 @@ the source and destination, show the snapshot totals first, and put the
per-folder or per-item breakdown below. Label partial counts and missing per-folder or per-item breakdown below. Label partial counts and missing
estimates explicitly. Distinguish the full source inventory from work estimates explicitly. Distinguish the full source inventory from work
remaining after a checkpoint. Do not display credentials or source content. remaining after a checkpoint. Do not display credentials or source content.
Distinguish a matching existing account from a requested new account by
name and domain. Show new-account settings only for that choice when
JavaScript is available, and validate both paths on the server. Keep
the selected destination visible while a job is queued. Results separate
completed, unconfirmed, and unrequested work, with links to review or finish
setup.
For selective imports, put editable choices below the inventory and keep For selective imports, put editable choices below the inventory and keep
them outside auto-refreshing status regions. State explicitly which choices them outside auto-refreshing status regions. State explicitly which choices
affect the destination, which are skipped and whether failures can leave affect the destination, which are skipped and whether failures can leave
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "coulobre-panel" name = "coulobre-panel"
version = "1.9.0" version = "1.10.0"
description = "A web hosting control panel for hosting providers and resellers." description = "A web hosting control panel for hosting providers and resellers."
readme = "README.md" readme = "README.md"
requires-python = ">=3.12" requires-python = ">=3.12"
+18 -3
View File
@@ -1,7 +1,9 @@
"""Stage and inspect DirectAdmin archives for operator approval.""" """Stage and inspect DirectAdmin archives for operator approval."""
import errno
import fcntl import fcntl
import hashlib import hashlib
import logging
import os import os
import stat import stat
from datetime import timedelta from datetime import timedelta
@@ -146,9 +148,19 @@ def register_upload(upload, actor):
except Exception: except Exception:
path.unlink(missing_ok=True) path.unlink(missing_ok=True)
raise raise
except OSError: except OSError as error:
logging.getLogger(__name__).warning(
"DirectAdmin archive staging failed (errno %s).", error.errno
)
if error.errno in {errno.ENOSPC, errno.EDQUOT}:
detail = "Free space in the panel's import storage and try again."
else:
detail = (
"Check the panel service's private import storage. "
"Inspect its StateDirectory and journal before retrying."
)
raise ValidationError( raise ValidationError(
"Could not stage the archive. Check server storage." f"Could not stage the archive. {detail}"
) from None ) from None
return job return job
@@ -540,7 +552,10 @@ def confirm_import(job_id, actor, selection):
validate_extra_domains(selection, account, job.report) validate_extra_domains(selection, account, job.report)
plan = plan_for_import(account, selection) plan = plan_for_import(account, selection)
validate_quotas(job.report, account, selection, plan) validate_quotas(job.report, account, selection, plan)
job.selection = selection | {"account_id": getattr(account, "pk", None)} job.selection = selection | {
"account_id": getattr(account, "pk", None),
"destination_name": account.name if account else selection["name"],
}
job.state = "import_queued" job.state = "import_queued"
job.confirmed_by = actor job.confirmed_by = actor
job.started_at = None job.started_at = None
@@ -271,13 +271,20 @@ def restore_components(job):
f"{item['label']} is no longer provisioned." f"{item['label']} is no longer provisioned."
) )
if item["kind"] != "mail" or item["messages"]: if item["kind"] != "mail" or item["messages"]:
restore_directadmin_component( receipt = restore_directadmin_component(
item["kind"], item["kind"],
destination_spec(job, item), destination_spec(job, item),
archive_path(job.pk), archive_path(job.pk),
source=item.get("source", ""), source=item.get("source", ""),
digest=job.digest, digest=job.digest,
) )
if isinstance(receipt, dict):
item["receipt"] = {
field: receipt[field]
for field in ("files", "bytes", "messages")
if type(receipt.get(field)) is int
and receipt[field] >= 0
}
item["status"] = ( item["status"] = (
"Mailbox configured (no source messages)" "Mailbox configured (no source messages)"
if item["kind"] == "mail" and not item["messages"] if item["kind"] == "mail" and not item["messages"]
@@ -1,4 +1,5 @@
from django import forms from django import forms
from django.contrib import messages
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.shortcuts import get_object_or_404, redirect, render from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone from django.utils import timezone
@@ -37,6 +38,8 @@ class DirectAdminSelectionForm(forms.Form):
) )
target = forms.ChoiceField( target = forms.ChoiceField(
label="Destination", label="Destination",
widget=forms.RadioSelect,
initial="new",
choices=( choices=(
("new", "Create a hosting account"), ("new", "Create a hosting account"),
("existing", "Use the matching empty hosting account"), ("existing", "Use the matching empty hosting account"),
@@ -78,6 +81,13 @@ class DirectAdminSelectionForm(forms.Form):
def __init__(self, report, *args, **kwargs): def __init__(self, report, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.report = report self.report = report
if (
self.is_bound
and self.data.get(self.add_prefix("target")) == "existing"
):
self.data = self.data.copy()
for field in ("hosting_plan", "name"):
self.data.pop(self.add_prefix(field), None)
choices = [ choices = [
(entry["name"], entry["name"]) for entry in report["domains"] (entry["name"], entry["name"]) for entry in report["domains"]
] ]
@@ -131,7 +141,11 @@ class DirectAdminImportView(OperatorOnlyMixin, OperatorAuthorization, View):
except ValidationError as error: except ValidationError as error:
form.add_error("archive", error) form.add_error("archive", error)
else: else:
messages.success(request, "DirectAdmin preflight queued.")
return redirect("panel:directadmin_import", pk=job.pk) return redirect("panel:directadmin_import", pk=job.pk)
messages.error(
request, "Preflight not queued. Check the upload below."
)
return self.page(form=form, status=400) return self.page(form=form, status=400)
job = get_object_or_404(DirectAdminWebImport, pk=pk) job = get_object_or_404(DirectAdminWebImport, pk=pk)
@@ -146,6 +160,7 @@ class DirectAdminImportView(OperatorOnlyMixin, OperatorAuthorization, View):
report={}, report={},
): ):
archive_path(pk).unlink(missing_ok=True) archive_path(pk).unlink(missing_ok=True)
messages.info(request, "DirectAdmin upload discarded.")
return redirect("panel:directadmin_import", pk=pk) return redirect("panel:directadmin_import", pk=pk)
form = DirectAdminSelectionForm(job.report, request.POST) form = DirectAdminSelectionForm(job.report, request.POST)
if form.is_valid(): if form.is_valid():
@@ -154,7 +169,11 @@ class DirectAdminImportView(OperatorOnlyMixin, OperatorAuthorization, View):
except ValidationError as error: except ValidationError as error:
form.add_error(None, error) form.add_error(None, error)
else: else:
messages.success(request, "DirectAdmin import queued.")
return redirect("panel:directadmin_import", pk=pk) return redirect("panel:directadmin_import", pk=pk)
messages.error(
request, "Import not queued. Review the highlighted details."
)
return self.page(job, form, status=400) return self.page(job, form, status=400)
def page(self, job=None, form=None, status=200): def page(self, job=None, form=None, status=200):
@@ -163,12 +182,24 @@ class DirectAdminImportView(OperatorOnlyMixin, OperatorAuthorization, View):
form = DirectAdminArchiveForm() form = DirectAdminArchiveForm()
elif job.state == "review" and job.expires_at > timezone.now(): elif job.state == "review" and job.expires_at > timezone.now():
form = DirectAdminSelectionForm(job.report) form = DirectAdminSelectionForm(job.report)
components = set(job.selection.get("components", ())) if job else set()
choices = DirectAdminSelectionForm.base_fields["components"].choices
return render( return render(
self.request, self.request,
self.template_name, self.template_name,
{ {
"job": job, "job": job,
"form": form, "form": form,
"not_started": [
label for key, label in choices if key in components
]
if job and job.finished_at and not job.work
else (),
"not_selected": [
label
for key, label in choices
if components and key not in components
],
"pending": job is not None and job.state in ACTIVE_STATES, "pending": job is not None and job.state in ACTIVE_STATES,
"recent": DirectAdminWebImport.objects.select_related( "recent": DirectAdminWebImport.objects.select_related(
"account" "account"
@@ -0,0 +1,22 @@
"use strict";
const importForm = document.querySelector("[data-directadmin-review]");
if (importForm) {
const domain = importForm.elements.domain;
const destination = importForm.elements.target;
const newFields = importForm.querySelector("[data-import-new]");
const matches = [...importForm.querySelectorAll("[data-import-match]")];
function updateDestination() {
const existing = destination.value === "existing";
newFields.hidden = existing;
newFields.disabled = existing;
for (const match of matches) {
match.hidden = !existing || match.dataset.importMatch !== domain.value;
}
}
importForm.addEventListener("change", updateDestination);
updateDestination();
}
@@ -43,6 +43,18 @@ async function refreshStatus() {
for (const detail of next.querySelectorAll("details[data-live-detail]")) { for (const detail of next.querySelectorAll("details[data-live-detail]")) {
detail.open = openDetails.has(detail.dataset.liveDetail); detail.open = openDetails.has(detail.dataset.liveDetail);
} }
const stateChanged = region.dataset.liveState !== next.dataset.liveState;
if (next.dataset.liveState) {
region.dataset.liveState = next.dataset.liveState;
}
if (stateChanged && next.dataset.liveNotice) {
document.dispatchEvent(new CustomEvent("coulobre:status-changed", {
detail: {
message: next.dataset.liveNotice,
level: next.dataset.liveNoticeLevel || "info",
},
}));
}
if (region.innerHTML === next.innerHTML) { if (region.innerHTML === next.innerHTML) {
continue; continue;
} }
@@ -0,0 +1,37 @@
"use strict";
const notificationStack = document.querySelector("[data-panel-notifications]");
if (notificationStack) {
notificationStack.classList.add("panel-notifications-floating");
function enhanceNotification(notice) {
const dismiss = document.createElement("button");
dismiss.type = "button";
dismiss.className = "button secondary compact";
dismiss.textContent = "Dismiss";
dismiss.setAttribute("aria-label", "Dismiss notification");
dismiss.addEventListener("click", () => {
const next = notice.nextElementSibling || notice.previousElementSibling;
notice.remove();
(next?.querySelector("button") || document.getElementById("main-content")).focus();
});
notice.append(dismiss);
}
notificationStack.querySelectorAll(".panel-notification").forEach(enhanceNotification);
document.addEventListener("coulobre:status-changed", event => {
const {message, level} = event.detail;
const notice = document.createElement("div");
notice.className = "notice panel-notification";
notice.dataset.notificationLevel = level;
const content = document.createElement("p");
content.setAttribute("role", level === "error" ? "alert" : "status");
notice.append(content);
enhanceNotification(notice);
notificationStack.append(notice);
// Add the text after the live region is mounted.
requestAnimationFrame(() => { content.textContent = message; });
});
}
+53 -8
View File
@@ -719,16 +719,13 @@ h3, h4, h5, h6 {
flex: 1 1 25rem; flex: 1 1 25rem;
} }
.account-identity { .account-identity, .cell-primary-domain {
display: flex; overflow-wrap: anywhere;
flex-wrap: wrap;
align-items: baseline;
gap: 0.15rem 0.65rem;
} }
.account-identity > * { th.cell-primary-domain, td.cell-primary-domain {
min-width: 0; text-align: end;
overflow-wrap: anywhere; width: 22%;
} }
.account-heading-meta { .account-heading-meta {
@@ -838,6 +835,7 @@ input::placeholder {
} }
.table-scroll { .table-scroll {
position: relative;
overflow-x: auto; overflow-x: auto;
} }
@@ -1595,3 +1593,50 @@ fieldset > div:has(> div > label > input:is([type="checkbox"], [type="radio"]))
min-inline-size: 0; min-inline-size: 0;
grid-template-rows: auto auto 1fr auto; grid-template-rows: auto auto 1fr auto;
} }
.panel-notifications:not(:has(.panel-notification)) {
display: none;
}
.panel-notifications-floating {
position: fixed;
inset-block-start: 1rem;
inset-inline-end: 1rem;
width: min(27rem, calc(100vw - 2rem));
max-height: 45vh;
overflow: auto;
z-index: 20;
display: grid;
gap: 0.45rem;
}
.panel-notification {
display: flex;
align-items: start;
justify-content: space-between;
gap: 0.75rem;
overflow-wrap: anywhere;
}
.panel-notifications-floating .panel-notification {
margin: 0;
border-radius: 0.4rem;
padding: 0.65rem 0.8rem;
}
.panel-notification p {
margin: 0;
}
.panel-notification[data-notification-level="error"] {
border-color: var(--invalid);
background-color: var(--error-bg);
}
.panel-notification[data-notification-level="warning"] {
background-color: var(--warning-bg);
}
[data-import-new][hidden] {
display: none;
}
@@ -35,7 +35,7 @@
</form> </form>
{% endif %} {% endif %}
</header> </header>
<div class="form-actions"> <div class="form-actions section-text">
<a class="button secondary" href="{% url 'panel:account_backup_archives' account.pk %}">Backup archives</a> <a class="button secondary" href="{% url 'panel:account_backup_archives' account.pk %}">Backup archives</a>
{% if edit_account_backup_schedule %} {% if edit_account_backup_schedule %}
<a class="button secondary" href="{% url 'panel:account_backup_schedule' account.pk %}">{% if account_backup_schedule %}Edit backup schedule{% else %}Schedule backups{% endif %}</a> <a class="button secondary" href="{% url 'panel:account_backup_schedule' account.pk %}">{% if account_backup_schedule %}Edit backup schedule{% else %}Schedule backups{% endif %}</a>
@@ -1,4 +1 @@
<div class="account-identity"> <div class="account-identity"><a class="record-link" href="{{ account_url }}">{{ name }}</a></div>
<a class="record-link" href="{{ account_url }}">{{ name }}</a>
{% if primary_domain|lower != name|lower %}<span class="domain muted">{{ primary_domain }}</span>{% endif %}
</div>
@@ -43,7 +43,7 @@
<tr> <tr>
<th scope="col">Account</th> <th scope="col">Account</th>
{% if local_hosting_node %}<th scope="col">Hosting node</th>{% endif %} {% if local_hosting_node %}<th scope="col">Hosting node</th>{% endif %}
<th scope="col">Status</th> <th class="cell-primary-domain" scope="col">Primary domain</th><th scope="col">Status</th>
{% if is_operator and perms.hosting.view_customer %}<th scope="col">Customer</th>{% endif %} {% if is_operator and perms.hosting.view_customer %}<th scope="col">Customer</th>{% endif %}
{% if is_tenant or perms.hosting.view_hostingplan %}<th scope="col">Hosting package</th>{% endif %} {% if is_tenant or perms.hosting.view_hostingplan %}<th scope="col">Hosting package</th>{% endif %}
<th scope="col" class="cell-date">Added</th> <th scope="col" class="cell-date">Added</th>
@@ -53,7 +53,7 @@
{% for account in accounts %} {% for account in accounts %}
<tr> <tr>
<td> <td>
{% include "hosting/account_identity.html" with account_url=account.get_absolute_url name=account.name primary_domain=account.primary_domain only %} {% include "hosting/account_identity.html" with account_url=account.get_absolute_url name=account.name only %}
{% if is_customer %} {% if is_customer %}
<div class="table-actions"> <div class="table-actions">
{% if show_customer_website_link %}<a href="{{ account.get_absolute_url }}#websites">Websites</a>{% endif %} {% if show_customer_website_link %}<a href="{{ account.get_absolute_url }}#websites">Websites</a>{% endif %}
@@ -63,6 +63,7 @@
{% endif %} {% endif %}
</td> </td>
{% if local_hosting_node %}<td>{% include "hosting/hosting_node.html" with node=local_hosting_node only %}</td>{% endif %} {% if local_hosting_node %}<td>{% include "hosting/hosting_node.html" with node=local_hosting_node only %}</td>{% endif %}
{% include "hosting/account_primary_domain.html" with name=account.name primary_domain=account.primary_domain only %}
<td>{% include "hosting/account_status.html" %}</td> <td>{% include "hosting/account_status.html" %}</td>
{% if is_operator and perms.hosting.view_customer %}<td>{{ account.customer|default_if_none:"No customer linked" }}</td>{% endif %} {% if is_operator and perms.hosting.view_customer %}<td>{{ account.customer|default_if_none:"No customer linked" }}</td>{% endif %}
{% if is_tenant or perms.hosting.view_hostingplan %} {% if is_tenant or perms.hosting.view_hostingplan %}
@@ -0,0 +1,3 @@
<td class="cell-primary-domain domain muted">
{% if primary_domain|lower != name|lower %}{{ primary_domain }}{% else %}<span aria-hidden="true">—</span><span class="visually-hidden">Same as account name</span>{% endif %}
</td>
@@ -76,7 +76,7 @@
<p>Type the primary domain to confirm this preview.</p> <p>Type the primary domain to confirm this preview.</p>
{% csrf_token %} {% csrf_token %}
{{ form.as_div }} {{ form.as_div }}
<button class="button primary" type="submit">{% if retirement %}Apply retirement policy{% else %}Retire hosting account{% endif %}</button> <div class="form-actions"><button class="button primary" type="submit">{% if retirement %}Apply retirement policy{% else %}Retire hosting account{% endif %}</button></div>
</form> </form>
</section> </section>
{% endif %} {% endif %}
@@ -93,10 +93,14 @@
</section> </section>
{% endif %} {% endif %}
{% for announcement in panel_announcements %}<section class="notice"><strong>{{ announcement.subject }}</strong>{{ announcement.body|linebreaks }}</section>{% endfor %} {% for announcement in panel_announcements %}<section class="notice"><strong>{{ announcement.subject }}</strong>{{ announcement.body|linebreaks }}</section>{% endfor %}
{% if not request.headers.x_coulobre_status %}
{% include "hosting/panel_notifications.html" %}
{% endif %}
{% block content %}{% endblock %} {% block content %}{% endblock %}
</main> </main>
</div> </div>
<script src="{% panel_asset 'hosting/panel-navigation.js' %}" defer></script> <script src="{% panel_asset 'hosting/panel-navigation.js' %}" defer></script>
<script src="{% panel_asset 'hosting/panel-notifications.js' %}" defer></script>
{% block extra_scripts %}{% endblock %} {% block extra_scripts %}{% endblock %}
{% else %} {% else %}
{% block public_content %}{% endblock %} {% block public_content %}{% endblock %}
@@ -32,23 +32,24 @@
<section class="surface" aria-label="Cluster hosting account list"> <section class="surface" aria-label="Cluster hosting account list">
<div class="table-scroll"> <div class="table-scroll">
<table> <table>
<thead><tr><th scope="col">Account</th><th scope="col">Hosting node</th><th scope="col">Status</th></tr></thead> <thead><tr><th scope="col">Account</th><th scope="col">Hosting node</th><th class="cell-primary-domain" scope="col">Primary domain</th><th scope="col">Status</th></tr></thead>
{% for page in pages %} {% for page in pages %}
{% if not page.unavailable %} {% if not page.unavailable %}
<tbody> <tbody>
{% for account in page.accounts %} {% for account in page.accounts %}
<tr> <tr>
<th scope="row">{% include "hosting/account_identity.html" with account_url=account.url name=account.name primary_domain=account.primary_domain only %}</th> <th scope="row">{% include "hosting/account_identity.html" with account_url=account.url name=account.name only %}</th>
<td>{% include "hosting/hosting_node.html" with node=page.node only %}</td> <td>{% include "hosting/hosting_node.html" with node=page.node only %}</td>
{% include "hosting/account_primary_domain.html" with name=account.name primary_domain=account.primary_domain only %}
<td>{% include "hosting/account_status.html" %}</td> <td>{% include "hosting/account_status.html" %}</td>
</tr> </tr>
{% empty %} {% empty %}
<tr> <tr>
<td colspan="3" class="muted">No matching accounts on {{ page.node.label }}{% if previous_offset is not None %} on this page{% endif %}.</td> <td colspan="4" class="muted">No matching accounts on {{ page.node.label }}{% if previous_offset is not None %} on this page{% endif %}.</td>
</tr> </tr>
{% endfor %} {% endfor %}
{% if page.more and not selected_node %} {% if page.more and not selected_node %}
<tr><td colspan="3"><a class="record-link" href="{% querystring node=page.node.key offset=None %}">View all results on {{ page.node.label }}</a></td></tr> <tr><td colspan="4"><a class="record-link" href="{% querystring node=page.node.key offset=None %}">View all results on {{ page.node.label }}</a></td></tr>
{% endif %} {% endif %}
</tbody> </tbody>
{% endif %} {% endif %}
@@ -6,7 +6,7 @@
{% if may_create %} {% if may_create %}
<section class="surface editor-surface" aria-labelledby="backup-create"> <section class="surface editor-surface" aria-labelledby="backup-create">
<h2 id="backup-create">Create a backup</h2><p>Download the latest completed customer backup over SFTP at <code>/backups/latest.zip</code>.</p> <h2 id="backup-create">Create a backup</h2><p>Download the latest completed customer backup over SFTP at <code>/backups/latest.zip</code>.</p>
<form class="editor" method="post">{% csrf_token %}{{ form.as_div }}<button class="button primary" type="submit">Create backup</button></form> <form class="editor" method="post">{% csrf_token %}{{ form.as_div }}<div class="form-actions"><button class="button primary" type="submit">Create backup</button></div></form>
</section> </section>
{% else %}<p class="notice">Customer backups require an active website, SFTP and the local backup service.</p>{% endif %} {% else %}<p class="notice">Customer backups require an active website, SFTP and the local backup service.</p>{% endif %}
<section class="surface" aria-labelledby="backup-history" data-live-status="customer-backups"> <section class="surface" aria-labelledby="backup-history" data-live-status="customer-backups">
@@ -47,7 +47,7 @@
<details class="surface editor-surface"{% if upload_form.errors %} open{% endif %}> <details class="surface editor-surface"{% if upload_form.errors %} open{% endif %}>
<summary>Upload certificate</summary> <summary>Upload certificate</summary>
<form method="post" class="editor" enctype="multipart/form-data">{% csrf_token %}{{ upload_form.as_div }} <form method="post" class="editor" enctype="multipart/form-data">{% csrf_token %}{{ upload_form.as_div }}
<button class="button secondary" type="submit" name="action" value="upload">Install uploaded certificate</button> <div class="form-actions"><button class="button secondary" type="submit" name="action" value="upload">Install uploaded certificate</button></div>
</form> </form>
</details> </details>
{% endif %} {% endif %}
@@ -57,7 +57,7 @@
<p>The website's DNS must resolve to this node and HTTP port 80 must be reachable for validation.</p> <p>The website's DNS must resolve to this node and HTTP port 80 must be reachable for validation.</p>
{% if enabled %} {% if enabled %}
<form method="post" class="editor">{% csrf_token %}{{ acme_form.as_div }} <form method="post" class="editor">{% csrf_token %}{{ acme_form.as_div }}
<button class="button primary" type="submit" name="action" value="{% if certificate.certificate.installed %}reissue{% else %}issue{% endif %}">Request ACME certificate</button> <div class="form-actions"><button class="button primary" type="submit" name="action" value="{% if certificate.certificate.installed %}reissue{% else %}issue{% endif %}">Request ACME certificate</button></div>
</form> </form>
{% endif %} {% endif %}
</section> </section>
@@ -31,7 +31,7 @@
<section class="surface editor-surface"> <section class="surface editor-surface">
<h2>Add {% if kind == 'domain' %}domain{% else %}site{% endif %} redirect</h2> <h2>Add {% if kind == 'domain' %}domain{% else %}site{% endif %} redirect</h2>
<form method="post" class="editor">{% csrf_token %}{{ form.as_div }} <form method="post" class="editor">{% csrf_token %}{{ form.as_div }}
<button type="submit" class="button primary" name="action" value="create"{% if job and not job.finished_at %} disabled{% endif %}>Add redirect</button> <div class="form-actions"><button type="submit" class="button primary" name="action" value="create"{% if job and not job.finished_at %} disabled{% endif %}>Add redirect</button></div>
</form> </form>
</section> </section>
{% else %}<p class="notice">Activate a website or an alias before adding redirects.</p>{% endif %} {% else %}<p class="notice">Activate a website or an alias before adding redirects.</p>{% endif %}
@@ -22,7 +22,7 @@
</table></div></section> </table></div></section>
<section class="surface editor-surface"> <section class="surface editor-surface">
<h2>Add database login</h2> <h2>Add database login</h2>
<form method="post" class="editor">{% csrf_token %}{{ form.as_div }}<button class="button primary" name="action" value="add" type="submit">Add login</button></form> <form method="post" class="editor">{% csrf_token %}{{ form.as_div }}<div class="form-actions"><button class="button primary" name="action" value="add" type="submit">Add login</button></div></form>
</section> </section>
<section class="surface editor-surface" data-live-status="sql-export"> <section class="surface editor-surface" data-live-status="sql-export">
<h2>SQL export</h2> <h2>SQL export</h2>
@@ -1,4 +1,9 @@
{% extends "hosting/workspace_page.html" %} {% extends "hosting/workspace_page.html" %}
{% load panel_assets %}
{% block extra_scripts %}
{{ block.super }}
<script src="{% panel_asset 'hosting/directadmin-import.js' %}" defer></script>
{% endblock %}
{% block title %}DirectAdmin import · Coulobre Panel{% endblock %} {% block title %}DirectAdmin import · Coulobre Panel{% endblock %}
{% block page_title %}DirectAdmin import{% endblock %} {% block page_title %}DirectAdmin import{% endblock %}
@@ -9,23 +14,35 @@
{% block page_content %} {% block page_content %}
{% if not job %} {% if not job %}
<form class="surface editor-surface" method="post" enctype="multipart/form-data"> <section class="surface editor-surface" aria-labelledby="directadmin-upload">
<form class="editor" method="post" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
<p>Upload an account backup in TAR, TAR.GZ or TAR.ZST format (up to 1 GiB). Coulobre checks the archive and shows what can be imported before making any changes.</p> <header>
<h2 id="directadmin-upload">Upload a backup</h2>
<p class="muted">Use a TAR, TAR.GZ or TAR.ZST account backup up to 1 GiB. Preflight shows what can be imported without making any changes to hosting accounts.</p>
</header>
{{ form.as_div }} {{ form.as_div }}
<div class="form-actions"><button type="submit">Run preflight</button></div> <div class="form-actions"><button class="button primary" type="submit">Run preflight</button></div>
</form> </form>
</section>
{% if recent %} {% if recent %}
<section class="surface" aria-labelledby="directadmin-recent"> <section class="surface" aria-labelledby="directadmin-recent">
<header class="section-heading"><h2 id="directadmin-recent">Recent imports</h2></header> <header class="section-heading"><h2 id="directadmin-recent">Recent imports</h2></header>
<div class="table-scroll"> <div class="table-scroll">
<table> <table>
<thead><tr><th scope="col">Requested</th><th scope="col">Destination</th><th scope="col">Status</th></tr></thead> <thead><tr><th scope="col">Requested</th><th scope="col">Destination</th><th scope="col">Status</th><th scope="col">Actions</th></tr></thead>
<tbody>{% for previous in recent %} <tbody>{% for previous in recent %}
<tr> <tr>
<th scope="row"><a href="{% url 'panel:directadmin_import' previous.pk %}">{{ previous.requested_at|date:"j M Y, H:i T" }}</a></th> <th scope="row">{{ previous.requested_at|date:"j M Y, H:i T" }}</th>
<td>{{ previous.account|default:"Not selected" }}</td> <td>
{% if previous.selection.domain %}
{{ previous.selection.domain }}{% if previous.selection.destination_name and previous.selection.destination_name != previous.selection.domain %} · {{ previous.selection.destination_name }}{% endif %}
{% else %}Not selected{% endif %}
</td>
<td>{{ previous.get_state_display }}</td> <td>{{ previous.get_state_display }}</td>
<td><a class="button secondary compact" href="{% url 'panel:directadmin_import' previous.pk %}">
{% if previous.state == "review" %}Review preflight{% elif previous.finished_at %}View import result{% else %}View import progress{% endif %}
</a></td>
</tr> </tr>
{% endfor %}</tbody> {% endfor %}</tbody>
</table> </table>
@@ -34,7 +51,7 @@
{% endif %} {% endif %}
{% else %} {% else %}
<div class="live-sections"> <div class="live-sections">
<section class="surface" aria-labelledby="directadmin-status" data-live-status="directadmin-import"> <section class="surface" aria-labelledby="directadmin-status" data-live-status="directadmin-import" data-live-state="{{ job.state }}"{% if job.state == "review" %} data-live-notice="DirectAdmin preflight is ready for review."{% elif job.state == "complete" %} data-live-notice="DirectAdmin import complete." data-live-notice-level="success"{% elif job.state == "failed" or job.state == "expired" %} data-live-notice="{{ job.get_state_display }}. See the import status for details." data-live-notice-level="error"{% endif %}>
<header class="section-heading"> <header class="section-heading">
<h2 id="directadmin-status">{{ job.get_state_display }}</h2> <h2 id="directadmin-status">{{ job.get_state_display }}</h2>
{% if job.account %}<a class="button secondary compact" href="{{ job.account.get_absolute_url }}">Open hosting account</a>{% endif %} {% if job.account %}<a class="button secondary compact" href="{{ job.account.get_absolute_url }}">Open hosting account</a>{% endif %}
@@ -42,6 +59,9 @@
<a class="button compact" href="{% url 'panel:directadmin_import' job.pk %}#directadmin-review">Review preflight</a> <a class="button compact" href="{% url 'panel:directadmin_import' job.pk %}#directadmin-review">Review preflight</a>
{% endif %} {% endif %}
</header> </header>
{% if job.selection.domain %}
<p class="section-text"><strong>Destination</strong> · {{ job.selection.domain }}{% if job.selection.destination_name and job.selection.destination_name != job.selection.domain %} · {{ job.selection.destination_name }}{% endif %}</p>
{% endif %}
{% if pending %} {% if pending %}
<p class="section-text" role="status" data-live-pending> <p class="section-text" role="status" data-live-pending>
{% if job.state == "inspect_queued" or job.state == "inspecting" %} {% if job.state == "inspect_queued" or job.state == "inspecting" %}
@@ -56,17 +76,21 @@
{% if job.work %}<p class="section-text">Changes already applied are not undone. Check the destination and the component status below.</p>{% endif %} {% if job.work %}<p class="section-text">Changes already applied are not undone. Check the destination and the component status below.</p>{% endif %}
{% elif job.state == "complete" %} {% elif job.state == "complete" %}
<p class="section-text">Review the imported data before updating DNS. Existing public DNS and the source account were not changed.</p> <p class="section-text">Review the imported data before updating DNS. Existing public DNS and the source account were not changed.</p>
{% if "dns" in job.selection.components and job.account %}<p class="section-text"><a class="button secondary compact" href="{{ job.account.get_absolute_url }}#domains-dns">Review DNS drafts</a></p>{% endif %}
{% endif %} {% endif %}
{% if job.work %} {% if job.work %}
<div class="table-scroll"> <div class="table-scroll">
<table> <table>
<thead><tr><th scope="col">Component</th><th scope="col">Destination</th><th scope="col">State</th></tr></thead> <thead><tr><th scope="col">Component</th><th scope="col">Destination</th><th scope="col">State</th></tr></thead>
<tbody>{% for item in job.work %} <tbody>{% for item in job.work %}
<tr><th scope="row">{{ item.kind|capfirst }}</th><td>{{ item.label }}</td><td>{{ item.status|default:"Waiting" }}</td></tr> <tr><th scope="row">{{ item.kind|capfirst }}</th><td>{{ item.label }}</td><td>{% if item.status %}{{ item.status }}{% elif job.finished_at %}Not completed{% else %}Waiting{% endif %}
{% if item.receipt %}<div class="muted">{% if "files" in item.receipt %}{{ item.receipt.files }} files{% elif "messages" in item.receipt %}{{ item.receipt.messages }} messages{% endif %}{% if "bytes" in item.receipt %}{% if "files" in item.receipt or "messages" in item.receipt %} · {% endif %}{{ item.receipt.bytes|filesizeformat }}{% endif %}</div>{% endif %}</td></tr>
{% endfor %}</tbody> {% endfor %}</tbody>
</table> </table>
</div> </div>
{% endif %} {% endif %}
{% if not_started %}<p class="section-text">Not started · {{ not_started|join:", " }}</p>{% endif %}
{% if not_selected and job.finished_at %}<p class="section-text muted">Not requested · {{ not_selected|join:", " }}</p>{% endif %}
</section> </section>
{% if job.state == "review" and form %} {% if job.state == "review" and form %}
<section class="surface" aria-labelledby="directadmin-source"> <section class="surface" aria-labelledby="directadmin-source">
@@ -74,17 +98,17 @@
<p class="section-text">Source account <strong>{{ job.report.username }}</strong> · {{ job.size|filesizeformat }} upload. Choose a primary domain and any additional domains to restore. Database dumps belong to the whole source account.</p> <p class="section-text">Source account <strong>{{ job.report.username }}</strong> · {{ job.size|filesizeformat }} upload. Choose a primary domain and any additional domains to restore. Database dumps belong to the whole source account.</p>
{% for domain in job.report.domains %} {% for domain in job.report.domains %}
<div class="section-text"> <div class="section-text">
<h3>{{ domain.name }}</h3> <h3 class="domain">{{ domain.name }}</h3>
<ul> <ul>
{% for root, counts in domain.websites.items %} {% for root, counts in domain.websites.items %}
<li>{{ root }} · {{ counts.files }} files · {{ counts.bytes|filesizeformat }}</li> <li>{{ root }} · {{ counts.files }} file{{ counts.files|pluralize }} · {{ counts.bytes|filesizeformat }}</li>
{% empty %}<li>No supported website files found.</li>{% endfor %} {% empty %}<li>No supported website files found.</li>{% endfor %}
{% for mailbox in domain.mailboxes %} {% for mailbox in domain.mailboxes %}
<li>{{ mailbox.address }} · {{ mailbox.messages }} messages · {{ mailbox.folders }} folders with messages · {{ mailbox.bytes|filesizeformat }}</li> <li>{{ mailbox.address }} · {{ mailbox.messages }} message{{ mailbox.messages|pluralize }} · {{ mailbox.folders }} folder{{ mailbox.folders|pluralize }} with messages · {{ mailbox.bytes|filesizeformat }}</li>
{% empty %}<li>No named mailboxes found.</li>{% endfor %} {% empty %}<li>No named mailboxes found.</li>{% endfor %}
{% if domain.unrecognized_mailbox_entries %}<li>{{ domain.unrecognized_mailbox_entries }} unrecognized mailbox entries will not be imported.</li>{% endif %} {% if domain.unrecognized_mailbox_entries %}<li>{{ domain.unrecognized_mailbox_entries }} unrecognized mailbox entries will not be imported.</li>{% endif %}
{% if domain.zone.manifest %} {% if domain.zone.manifest %}
<li>{{ domain.zone.records }} DNS records can be saved as a draft. Review and update source DNS records before publishing.</li> <li>{{ domain.zone.records }} DNS record{{ domain.zone.records|pluralize }} can be saved as a draft. Review and update source DNS records before publishing.</li>
{% elif domain.zone.problem %}<li>{{ domain.zone.problem }}</li> {% elif domain.zone.problem %}<li>{{ domain.zone.problem }}</li>
{% else %}<li>No DNS zone found.</li>{% endif %} {% else %}<li>No DNS zone found.</li>{% endif %}
{% if domain.destination_problem %}<li>{{ domain.destination_problem }}</li> {% if domain.destination_problem %}<li>{{ domain.destination_problem }}</li>
@@ -104,21 +128,59 @@
{% empty %}<li>No supported database dumps found.</li>{% endfor %}</ul> {% empty %}<li>No supported database dumps found.</li>{% endfor %}</ul>
{% if job.report.unsupported_databases %}<p>Some database dumps have unsupported names or are empty or duplicated. They are not imported.</p>{% endif %} {% if job.report.unsupported_databases %}<p>Some database dumps have unsupported names or are empty or duplicated. They are not imported.</p>{% endif %}
{% if job.report.home_archive %}<p>Nested home archives are not imported.</p>{% endif %} {% if job.report.home_archive %}<p>Nested home archives are not imported.</p>{% endif %}
{% if job.report.skipped_non_regular_entries %}<p>The archive contains {{ job.report.skipped_non_regular_entries }} links or special entries. Selected website or mail files containing unsupported entries may be rejected.</p>{% endif %} {% if job.report.skipped_non_regular_entries %}<p>The archive contains unsupported links or special entries ({{ job.report.skipped_non_regular_entries }}). Website or mail components containing them may be rejected.</p>{% endif %}
</div> </div>
</section> </section>
{% if job.report.domains %} {% if job.report.domains %}
<form class="surface editor-surface" id="directadmin-review" method="post"> <section class="surface editor-surface editor-wide" aria-labelledby="directadmin-review-title" id="directadmin-review">
<form class="editor" data-directadmin-review method="post">
{% csrf_token %} {% csrf_token %}
<h2>Choose what to import</h2> <header>
<p>After creating a hosting account, open it to assign a customer or manager. This import does not create a customer login. To restore more than one website, use a hosting package that permits them. Imported mailbox and database passwords are not recovered from the backup. Set new passwords and update site configuration before going live.</p> <h2 id="directadmin-review-title">Choose what to import</h2>
<p>Importing mail activates the destination mailboxes on this installation even before public DNS changes.</p> <p class="muted">Choose a destination and the data to restore. The import does not create a customer login or recover mailbox and database passwords.</p>
{{ form.as_div }} </header>
{% if form.errors %}
<div class="notice panel-notification" data-notification-level="error" role="alert">
<div><strong>Import not queued</strong>
{% if form.non_field_errors %}{{ form.non_field_errors }}
{% else %}<p>Correct the highlighted fields before starting the import.</p>{% endif %}
</div>
</div>
{% endif %}
<div class="editor-columns">
<fieldset class="editor editor-group">
<legend>Source and components</legend>
<div>{{ form.domain.as_field_group }}</div>
{% if form.extra_domains %}<div>{{ form.extra_domains.as_field_group }}</div>{% endif %}
<div>{{ form.components.as_field_group }}</div>
<div>{{ form.source_root.as_field_group }}</div>
</fieldset>
<fieldset class="editor editor-group">
<legend>Hosting destination</legend>
<div>{{ form.target.as_field_group }}</div>
{% for domain in job.report.domains %}
<p class="muted" data-import-match="{{ domain.name }}">
{{ domain.name }} ·
{% if domain.existing_account %}Matching account <strong>{{ domain.existing_account_name }}</strong>.{% else %}No matching hosting account.{% endif %}
{% if domain.destination_problem %}{{ domain.destination_problem }}{% endif %}
</p>
{% endfor %}
<fieldset class="editor editor-group" data-import-new>
<legend>New account settings</legend>
<div>{{ form.hosting_plan.as_field_group }}</div>
<div>{{ form.name.as_field_group }}</div>
<p class="muted">To restore more than one website, select a package that permits it. Assign a customer or manager after import if needed.</p>
</fieldset>
</fieldset>
</div>
<p class="muted">Importing mail activates the destination mailboxes before any public DNS change. Set new passwords and update site configuration before going live.</p>
<div>{{ form.reviewed.as_field_group }}</div>
<div class="form-actions"> <div class="form-actions">
<button type="submit" name="action" value="import">Start import</button> <button type="submit" class="button primary" name="action" value="import">Start import</button>
<button type="submit" name="action" value="cancel" class="button secondary" formnovalidate>Discard upload</button> <button type="submit" name="action" value="cancel" class="button secondary" formnovalidate>Discard upload</button>
</div> </div>
</form> </form>
</section>
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>
@@ -5,7 +5,7 @@
<form method="post" class="editor"> <form method="post" class="editor">
{% csrf_token %} {% csrf_token %}
{{ form.as_div }} {{ form.as_div }}
<button class="button primary" type="submit">Save template</button> <div class="form-actions"><button class="button primary" type="submit">Save template</button></div>
</form> </form>
</section> </section>
<section class="surface" aria-label="Template preview"> <section class="surface" aria-label="Template preview">
@@ -9,6 +9,6 @@
{% if topology.problem %}<p class="notice">{{ topology.problem }}</p>{% endif %} {% if topology.problem %}<p class="notice">{{ topology.problem }}</p>{% endif %}
</section> </section>
<section class="surface editor-surface"><h2>Domain service ownership</h2> <section class="surface editor-surface"><h2>Domain service ownership</h2>
<form method="post" class="editor">{% csrf_token %}{{ form.as_div }}<button class="button primary" type="submit">Save domain preferences</button></form> <form method="post" class="editor">{% csrf_token %}{{ form.as_div }}<div class="form-actions"><button class="button primary" type="submit">Save domain preferences</button></div></form>
</section> </section>
{% endblock %} {% endblock %}
@@ -16,7 +16,7 @@
<section class="surface section-heading"><h2>Mail domain alias</h2><a class="button secondary" href="{% url 'panel:mail_domain_alias' account.pk domain %}">Manage mail alias</a></section> <section class="surface section-heading"><h2>Mail domain alias</h2><a class="button secondary" href="{% url 'panel:mail_domain_alias' account.pk domain %}">Manage mail alias</a></section>
{% endif %} {% endif %}
<section class="surface editor-surface" aria-label="Domain services"> <section class="surface editor-surface" aria-label="Domain services">
<form method="post" class="editor">{% csrf_token %}{{ form.as_div }}<button class="button primary" type="submit">Save service preferences</button></form> <form method="post" class="editor">{% csrf_token %}{{ form.as_div }}<div class="form-actions"><button class="button primary" type="submit">Save service preferences</button></div></form>
</section> </section>
{% elif page == 'dns' %} {% elif page == 'dns' %}
{% if zone %} {% if zone %}
@@ -4,7 +4,7 @@
{% block page_content %} {% block page_content %}
<section class="surface editor-surface"> <section class="surface editor-surface">
<form class="editor" method="post" action="{% url 'panel:mail_delivery' %}"> <form class="editor" method="post" action="{% url 'panel:mail_delivery' %}">
{% csrf_token %}{{ form.as_div }}<button class="button primary" type="submit">Search delivery history</button> {% csrf_token %}{{ form.as_div }}<div class="form-actions"><button class="button primary" type="submit">Search delivery history</button></div>
</form> </form>
</section> </section>
{% if search %} {% if search %}
@@ -9,7 +9,7 @@
<form class="editor" method="post" action="{% url 'panel:mail_diagnostics' %}"> <form class="editor" method="post" action="{% url 'panel:mail_diagnostics' %}">
{% csrf_token %} {% csrf_token %}
{{ filter_form.as_div }} {{ filter_form.as_div }}
<button class="button secondary" type="submit" name="action" value="check-filter">Run filter check</button> <div class="form-actions"><button class="button secondary" type="submit" name="action" value="check-filter">Run filter check</button></div>
</form> </form>
</section> </section>
{% endif %} {% endif %}
@@ -47,7 +47,7 @@
{% csrf_token %} {% csrf_token %}
{% if errors %}<ul class="errorlist" role="alert">{% for error in errors %}<li>{{ error }}</li>{% endfor %}</ul>{% endif %} {% if errors %}<ul class="errorlist" role="alert">{% for error in errors %}<li>{{ error }}</li>{% endfor %}</ul>{% endif %}
{{ form.as_div }} {{ form.as_div }}
<button class="button primary" type="submit">Analyze headers</button> <div class="form-actions"><button class="button primary" type="submit">Analyze headers</button></div>
</form> </form>
</section> </section>
{% if report %} {% if report %}
@@ -14,10 +14,10 @@
{% endif %} {% endif %}
{% if problem %}<p class="error" role="alert">{{ problem }}</p>{% endif %} {% if problem %}<p class="error" role="alert">{{ problem }}</p>{% endif %}
{% if not job or job.problem and not job.remove %} {% if not job or job.problem and not job.remove %}
<form method="post" class="editor">{% csrf_token %}{{ form.as_div }}<button class="button primary" name="action" value="save">{% if job %}Retry setup{% else %}Add mail alias{% endif %}</button></form> <form method="post" class="editor">{% csrf_token %}{{ form.as_div }}<div class="form-actions"><button class="button primary" type="submit" name="action" value="save">{% if job %}Retry setup{% else %}Add mail alias{% endif %}</button></div></form>
{% endif %} {% endif %}
{% if job.finished_at %} {% if job.finished_at %}
<form method="post" class="editor">{% csrf_token %}<button class="button secondary" name="action" value="remove">{% if job.remove %}Retry removal{% else %}Remove mail alias{% endif %}</button></form> <form method="post" class="editor">{% csrf_token %}<div class="form-actions"><button class="button secondary" type="submit" name="action" value="remove">{% if job.remove %}Retry removal{% else %}Remove mail alias{% endif %}</button></div></form>
{% endif %} {% endif %}
{% if job.active %} {% if job.active %}
<h2>Incoming mail DNS</h2> <h2>Incoming mail DNS</h2>
@@ -15,7 +15,7 @@
{% block page_content %} {% block page_content %}
<div class="live-sections"> <div class="live-sections">
{% if job %} {% if job %}
<section class="surface" aria-labelledby="import-progress" data-live-status="mailbox-import"> <section class="surface" aria-labelledby="import-progress" data-live-status="mailbox-import" data-live-state="{% if job.finished_at %}{% if job.problem %}failed{% else %}complete{% endif %}{% else %}active{% endif %}"{% if job.finished_at %}{% if job.problem %} data-live-notice="The mailbox import needs attention." data-live-notice-level="error"{% else %} data-live-notice="Mailbox import complete." data-live-notice-level="success"{% endif %}{% endif %}>
<header class="section-heading"> <header class="section-heading">
<h2 id="import-progress">Import progress</h2> <h2 id="import-progress">Import progress</h2>
{% if job.finished_at %} {% if job.finished_at %}
@@ -71,7 +71,7 @@
{% endif %} {% endif %}
{% if preview and not job or preview and job.finished_at %} {% if preview and not job or preview and job.finished_at %}
<section class="surface" id="import-preview" aria-labelledby="preview-heading" data-live-status="mailbox-import-preview"> <section class="surface" id="import-preview" aria-labelledby="preview-heading" data-live-status="mailbox-import-preview" data-live-state="{% if preview.finished_at %}{% if preview.problem %}failed{% else %}ready{% endif %}{% else %}active{% endif %}"{% if preview.finished_at %}{% if preview.problem %} data-live-notice="The mailbox import preview could not finish." data-live-notice-level="error"{% else %} data-live-notice="Mailbox import preview is ready."{% endif %}{% endif %}>
<header class="section-heading"><h2 id="preview-heading">Import preview</h2></header> <header class="section-heading"><h2 id="preview-heading">Import preview</h2></header>
{% if not preview.finished_at %} {% if not preview.finished_at %}
<p class="section-text" role="status" data-live-pending>Checking the source and destination. Nothing is being copied.</p> <p class="section-text" role="status" data-live-pending>Checking the source and destination. Nothing is being copied.</p>
@@ -24,7 +24,7 @@
{% if enabled %} {% if enabled %}
<section class="surface editor-surface"> <section class="surface editor-surface">
<h2>Back up a manager's hosting accounts</h2> <h2>Back up a manager's hosting accounts</h2>
<form class="editor" method="post">{% csrf_token %}{{ form.as_div }}<button class="button primary" type="submit">Apply to hosting accounts</button></form> <form class="editor" method="post">{% csrf_token %}{{ form.as_div }}<div class="form-actions"><button class="button primary" type="submit">Apply to hosting accounts</button></div></form>
</section> </section>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
@@ -0,0 +1,7 @@
<div class="panel-notifications" data-panel-notifications aria-label="Notifications">
{% for message in messages %}
<div class="notice panel-notification" data-notification-level="{{ message.level_tag }}">
<p role="{% if message.level_tag == 'error' %}alert{% else %}status{% endif %}">{{ message }}</p>
</div>
{% endfor %}
</div>
@@ -18,7 +18,7 @@
<form method="post" class="editor"> <form method="post" class="editor">
{% csrf_token %} {% csrf_token %}
{{ form.as_div }} {{ form.as_div }}
<button type="submit" class="button primary" name="action" value="enroll">Enroll panel</button> <div class="form-actions"><button type="submit" class="button primary" name="action" value="enroll">Enroll panel</button></div>
</form> </form>
</section> </section>
<section class="surface"> <section class="surface">
@@ -25,7 +25,7 @@
<form class="editor" method="post"> <form class="editor" method="post">
{% csrf_token %} {% csrf_token %}
{{ form.as_div }} {{ form.as_div }}
<button type="submit" class="button primary" name="action" value="issue">Issue credential</button> <div class="form-actions"><button type="submit" class="button primary" name="action" value="issue">Issue credential</button></div>
</form> </form>
</section> </section>
<section class="surface"> <section class="surface">
@@ -7,13 +7,13 @@
<p>The archive contains local service configuration, MariaDB, and hosted files and mail. Retrieve it on the server using an administrator account.</p> <p>The archive contains local service configuration, MariaDB, and hosted files and mail. Retrieve it on the server using an administrator account.</p>
<form method="post" class="editor">{% csrf_token %} <form method="post" class="editor">{% csrf_token %}
<label><input type="checkbox" name="confirm" value="yes" required> Create a system recovery archive</label> <label><input type="checkbox" name="confirm" value="yes" required> Create a system recovery archive</label>
<button class="button primary" type="submit" name="action" value="create">Queue backup</button> <div class="form-actions"><button class="button primary" type="submit" name="action" value="create">Queue backup</button></div>
</form> </form>
</section> </section>
<section class="surface editor-surface"> <section class="surface editor-surface">
<h2>Schedule</h2> <h2>Schedule</h2>
<form method="post" class="editor">{% csrf_token %}{{ form.as_div }} <form method="post" class="editor">{% csrf_token %}{{ form.as_div }}
<button class="button secondary" name="action" value="schedule" type="submit">Save schedule</button> <div class="form-actions"><button class="button secondary" name="action" value="schedule" type="submit">Save schedule</button></div>
</form> </form>
</section> </section>
{% else %}<p class="notice">Enable system backups and the local operator worker on this server.</p>{% endif %} {% else %}<p class="notice">Enable system backups and the local operator worker on this server.</p>{% endif %}
@@ -25,13 +25,13 @@
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="operation" value="upload"> <input type="hidden" name="operation" value="upload">
{{ upload_form.as_div }} {{ upload_form.as_div }}
<button class="button primary" type="submit">Upload</button> <div class="form-actions"><button class="button primary" type="submit">Upload</button></div>
</form> </form>
<form class="editor" method="post"> <form class="editor" method="post">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="operation" value="mkdir"> <input type="hidden" name="operation" value="mkdir">
{{ folder_form.as_div }} {{ folder_form.as_div }}
<button class="button secondary" type="submit">Create folder</button> <div class="form-actions"><button class="button secondary" type="submit">Create folder</button></div>
</form> </form>
</div> </div>
{% if entries %} {% if entries %}
@@ -19,10 +19,5 @@
{% block workspace_selector %}{% include "hosting/workspace_account_selector.html" %}{% endblock %} {% block workspace_selector %}{% include "hosting/workspace_account_selector.html" %}{% endblock %}
{% block page_context %}{% endblock %} {% block page_context %}{% endblock %}
</div> </div>
{% if not request.headers.x_coulobre_status %}
{% for message in messages %}
<p class="notice" role="{% if message.level_tag == 'error' %}alert{% else %}status{% endif %}">{{ message }}</p>
{% endfor %}
{% endif %}
{% block page_content %}{% endblock %} {% block page_content %}{% endblock %}
{% endblock %} {% endblock %}
@@ -139,7 +139,7 @@ class DirectAdminWebImportTests(TestCase):
response = self.client.get(url) response = self.client.get(url)
self.assertContains(response, "source_main") self.assertContains(response, "source_main")
self.assertContains(response, "info@example.net") self.assertContains(response, "info@example.net")
self.assertContains(response, "1 messages") self.assertContains(response, "1 message · 1 folder with messages")
self.assertContains(response, "6 DNS records") self.assertContains(response, "6 DNS records")
self.assertNotContains(response, "should-never-be-stored") self.assertNotContains(response, "should-never-be-stored")
self.assertNotIn("should-never-be-stored", str(job.report)) self.assertNotIn("should-never-be-stored", str(job.report))
@@ -156,7 +156,16 @@ class DirectAdminWebImportTests(TestCase):
name="Destination", primary_domain=DOMAIN name="Destination", primary_domain=DOMAIN
) )
job, url = self.prepare() job, url = self.prepare()
self.assertEqual(self.submit(url, target="existing").status_code, 302) review = self.client.get(url)
self.assertContains(review, "Use the matching empty hosting account")
self.assertContains(review, "New account settings")
response = self.submit(
url, target="existing", hosting_plan="invalid", name="unused"
)
self.assertEqual(response.status_code, 302)
queued = self.client.get(self.url)
self.assertContains(queued, "Destination")
self.assertContains(queued, "View import progress")
run_directadmin_import(str(job.pk), "import_queued") run_directadmin_import(str(job.pk), "import_queued")
job.refresh_from_db() job.refresh_from_db()
self.assertEqual(job.state, "provisioning", job.problem) self.assertEqual(job.state, "provisioning", job.problem)
@@ -170,6 +179,20 @@ class DirectAdminWebImportTests(TestCase):
self.assertFalse(archive_path(job.pk).exists()) self.assertFalse(archive_path(job.pk).exists())
self.assertFalse(HostingDatabase.objects.exists()) self.assertFalse(HostingDatabase.objects.exists())
self.assertFalse(HostingMailbox.objects.exists()) self.assertFalse(HostingMailbox.objects.exists())
self.assertContains(self.client.get(self.url), "View import result")
self.assertContains(self.client.get(url), "Not requested")
def test_status_poll_does_not_consume_the_submission_notification(self):
_, url = self.prepare()
self.assertEqual(self.submit(url).status_code, 302)
self.assertNotContains(
self.client.get(url, headers={"X-Coulobre-Status": "1"}),
"DirectAdmin import queued.",
)
self.assertContains(self.client.get(url), "DirectAdmin import queued.")
self.assertNotContains(
self.client.get(url), "DirectAdmin import queued."
)
def test_rejects_nonempty_target_on_review_or_after_confirmation(self): def test_rejects_nonempty_target_on_review_or_after_confirmation(self):
account = HostingAccount.objects.create( account = HostingAccount.objects.create(
@@ -123,5 +123,10 @@ class PackageWorkflowTests(TestCase):
) )
response = self.client.get(reverse("panel:accounts")) response = self.client.get(reverse("panel:accounts"))
self.assertContains(response, 'class="account-identity"', count=2) self.assertContains(response, 'class="account-identity"', count=2)
self.assertNotContains(response, ">same.example</span>") self.assertContains(response, "Same as account name", count=1)
self.assertContains(response, ">different.example</span>") self.assertContains(response, "different.example", count=1)
self.assertContains(response, "Primary domain")
self.assertLess(
response.content.index(b">Primary domain<"),
response.content.index(b">Status<"),
)
@@ -11,6 +11,7 @@ from unittest.mock import patch
from django.test import SimpleTestCase from django.test import SimpleTestCase
from coulobre.web_node import WebSite, main from coulobre.web_node import WebSite, main
from coulobre.web_node_apply import LEGACY_STARTER_PAGE, render_starter_page
from coulobre.web_node_restore import copy_website, restore_website from coulobre.web_node_restore import copy_website, restore_website
@@ -146,6 +147,59 @@ class DirectAdminWebRestoreTests(SimpleTestCase):
self.assertEqual(list(self.public.iterdir()), [existing]) self.assertEqual(list(self.public.iterdir()), [existing])
self.assertEqual(existing.read_bytes(), b"existing") self.assertEqual(existing.read_bytes(), b"existing")
def test_only_stock_starter_page_can_be_replaced(self):
index = self.public / "index.html"
starter = render_starter_page(self.site.domain)
index.write_text(starter + "\n<!-- edited -->", encoding="utf-8")
with self.assertRaisesRegex(ValueError, "empty document root"):
self.restore()
index.unlink()
other_index = self.account / "other.html"
other_index.write_text(starter, encoding="utf-8")
index.symlink_to(other_index)
with self.assertRaisesRegex(ValueError, "empty document root"):
self.restore()
self.assertTrue(index.is_symlink())
index.unlink()
index.write_text(starter, encoding="utf-8")
self.assertEqual(self.restore()["files"], 6)
self.assertFalse(index.exists())
self.assertEqual(other_index.read_text(encoding="utf-8"), starter)
self.assertEqual(
set(self.account.iterdir()), {self.public, other_index}
)
def test_legacy_starter_page_can_be_replaced(self):
(self.public / "index.html").write_text(
LEGACY_STARTER_PAGE, encoding="utf-8"
)
self.assertEqual(self.restore()["files"], 6)
def test_restore_keeps_both_versions_if_index_appears_during_publish(self):
index = self.public / "index.html"
starter = render_starter_page(self.site.domain)
index.write_text(starter, encoding="utf-8")
def publish_with_concurrent_file(staged, public):
self.assertFalse(index.exists())
index.write_bytes(b"new homepage")
raise ValueError("Restore requires an empty document root.")
with (
patch(
"coulobre.web_node_restore.publish_empty_webroot",
side_effect=publish_with_concurrent_file,
),
self.assertRaisesRegex(ValueError, "private recovery directory"),
):
self.restore()
self.assertEqual(index.read_bytes(), b"new homepage")
(saved,) = self.account.glob(".directadmin-recovery-*/index.html")
self.assertEqual(saved.read_text(encoding="utf-8"), starter)
def test_atomic_publish_preserves_a_file_created_during_restore(self): def test_atomic_publish_preserves_a_file_created_during_restore(self):
existing = self.public / "new.txt" existing = self.public / "new.txt"
+13
View File
@@ -81,6 +81,19 @@ def starter_page_matches(page):
return False return False
def is_starter_page(index):
try:
descriptor = os.open(
index, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK
)
except OSError:
return False
with os.fdopen(descriptor, "rb") as page:
if not stat.S_ISREG(os.fstat(page.fileno()).st_mode):
return False
return starter_page_matches(page.read(starter_page_read_limit()))
def starter_page_read_limit(): def starter_page_read_limit():
return ( return (
max( max(
+56 -6
View File
@@ -2,10 +2,23 @@ import errno
import fcntl import fcntl
import os import os
from pathlib import Path from pathlib import Path
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory, mkdtemp
from . import web_node_apply from . import web_node_apply
from .directadmin_website import copy_website from .directadmin_website import copy_website
from .web_node_files import rename_entry
def starter_to_replace(public):
entries = os.listdir(public)
if not entries:
return None
index = public / "index.html"
if entries == [index.name] and web_node_apply.is_starter_page(index):
return index
raise ValueError(
"Restore requires an empty document root or the original starter page."
)
def check_website_empty(site): def check_website_empty(site):
@@ -17,8 +30,7 @@ def check_website_empty(site):
fcntl.flock(lock, fcntl.LOCK_SH) fcntl.flock(lock, fcntl.LOCK_SH)
web_node_apply.check_reservation(site) web_node_apply.check_reservation(site)
public, _, _ = web_node_apply.site_storage(site) public, _, _ = web_node_apply.site_storage(site)
if any(public.iterdir()): starter_to_replace(public)
raise ValueError("Restore requires an empty document root.")
def restore_website(site, backup, source_root): def restore_website(site, backup, source_root):
@@ -32,8 +44,7 @@ def restore_website(site, backup, source_root):
paths = web_node_apply.SitePaths.for_site(site) paths = web_node_apply.SitePaths.for_site(site)
uid, gid = web_node_apply.check_installation(site, paths) uid, gid = web_node_apply.check_installation(site, paths)
public = paths.account / "public" public = paths.account / "public"
if any(public.iterdir()): starter_to_replace(public)
raise ValueError("Restore requires an empty document root.")
with TemporaryDirectory( with TemporaryDirectory(
dir=paths.account, prefix=".directadmin-restore-" dir=paths.account, prefix=".directadmin-restore-"
@@ -55,7 +66,7 @@ def restore_website(site, backup, source_root):
on_copy=remember_private_entry, on_copy=remember_private_entry,
) )
prepare_web_permissions(staged, uid, gid, private) prepare_web_permissions(staged, uid, gid, private)
publish_empty_webroot(staged, public) publish_directadmin_webroot(staged, public)
return { return {
**site.manifest(), **site.manifest(),
@@ -66,6 +77,45 @@ def restore_website(site, backup, source_root):
} }
def publish_directadmin_webroot(staged, public):
index = starter_to_replace(public)
if index is None:
publish_empty_webroot(staged, public)
return
recovery = Path(
mkdtemp(dir=public.parent, prefix=".directadmin-recovery-")
)
saved = recovery / index.name
try:
os.replace(index, saved)
if not web_node_apply.is_starter_page(saved):
raise ValueError("The starter page changed during import.")
publish_empty_webroot(staged, public)
except BaseException:
if os.path.lexists(saved) and staged.exists():
folder = os.open(public.parent, os.O_RDONLY | os.O_DIRECTORY)
try:
rename_entry(
folder,
saved.relative_to(public.parent),
index.relative_to(public.parent),
)
except (OSError, ValueError):
raise ValueError(
"The document root changed. The previous index was kept "
"in a private recovery directory on the web node."
) from None
finally:
os.close(folder)
if not os.path.lexists(saved):
recovery.rmdir()
raise
else:
saved.unlink()
recovery.rmdir()
def publish_empty_webroot(staged, public): def publish_empty_webroot(staged, public):
try: try:
# A rename can replace the live root while it is empty. # A rename can replace the live root while it is empty.
+3 -16
View File
@@ -140,24 +140,11 @@ def wordpress_version(cli, root):
return version return version
def is_starter_page(index):
try:
descriptor = os.open(
index, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK
)
except OSError:
return False
with os.fdopen(descriptor, "rb") as page:
if not stat.S_ISREG(os.fstat(page.fileno()).st_mode):
return False
contents = page.read(web.starter_page_read_limit())
return web.starter_page_matches(contents)
def check_install_target(public): def check_install_target(public):
entries = os.listdir(public) entries = os.listdir(public)
if entries and ( if entries and (
entries != ["index.html"] or not is_starter_page(public / "index.html") entries != ["index.html"]
or not web.is_starter_page(public / "index.html")
): ):
raise ValueError( raise ValueError(
"Use an empty website or the original Coulobre starter page." "Use an empty website or the original Coulobre starter page."
@@ -174,7 +161,7 @@ def publish_wordpress(staged, public):
saved = staged.parent / "previous-index" saved = staged.parent / "previous-index"
os.replace(index, saved) os.replace(index, saved)
try: try:
if not is_starter_page(saved): if not web.is_starter_page(saved):
raise ValueError("The starter page changed during setup.") raise ValueError("The starter page changed during setup.")
publish_empty_webroot(staged, public) publish_empty_webroot(staged, public)
except (OSError, ValueError, KeyboardInterrupt): except (OSError, ValueError, KeyboardInterrupt):
+1
View File
@@ -81,6 +81,7 @@ def build_package(source, wheel, ref, output):
units = root / "usr/lib/systemd/system" units = root / "usr/lib/systemd/system"
units.mkdir(parents=True) units.mkdir(parents=True)
for name in ( for name in (
"coulobre-panel.service.d/import-storage.conf",
"coulobre-directadmin-import-worker.service", "coulobre-directadmin-import-worker.service",
"coulobre-directadmin-restore.socket", "coulobre-directadmin-restore.socket",
"coulobre-directadmin-restore@.service", "coulobre-directadmin-restore@.service",