Compare commits
4
Commits
9caee44642
...
b6efae0cd8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6efae0cd8 | ||
|
|
528d62944e | ||
|
|
ccf7c544ea | ||
|
|
880b62e3d8 |
No files matched your search
@@ -9,7 +9,8 @@ Type=exec
|
||||
User=coulobre-panel
|
||||
Group=coulobre-panel
|
||||
SupplementaryGroups=coulobre-mail-provisioning
|
||||
ReadWritePaths=-/var/lib/coulobre-panel-imports
|
||||
StateDirectory=coulobre-panel-imports
|
||||
StateDirectoryMode=0700
|
||||
EnvironmentFile=/etc/coulobre/panel.env
|
||||
WorkingDirectory=/opt/coulobre
|
||||
UMask=0077
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[Service]
|
||||
StateDirectory=coulobre-panel-imports
|
||||
StateDirectoryMode=0700
|
||||
+5
-3
@@ -1534,9 +1534,11 @@ not modify or promote the live site.
|
||||
|
||||
### Import WordPress from a ZIP or TAR export
|
||||
|
||||
New installer-managed panels already have a private WordPress upload inbox.
|
||||
APT and web upgrades preserve the installed panel unit. If you are enabling
|
||||
imports on an upgraded panel and the unit does not list
|
||||
New installer-managed panels have a private upload inbox for WordPress and
|
||||
DirectAdmin imports. Starting with Core 1.10, APT upgrades supply the inbox
|
||||
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.service`, add the inbox with `sudo systemctl edit
|
||||
coulobre-panel.service`:
|
||||
|
||||
+5
-3
@@ -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
|
||||
slots when restoring more than one site.
|
||||
The destination can be a new hosting account or an existing empty account
|
||||
whose primary domain exactly matches. Remove any existing starter page
|
||||
before restoring website files. Existing DNS can be left in place if you
|
||||
do not select DNS import. New accounts do not include a new customer login.
|
||||
whose primary domain exactly matches. A document root containing only an
|
||||
unchanged Coulobre starter page counts as empty. A modified starter page
|
||||
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.
|
||||
|
||||
The selected component types apply to supported content across the selected
|
||||
|
||||
+24
-1
@@ -93,7 +93,9 @@ heading, help, fields, and actions should share a left edge.
|
||||
workflow. Keep the final destructive confirmation visually distinct.
|
||||
- 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
|
||||
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
|
||||
them vertically within the row and allow labels to wrap instead of
|
||||
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>
|
||||
```
|
||||
|
||||
### 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
|
||||
|
||||
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
|
||||
estimates explicitly. Distinguish the full source inventory from work
|
||||
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
|
||||
them outside auto-refreshing status regions. State explicitly which choices
|
||||
affect the destination, which are skipped and whether failures can leave
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "coulobre-panel"
|
||||
version = "1.9.0"
|
||||
version = "1.10.0"
|
||||
description = "A web hosting control panel for hosting providers and resellers."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
"""Stage and inspect DirectAdmin archives for operator approval."""
|
||||
|
||||
import errno
|
||||
import fcntl
|
||||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
import stat
|
||||
from datetime import timedelta
|
||||
@@ -146,9 +148,19 @@ def register_upload(upload, actor):
|
||||
except Exception:
|
||||
path.unlink(missing_ok=True)
|
||||
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(
|
||||
"Could not stage the archive. Check server storage."
|
||||
f"Could not stage the archive. {detail}"
|
||||
) from None
|
||||
return job
|
||||
|
||||
@@ -540,7 +552,10 @@ def confirm_import(job_id, actor, selection):
|
||||
validate_extra_domains(selection, account, job.report)
|
||||
plan = plan_for_import(account, selection)
|
||||
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.confirmed_by = actor
|
||||
job.started_at = None
|
||||
|
||||
@@ -271,13 +271,20 @@ def restore_components(job):
|
||||
f"{item['label']} is no longer provisioned."
|
||||
)
|
||||
if item["kind"] != "mail" or item["messages"]:
|
||||
restore_directadmin_component(
|
||||
receipt = restore_directadmin_component(
|
||||
item["kind"],
|
||||
destination_spec(job, item),
|
||||
archive_path(job.pk),
|
||||
source=item.get("source", ""),
|
||||
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"] = (
|
||||
"Mailbox configured (no source messages)"
|
||||
if item["kind"] == "mail" and not item["messages"]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from django import forms
|
||||
from django.contrib import messages
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.utils import timezone
|
||||
@@ -37,6 +38,8 @@ class DirectAdminSelectionForm(forms.Form):
|
||||
)
|
||||
target = forms.ChoiceField(
|
||||
label="Destination",
|
||||
widget=forms.RadioSelect,
|
||||
initial="new",
|
||||
choices=(
|
||||
("new", "Create a hosting account"),
|
||||
("existing", "Use the matching empty hosting account"),
|
||||
@@ -78,6 +81,13 @@ class DirectAdminSelectionForm(forms.Form):
|
||||
def __init__(self, report, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
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 = [
|
||||
(entry["name"], entry["name"]) for entry in report["domains"]
|
||||
]
|
||||
@@ -131,7 +141,11 @@ class DirectAdminImportView(OperatorOnlyMixin, OperatorAuthorization, View):
|
||||
except ValidationError as error:
|
||||
form.add_error("archive", error)
|
||||
else:
|
||||
messages.success(request, "DirectAdmin preflight queued.")
|
||||
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)
|
||||
|
||||
job = get_object_or_404(DirectAdminWebImport, pk=pk)
|
||||
@@ -146,6 +160,7 @@ class DirectAdminImportView(OperatorOnlyMixin, OperatorAuthorization, View):
|
||||
report={},
|
||||
):
|
||||
archive_path(pk).unlink(missing_ok=True)
|
||||
messages.info(request, "DirectAdmin upload discarded.")
|
||||
return redirect("panel:directadmin_import", pk=pk)
|
||||
form = DirectAdminSelectionForm(job.report, request.POST)
|
||||
if form.is_valid():
|
||||
@@ -154,7 +169,11 @@ class DirectAdminImportView(OperatorOnlyMixin, OperatorAuthorization, View):
|
||||
except ValidationError as error:
|
||||
form.add_error(None, error)
|
||||
else:
|
||||
messages.success(request, "DirectAdmin import queued.")
|
||||
return redirect("panel:directadmin_import", pk=pk)
|
||||
messages.error(
|
||||
request, "Import not queued. Review the highlighted details."
|
||||
)
|
||||
return self.page(job, form, status=400)
|
||||
|
||||
def page(self, job=None, form=None, status=200):
|
||||
@@ -163,12 +182,24 @@ class DirectAdminImportView(OperatorOnlyMixin, OperatorAuthorization, View):
|
||||
form = DirectAdminArchiveForm()
|
||||
elif job.state == "review" and job.expires_at > timezone.now():
|
||||
form = DirectAdminSelectionForm(job.report)
|
||||
components = set(job.selection.get("components", ())) if job else set()
|
||||
choices = DirectAdminSelectionForm.base_fields["components"].choices
|
||||
return render(
|
||||
self.request,
|
||||
self.template_name,
|
||||
{
|
||||
"job": job,
|
||||
"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,
|
||||
"recent": DirectAdminWebImport.objects.select_related(
|
||||
"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]")) {
|
||||
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) {
|
||||
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; });
|
||||
});
|
||||
}
|
||||
@@ -719,16 +719,13 @@ h3, h4, h5, h6 {
|
||||
flex: 1 1 25rem;
|
||||
}
|
||||
|
||||
.account-identity {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 0.15rem 0.65rem;
|
||||
.account-identity, .cell-primary-domain {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.account-identity > * {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
th.cell-primary-domain, td.cell-primary-domain {
|
||||
text-align: end;
|
||||
width: 22%;
|
||||
}
|
||||
|
||||
.account-heading-meta {
|
||||
@@ -838,6 +835,7 @@ input::placeholder {
|
||||
}
|
||||
|
||||
.table-scroll {
|
||||
position: relative;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
@@ -1595,3 +1593,50 @@ fieldset > div:has(> div > label > input:is([type="checkbox"], [type="radio"]))
|
||||
min-inline-size: 0;
|
||||
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>
|
||||
{% endif %}
|
||||
</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>
|
||||
{% 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>
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
<div class="account-identity">
|
||||
<a class="record-link" href="{{ account_url }}">{{ name }}</a>
|
||||
{% if primary_domain|lower != name|lower %}<span class="domain muted">{{ primary_domain }}</span>{% endif %}
|
||||
</div>
|
||||
<div class="account-identity"><a class="record-link" href="{{ account_url }}">{{ name }}</a></div>
|
||||
@@ -43,7 +43,7 @@
|
||||
<tr>
|
||||
<th scope="col">Account</th>
|
||||
{% 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_tenant or perms.hosting.view_hostingplan %}<th scope="col">Hosting package</th>{% endif %}
|
||||
<th scope="col" class="cell-date">Added</th>
|
||||
@@ -53,7 +53,7 @@
|
||||
{% for account in accounts %}
|
||||
<tr>
|
||||
<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 %}
|
||||
<div class="table-actions">
|
||||
{% if show_customer_website_link %}<a href="{{ account.get_absolute_url }}#websites">Websites</a>{% endif %}
|
||||
@@ -63,6 +63,7 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
{% 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>
|
||||
{% 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 %}
|
||||
|
||||
@@ -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>
|
||||
{% csrf_token %}
|
||||
{{ 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>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
@@ -93,10 +93,14 @@
|
||||
</section>
|
||||
{% endif %}
|
||||
{% 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 %}
|
||||
</main>
|
||||
</div>
|
||||
<script src="{% panel_asset 'hosting/panel-navigation.js' %}" defer></script>
|
||||
<script src="{% panel_asset 'hosting/panel-notifications.js' %}" defer></script>
|
||||
{% block extra_scripts %}{% endblock %}
|
||||
{% else %}
|
||||
{% block public_content %}{% endblock %}
|
||||
|
||||
@@ -32,23 +32,24 @@
|
||||
<section class="surface" aria-label="Cluster hosting account list">
|
||||
<div class="table-scroll">
|
||||
<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 %}
|
||||
{% if not page.unavailable %}
|
||||
<tbody>
|
||||
{% for account in page.accounts %}
|
||||
<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>
|
||||
{% include "hosting/account_primary_domain.html" with name=account.name primary_domain=account.primary_domain only %}
|
||||
<td>{% include "hosting/account_status.html" %}</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<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>
|
||||
{% endfor %}
|
||||
{% 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 %}
|
||||
</tbody>
|
||||
{% endif %}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
{% if may_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>
|
||||
<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>
|
||||
{% 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">
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<details class="surface editor-surface"{% if upload_form.errors %} open{% endif %}>
|
||||
<summary>Upload certificate</summary>
|
||||
<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>
|
||||
</details>
|
||||
{% 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>
|
||||
{% if enabled %}
|
||||
<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>
|
||||
{% endif %}
|
||||
</section>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<section class="surface editor-surface">
|
||||
<h2>Add {% if kind == 'domain' %}domain{% else %}site{% endif %} redirect</h2>
|
||||
<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>
|
||||
</section>
|
||||
{% else %}<p class="notice">Activate a website or an alias before adding redirects.</p>{% endif %}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</table></div></section>
|
||||
<section class="surface editor-surface">
|
||||
<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 class="surface editor-surface" data-live-status="sql-export">
|
||||
<h2>SQL export</h2>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
{% 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 page_title %}DirectAdmin import{% endblock %}
|
||||
@@ -9,23 +14,35 @@
|
||||
|
||||
{% block page_content %}
|
||||
{% if not job %}
|
||||
<form class="surface editor-surface" method="post" enctype="multipart/form-data">
|
||||
{% 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>
|
||||
{{ form.as_div }}
|
||||
<div class="form-actions"><button type="submit">Run preflight</button></div>
|
||||
</form>
|
||||
<section class="surface editor-surface" aria-labelledby="directadmin-upload">
|
||||
<form class="editor" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<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 }}
|
||||
<div class="form-actions"><button class="button primary" type="submit">Run preflight</button></div>
|
||||
</form>
|
||||
</section>
|
||||
{% if recent %}
|
||||
<section class="surface" aria-labelledby="directadmin-recent">
|
||||
<header class="section-heading"><h2 id="directadmin-recent">Recent imports</h2></header>
|
||||
<div class="table-scroll">
|
||||
<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 %}
|
||||
<tr>
|
||||
<th scope="row"><a href="{% url 'panel:directadmin_import' previous.pk %}">{{ previous.requested_at|date:"j M Y, H:i T" }}</a></th>
|
||||
<td>{{ previous.account|default:"Not selected" }}</td>
|
||||
<th scope="row">{{ previous.requested_at|date:"j M Y, H:i T" }}</th>
|
||||
<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><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>
|
||||
{% endfor %}</tbody>
|
||||
</table>
|
||||
@@ -34,7 +51,7 @@
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<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">
|
||||
<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 %}
|
||||
@@ -42,6 +59,9 @@
|
||||
<a class="button compact" href="{% url 'panel:directadmin_import' job.pk %}#directadmin-review">Review preflight</a>
|
||||
{% endif %}
|
||||
</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 %}
|
||||
<p class="section-text" role="status" data-live-pending>
|
||||
{% 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 %}
|
||||
{% 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>
|
||||
{% 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 %}
|
||||
{% if job.work %}
|
||||
<div class="table-scroll">
|
||||
<table>
|
||||
<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 %}
|
||||
<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>
|
||||
</table>
|
||||
</div>
|
||||
{% 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>
|
||||
{% if job.state == "review" and form %}
|
||||
<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>
|
||||
{% for domain in job.report.domains %}
|
||||
<div class="section-text">
|
||||
<h3>{{ domain.name }}</h3>
|
||||
<h3 class="domain">{{ domain.name }}</h3>
|
||||
<ul>
|
||||
{% 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 %}
|
||||
{% 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 %}
|
||||
{% if domain.unrecognized_mailbox_entries %}<li>{{ domain.unrecognized_mailbox_entries }} unrecognized mailbox entries will not be imported.</li>{% endif %}
|
||||
{% 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>
|
||||
{% else %}<li>No DNS zone found.</li>{% endif %}
|
||||
{% if domain.destination_problem %}<li>{{ domain.destination_problem }}</li>
|
||||
@@ -104,21 +128,59 @@
|
||||
{% 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.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>
|
||||
</section>
|
||||
{% 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 %}
|
||||
<h2>Choose what to import</h2>
|
||||
<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>
|
||||
<p>Importing mail activates the destination mailboxes on this installation even before public DNS changes.</p>
|
||||
{{ form.as_div }}
|
||||
<header>
|
||||
<h2 id="directadmin-review-title">Choose what to import</h2>
|
||||
<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>
|
||||
</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">
|
||||
<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>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<form method="post" class="editor">
|
||||
{% csrf_token %}
|
||||
{{ 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>
|
||||
</section>
|
||||
<section class="surface" aria-label="Template preview">
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
{% if topology.problem %}<p class="notice">{{ topology.problem }}</p>{% endif %}
|
||||
</section>
|
||||
<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>
|
||||
{% 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>
|
||||
{% endif %}
|
||||
<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>
|
||||
{% elif page == 'dns' %}
|
||||
{% if zone %}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
{% block page_content %}
|
||||
<section class="surface editor-surface">
|
||||
<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>
|
||||
</section>
|
||||
{% if search %}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<form class="editor" method="post" action="{% url 'panel:mail_diagnostics' %}">
|
||||
{% csrf_token %}
|
||||
{{ 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>
|
||||
</section>
|
||||
{% endif %}
|
||||
@@ -47,7 +47,7 @@
|
||||
{% csrf_token %}
|
||||
{% if errors %}<ul class="errorlist" role="alert">{% for error in errors %}<li>{{ error }}</li>{% endfor %}</ul>{% endif %}
|
||||
{{ 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>
|
||||
</section>
|
||||
{% if report %}
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
{% endif %}
|
||||
{% if problem %}<p class="error" role="alert">{{ problem }}</p>{% endif %}
|
||||
{% 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 %}
|
||||
{% 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 %}
|
||||
{% if job.active %}
|
||||
<h2>Incoming mail DNS</h2>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
{% block page_content %}
|
||||
<div class="live-sections">
|
||||
{% 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">
|
||||
<h2 id="import-progress">Import progress</h2>
|
||||
{% if job.finished_at %}
|
||||
@@ -71,7 +71,7 @@
|
||||
{% endif %}
|
||||
|
||||
{% 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>
|
||||
{% if not preview.finished_at %}
|
||||
<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 %}
|
||||
<section class="surface editor-surface">
|
||||
<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>
|
||||
{% endif %}
|
||||
{% 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">
|
||||
{% csrf_token %}
|
||||
{{ 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>
|
||||
</section>
|
||||
<section class="surface">
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<form class="editor" method="post">
|
||||
{% csrf_token %}
|
||||
{{ 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>
|
||||
</section>
|
||||
<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>
|
||||
<form method="post" class="editor">{% csrf_token %}
|
||||
<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>
|
||||
</section>
|
||||
<section class="surface editor-surface">
|
||||
<h2>Schedule</h2>
|
||||
<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>
|
||||
</section>
|
||||
{% else %}<p class="notice">Enable system backups and the local operator worker on this server.</p>{% endif %}
|
||||
|
||||
@@ -25,13 +25,13 @@
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="operation" value="upload">
|
||||
{{ 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 class="editor" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="operation" value="mkdir">
|
||||
{{ 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>
|
||||
</div>
|
||||
{% if entries %}
|
||||
|
||||
@@ -19,10 +19,5 @@
|
||||
{% block workspace_selector %}{% include "hosting/workspace_account_selector.html" %}{% endblock %}
|
||||
{% block page_context %}{% endblock %}
|
||||
</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 %}
|
||||
{% endblock %}
|
||||
@@ -139,7 +139,7 @@ class DirectAdminWebImportTests(TestCase):
|
||||
response = self.client.get(url)
|
||||
self.assertContains(response, "source_main")
|
||||
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.assertNotContains(response, "should-never-be-stored")
|
||||
self.assertNotIn("should-never-be-stored", str(job.report))
|
||||
@@ -156,7 +156,16 @@ class DirectAdminWebImportTests(TestCase):
|
||||
name="Destination", primary_domain=DOMAIN
|
||||
)
|
||||
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")
|
||||
job.refresh_from_db()
|
||||
self.assertEqual(job.state, "provisioning", job.problem)
|
||||
@@ -170,6 +179,20 @@ class DirectAdminWebImportTests(TestCase):
|
||||
self.assertFalse(archive_path(job.pk).exists())
|
||||
self.assertFalse(HostingDatabase.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):
|
||||
account = HostingAccount.objects.create(
|
||||
|
||||
@@ -123,5 +123,10 @@ class PackageWorkflowTests(TestCase):
|
||||
)
|
||||
response = self.client.get(reverse("panel:accounts"))
|
||||
self.assertContains(response, 'class="account-identity"', count=2)
|
||||
self.assertNotContains(response, ">same.example</span>")
|
||||
self.assertContains(response, ">different.example</span>")
|
||||
self.assertContains(response, "Same as account name", count=1)
|
||||
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 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
|
||||
|
||||
|
||||
@@ -146,6 +147,59 @@ class DirectAdminWebRestoreTests(SimpleTestCase):
|
||||
self.assertEqual(list(self.public.iterdir()), [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):
|
||||
existing = self.public / "new.txt"
|
||||
|
||||
|
||||
@@ -81,6 +81,19 @@ def starter_page_matches(page):
|
||||
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():
|
||||
return (
|
||||
max(
|
||||
|
||||
@@ -2,10 +2,23 @@ import errno
|
||||
import fcntl
|
||||
import os
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
from tempfile import TemporaryDirectory, mkdtemp
|
||||
|
||||
from . import web_node_apply
|
||||
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):
|
||||
@@ -17,8 +30,7 @@ def check_website_empty(site):
|
||||
fcntl.flock(lock, fcntl.LOCK_SH)
|
||||
web_node_apply.check_reservation(site)
|
||||
public, _, _ = web_node_apply.site_storage(site)
|
||||
if any(public.iterdir()):
|
||||
raise ValueError("Restore requires an empty document root.")
|
||||
starter_to_replace(public)
|
||||
|
||||
|
||||
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)
|
||||
uid, gid = web_node_apply.check_installation(site, paths)
|
||||
public = paths.account / "public"
|
||||
if any(public.iterdir()):
|
||||
raise ValueError("Restore requires an empty document root.")
|
||||
starter_to_replace(public)
|
||||
|
||||
with TemporaryDirectory(
|
||||
dir=paths.account, prefix=".directadmin-restore-"
|
||||
@@ -55,7 +66,7 @@ def restore_website(site, backup, source_root):
|
||||
on_copy=remember_private_entry,
|
||||
)
|
||||
prepare_web_permissions(staged, uid, gid, private)
|
||||
publish_empty_webroot(staged, public)
|
||||
publish_directadmin_webroot(staged, public)
|
||||
|
||||
return {
|
||||
**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):
|
||||
try:
|
||||
# A rename can replace the live root while it is empty.
|
||||
|
||||
@@ -140,24 +140,11 @@ def wordpress_version(cli, root):
|
||||
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):
|
||||
entries = os.listdir(public)
|
||||
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(
|
||||
"Use an empty website or the original Coulobre starter page."
|
||||
@@ -174,7 +161,7 @@ def publish_wordpress(staged, public):
|
||||
saved = staged.parent / "previous-index"
|
||||
os.replace(index, saved)
|
||||
try:
|
||||
if not is_starter_page(saved):
|
||||
if not web.is_starter_page(saved):
|
||||
raise ValueError("The starter page changed during setup.")
|
||||
publish_empty_webroot(staged, public)
|
||||
except (OSError, ValueError, KeyboardInterrupt):
|
||||
|
||||
@@ -81,6 +81,7 @@ def build_package(source, wheel, ref, output):
|
||||
units = root / "usr/lib/systemd/system"
|
||||
units.mkdir(parents=True)
|
||||
for name in (
|
||||
"coulobre-panel.service.d/import-storage.conf",
|
||||
"coulobre-directadmin-import-worker.service",
|
||||
"coulobre-directadmin-restore.socket",
|
||||
"coulobre-directadmin-restore@.service",
|
||||
|
||||
Reference in new issue
Block a user