Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd4fda926a | ||
|
|
445f41f15d | ||
|
|
75a3ce5584 |
No files matched your search
+7
-2
@@ -1139,8 +1139,13 @@ commas. If a nameserver is inside a hosted zone, the zone must include
|
||||
its address records. Apply the environment changes to the panel workers.
|
||||
|
||||
When creating an account, select the services it should use. The website
|
||||
option queues the Apache configuration. A fresh, empty web root can receive
|
||||
a starter page. Coulobre DNS can publish the apex, `www`, and a wildcard
|
||||
option queues the Apache configuration. A new managed website with an empty
|
||||
web root gets a neutral starter page unless you skip it during setup or
|
||||
activation. Already provisioned sites are not changed by an upgrade, and
|
||||
the starter page never replaces existing files. Replace or remove the
|
||||
generated `index.html` when you publish manually. Managed WordPress
|
||||
installation can replace an unmodified starter page automatically.
|
||||
Coulobre DNS can publish the apex, `www`, and a wildcard
|
||||
record. The panel provides copyable web records for third-party DNS.
|
||||
When [managed mail DNS](#check-and-provision-mail-dns) is enabled, the
|
||||
zone includes MX, SPF and a monitoring DMARC policy. Provisioning the
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "coulobre-panel"
|
||||
version = "1.2.1"
|
||||
version = "1.3.0"
|
||||
description = "A web hosting control panel for hosting providers and resellers."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
@@ -65,6 +65,11 @@ class CustomerOnboardingForm(InviteLoginForm):
|
||||
setup_info_mailbox = forms.BooleanField(
|
||||
required=False, initial=True, label="Create an info@ mailbox"
|
||||
)
|
||||
skip_starter_page = forms.BooleanField(
|
||||
label="Skip the starter page",
|
||||
help_text="An empty web root otherwise shows a Coulobre starter page.",
|
||||
required=False,
|
||||
)
|
||||
send_invitation = forms.BooleanField(
|
||||
required=False, initial=True, label="Send a welcome email"
|
||||
)
|
||||
@@ -116,6 +121,10 @@ class CustomerOnboardingForm(InviteLoginForm):
|
||||
)
|
||||
if self.fields["manage_mail"].disabled:
|
||||
del self.fields["setup_info_mailbox"]
|
||||
if not capabilities["website"] or not panel_feature_allowed(
|
||||
"LOCAL_WEB_ACTIVATION"
|
||||
):
|
||||
del self.fields["skip_starter_page"]
|
||||
|
||||
def clean_primary_domain(self):
|
||||
try:
|
||||
@@ -245,6 +254,9 @@ class CustomerOnboardingView(UserPassesTestMixin, FormView):
|
||||
{
|
||||
"setup_website": capabilities["website"]
|
||||
and panel_feature_allowed("LOCAL_WEB_ACTIVATION"),
|
||||
"setup_landing_page": not data.get(
|
||||
"skip_starter_page"
|
||||
),
|
||||
"setup_dns": data["manage_dns"],
|
||||
"setup_email": data["manage_mail"],
|
||||
"setup_info_mailbox": data.get("setup_info_mailbox"),
|
||||
|
||||
@@ -58,7 +58,7 @@ def setup_new_account(account, options):
|
||||
WebActivation.objects.create(
|
||||
plan=plan,
|
||||
php_settings=php.manifest() if php.has_overrides else None,
|
||||
starter_page=options.get("setup_landing_page", False),
|
||||
starter_page=options.get("setup_landing_page", True),
|
||||
)
|
||||
if add_www:
|
||||
reservation, created = WebsiteDomain.objects.get_or_create(
|
||||
|
||||
@@ -36,6 +36,11 @@ class WebsiteCreateForm(forms.Form):
|
||||
max_length=5,
|
||||
help_text="Leave blank to use the newest allowed stable series.",
|
||||
)
|
||||
skip_starter_page = forms.BooleanField(
|
||||
label="Skip the starter page",
|
||||
help_text="An empty web root otherwise shows a Coulobre starter page.",
|
||||
required=False,
|
||||
)
|
||||
|
||||
def clean_domain(self):
|
||||
try:
|
||||
@@ -118,6 +123,7 @@ class IndependentWebsiteCreate(IndependentWebsiteEditor):
|
||||
domain,
|
||||
form.cleaned_data["php_version"],
|
||||
self.request.user,
|
||||
starter_page=not form.cleaned_data["skip_starter_page"],
|
||||
)
|
||||
except HostingAccount.DoesNotExist as error:
|
||||
raise Http404 from error
|
||||
|
||||
@@ -82,7 +82,7 @@ def check_version(account, version):
|
||||
|
||||
|
||||
@transaction.atomic
|
||||
def create_website(account_id, domain, version, actor):
|
||||
def create_website(account_id, domain, version, actor, *, starter_page=True):
|
||||
account = lock_hosting_account(account_id, customer_id=None)
|
||||
check_actor(account, actor)
|
||||
require_active_services(account)
|
||||
@@ -102,7 +102,9 @@ def create_website(account_id, domain, version, actor):
|
||||
raise ValidationError({"domain": "This domain is unavailable."})
|
||||
reservation = WebsiteDomain.objects.create(account=account, domain=domain)
|
||||
return IndependentWebsite.objects.create(
|
||||
reservation=reservation, requested_php_version=version
|
||||
reservation=reservation,
|
||||
requested_php_version=version,
|
||||
starter_page=starter_page,
|
||||
)
|
||||
|
||||
|
||||
@@ -184,10 +186,12 @@ def apply_website_operation(website):
|
||||
raise ValueError(" ".join(error.messages)) from None
|
||||
if operation == Operation.ACTIVATE:
|
||||
plan = account.hosting_plan
|
||||
starter = {"starter_page": True} if website.starter_page else {}
|
||||
options, version = activate_local_site(
|
||||
site,
|
||||
plan.get_php_settings() if plan else PhpPoolSettings(),
|
||||
(requested,) if requested else allowed_versions(account),
|
||||
**starter,
|
||||
)
|
||||
limit = plan.website_storage_limit_mib if plan else None
|
||||
if limit is not None:
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
# Generated by Django 5.2.19 on 2026-12-03 11:57
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("hosting", "0091_panel_peer_account_inventory"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="independentwebsite",
|
||||
name="starter_page",
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@@ -1292,6 +1292,7 @@ class IndependentWebsite(ProvisioningJob):
|
||||
max_length=8, choices=Operation, default=Operation.ACTIVATE
|
||||
)
|
||||
activated = models.BooleanField(default=False)
|
||||
starter_page = models.BooleanField(default=False)
|
||||
https_enabled = models.BooleanField(default=False)
|
||||
suspended = models.BooleanField(default=False)
|
||||
retired_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
@@ -93,7 +93,7 @@ def last_applied_php_settings(account, job):
|
||||
|
||||
|
||||
@transaction.atomic
|
||||
def queue_web_activation(plan):
|
||||
def queue_web_activation(plan, *, starter_page=True):
|
||||
account = lock_hosting_account(plan.account_id, customer_id=None)
|
||||
require_active_services(account)
|
||||
activations = WebActivation.objects.filter(plan=plan)
|
||||
@@ -103,6 +103,7 @@ def queue_web_activation(plan):
|
||||
WebActivation.objects.create(
|
||||
plan=plan,
|
||||
php_settings=options.manifest() if options.has_overrides else None,
|
||||
starter_page=starter_page,
|
||||
)
|
||||
elif activation.problem:
|
||||
WebActivation.objects.requeue(activations)
|
||||
|
||||
@@ -58,8 +58,9 @@
|
||||
</div>
|
||||
{% if local_activation_enabled and plan.can_export %}
|
||||
{% if not activation or activation.state == "failed" %}
|
||||
<form method="post" action="{% url 'panel:plan_activate' plan.pk %}">
|
||||
<form class="form-actions" method="post" action="{% url 'panel:plan_activate' plan.pk %}">
|
||||
{% csrf_token %}
|
||||
{% if not activation %}<label><input type="checkbox" name="skip_starter_page"> Skip the starter page</label>{% endif %}
|
||||
<button class="button primary" type="submit">{% if activation %}Retry activation{% else %}Activate site{% endif %}</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
@@ -161,7 +161,10 @@ class IndependentWebsiteTests(TestCase):
|
||||
):
|
||||
provision_independent_website.run(website.pk)
|
||||
activate.assert_called_once_with(
|
||||
website.spec, self.plan.get_php_settings(), ("8.4",)
|
||||
website.spec,
|
||||
self.plan.get_php_settings(),
|
||||
("8.4",),
|
||||
starter_page=True,
|
||||
)
|
||||
quota.assert_called_once_with(website.spec, 200)
|
||||
website.refresh_from_db()
|
||||
|
||||
@@ -95,7 +95,9 @@ class PanelPhpSettingsTests(TestCase):
|
||||
return_value=(options, "8.5"),
|
||||
) as activate:
|
||||
activate_web_plan(job.pk)
|
||||
activate.assert_called_once_with(self.site, options, ())
|
||||
activate.assert_called_once_with(
|
||||
self.site, options, (), starter_page=True
|
||||
)
|
||||
self.assertContains(self.client.get(self.account_url), "256 MiB")
|
||||
self.assertEqual(
|
||||
self.client.get(self.url).context["form"].initial,
|
||||
|
||||
@@ -58,6 +58,7 @@ class WebActivationTests(TestCase):
|
||||
for _ in range(2):
|
||||
self.assertRedirects(self.client.post(self.url), self.detail)
|
||||
activation = WebActivation.objects.get(plan=self.plan)
|
||||
self.assertTrue(activation.starter_page)
|
||||
self.assertContains(self.client.get(self.detail), "Queued")
|
||||
with patch.object(activate_web_plan, "apply_async") as publish:
|
||||
dispatch_web_activations.run()
|
||||
@@ -73,13 +74,25 @@ class WebActivationTests(TestCase):
|
||||
activate_web_plan.run(activation.pk)
|
||||
activate_web_plan.run(activation.pk)
|
||||
apply.assert_called_once_with(
|
||||
WebSite(self.account.pk, "site.example"), PhpPoolSettings(), ()
|
||||
WebSite(self.account.pk, "site.example"),
|
||||
PhpPoolSettings(),
|
||||
(),
|
||||
starter_page=True,
|
||||
)
|
||||
self.assertContains(self.client.get(self.detail), "Configured")
|
||||
self.assertRedirects(self.client.post(self.url), self.detail)
|
||||
activation.refresh_from_db()
|
||||
self.assertEqual(activation.state, "configured")
|
||||
|
||||
def test_operator_can_opt_out_of_the_default_starter_page(self):
|
||||
self.assertRedirects(
|
||||
self.client.post(self.url, {"skip_starter_page": "on"}),
|
||||
self.detail,
|
||||
)
|
||||
self.assertFalse(
|
||||
WebActivation.objects.get(plan=self.plan).starter_page
|
||||
)
|
||||
|
||||
def test_tenants_and_operators_without_activation_permission_are_denied(
|
||||
self,
|
||||
):
|
||||
|
||||
@@ -15,7 +15,7 @@ from django.utils import timezone
|
||||
from coulobre.account_backup import MANIFEST_NAME, AccountBackup, manifest_text
|
||||
from coulobre.database_node import DatabaseSpec
|
||||
from coulobre.web_node import WebSite, parse_web_request
|
||||
from coulobre.web_node_apply import STARTER_PAGE
|
||||
from coulobre.web_node_apply import LEGACY_STARTER_PAGE, STARTER_PAGE
|
||||
from coulobre.wordpress import WordPressRequest
|
||||
from coulobre.wordpress_node import check_install_target, publish_wordpress
|
||||
from coulobre.wordpress_node_updates import (
|
||||
@@ -153,6 +153,8 @@ class InstallRequestTests(SimpleTestCase):
|
||||
check_install_target(public)
|
||||
self.assertEqual((stage / "index.php").read_text(), "prepared")
|
||||
index.unlink()
|
||||
index.write_text(LEGACY_STARTER_PAGE)
|
||||
check_install_target(public)
|
||||
index.write_text(STARTER_PAGE)
|
||||
with (
|
||||
patch(
|
||||
|
||||
@@ -311,6 +311,7 @@ class ExistingAccountSetup(
|
||||
form.fields["setup_landing_page"] = forms.BooleanField(
|
||||
label="Add a starter page if the web root is empty",
|
||||
required=False,
|
||||
initial=True,
|
||||
)
|
||||
return form
|
||||
|
||||
@@ -2921,7 +2922,10 @@ class RequestWebActivation(
|
||||
content_type="text/plain",
|
||||
)
|
||||
try:
|
||||
queue_web_activation(plan)
|
||||
queue_web_activation(
|
||||
plan,
|
||||
starter_page=request.POST.get("skip_starter_page") != "on",
|
||||
)
|
||||
except ValidationError as error:
|
||||
return provisioning_conflict(error)
|
||||
return redirect("panel:plan", pk=plan.pk)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
from unittest import TestCase
|
||||
|
||||
from .web_node_apply import STARTER_PAGE, install_starter_page
|
||||
|
||||
|
||||
class WebsiteStarterTests(TestCase):
|
||||
def setUp(self):
|
||||
self.root = Path(self.enterContext(TemporaryDirectory()))
|
||||
self.public = self.root / "public"
|
||||
self.public.mkdir()
|
||||
self.index = self.public / "index.html"
|
||||
|
||||
def install(self):
|
||||
install_starter_page(self.public, os.getuid(), os.getgid())
|
||||
|
||||
def test_empty_root_gets_a_neutral_page_only_once(self):
|
||||
self.install()
|
||||
self.assertEqual(self.index.read_text(), STARTER_PAGE)
|
||||
self.assertIn('name="robots" content="noindex"', STARTER_PAGE)
|
||||
self.assertEqual(self.index.stat().st_mode & 0o777, 0o644)
|
||||
self.index.write_text("Published customer site")
|
||||
self.install()
|
||||
self.assertEqual(self.index.read_text(), "Published customer site")
|
||||
|
||||
def test_php_content_and_hidden_files_prevent_creating_a_placeholder(self):
|
||||
for name in ("index.php", ".htaccess"):
|
||||
with self.subTest(name=name):
|
||||
content = self.public / name
|
||||
content.write_text("Existing customer content")
|
||||
self.install()
|
||||
self.assertFalse(self.index.exists())
|
||||
self.assertEqual(
|
||||
content.read_text(), "Existing customer content"
|
||||
)
|
||||
content.unlink()
|
||||
|
||||
def test_linked_document_root_is_not_written(self):
|
||||
self.public.rmdir()
|
||||
actual = self.root / "other"
|
||||
actual.mkdir()
|
||||
self.public.symlink_to(actual, target_is_directory=True)
|
||||
with self.assertRaises(OSError):
|
||||
self.install()
|
||||
self.assertFalse((actual / "index.html").exists())
|
||||
@@ -29,12 +29,23 @@ WEB_ROOT = Path("/srv/coulobre/web")
|
||||
APACHE_AVAILABLE = Path("/etc/apache2/sites-available")
|
||||
APACHE_ENABLED = Path("/etc/apache2/sites-enabled")
|
||||
SITE_SHELL = "/usr/sbin/nologin"
|
||||
STARTER_PAGE = (
|
||||
LEGACY_STARTER_PAGE = (
|
||||
'<!doctype html><html lang="en"><meta charset="utf-8">'
|
||||
"<title>Website ready</title><h1>Your website is ready</h1>"
|
||||
"<p>Upload your website files to replace this page.</p>"
|
||||
"</html>\n"
|
||||
)
|
||||
STARTER_PAGE = (
|
||||
'<!doctype html><html lang="en"><head><meta charset="utf-8">'
|
||||
'<meta name="viewport" content="width=device-width, initial-scale=1">'
|
||||
'<meta name="robots" content="noindex">'
|
||||
"<title>Website ready</title></head><body><main>"
|
||||
"<h1>Your website is ready</h1>"
|
||||
"<p>Hosting is set up. The site owner has not published "
|
||||
"the website yet.</p>"
|
||||
"<p>Hosted with Coulobre Panel.</p>"
|
||||
"</main></body></html>\n"
|
||||
)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
||||
@@ -147,10 +147,12 @@ def is_starter_page(index):
|
||||
)
|
||||
except OSError:
|
||||
return False
|
||||
expected = (web.STARTER_PAGE.encode(), web.LEGACY_STARTER_PAGE.encode())
|
||||
with os.fdopen(descriptor, "rb") as page:
|
||||
return stat.S_ISREG(os.fstat(page.fileno()).st_mode) and page.read(
|
||||
len(web.STARTER_PAGE) + 1
|
||||
) == web.STARTER_PAGE.encode("utf-8")
|
||||
return (
|
||||
stat.S_ISREG(os.fstat(page.fileno()).st_mode)
|
||||
and page.read(max(map(len, expected)) + 1) in expected
|
||||
)
|
||||
|
||||
|
||||
def check_install_target(public):
|
||||
|
||||
Reference in new issue
Block a user