From 75a3ce5584ed4969639adb2e6feff18e2c022ded Mon Sep 17 00:00:00 2001 From: Peter van Arkel Date: Thu, 3 Dec 2026 13:01:23 +0100 Subject: [PATCH 1/2] Show a starter page for newly activated empty websites --- docs/deployment.md | 9 +++- .../hosting/account_administration.py | 12 +++++ src/coulobre/hosting/account_setup.py | 2 +- .../hosting/independent_website_views.py | 6 +++ src/coulobre/hosting/independent_websites.py | 8 +++- .../0092_independent_website_starter_page.py | 17 +++++++ src/coulobre/hosting/models.py | 1 + src/coulobre/hosting/php_settings.py | 3 +- .../templates/hosting/plan_detail.html | 3 +- .../hosting/test_independent_websites.py | 5 +- src/coulobre/hosting/test_php_settings.py | 4 +- src/coulobre/hosting/test_web_activation.py | 15 +++++- src/coulobre/hosting/test_wordpress.py | 4 +- src/coulobre/hosting/views.py | 6 ++- src/coulobre/test_website_starter.py | 47 +++++++++++++++++++ src/coulobre/web_node_apply.py | 13 ++++- src/coulobre/wordpress_node.py | 8 ++-- 17 files changed, 147 insertions(+), 16 deletions(-) create mode 100644 src/coulobre/hosting/migrations/0092_independent_website_starter_page.py create mode 100644 src/coulobre/test_website_starter.py diff --git a/docs/deployment.md b/docs/deployment.md index b8a5782..d2f1f48 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -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 diff --git a/src/coulobre/hosting/account_administration.py b/src/coulobre/hosting/account_administration.py index af9311a..16ea7ce 100644 --- a/src/coulobre/hosting/account_administration.py +++ b/src/coulobre/hosting/account_administration.py @@ -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"), diff --git a/src/coulobre/hosting/account_setup.py b/src/coulobre/hosting/account_setup.py index cbceeca..5b5bdc6 100644 --- a/src/coulobre/hosting/account_setup.py +++ b/src/coulobre/hosting/account_setup.py @@ -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( diff --git a/src/coulobre/hosting/independent_website_views.py b/src/coulobre/hosting/independent_website_views.py index 8ef14be..26a1683 100644 --- a/src/coulobre/hosting/independent_website_views.py +++ b/src/coulobre/hosting/independent_website_views.py @@ -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 diff --git a/src/coulobre/hosting/independent_websites.py b/src/coulobre/hosting/independent_websites.py index 57f0375..39bbd46 100644 --- a/src/coulobre/hosting/independent_websites.py +++ b/src/coulobre/hosting/independent_websites.py @@ -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: diff --git a/src/coulobre/hosting/migrations/0092_independent_website_starter_page.py b/src/coulobre/hosting/migrations/0092_independent_website_starter_page.py new file mode 100644 index 0000000..0b01478 --- /dev/null +++ b/src/coulobre/hosting/migrations/0092_independent_website_starter_page.py @@ -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), + ), + ] diff --git a/src/coulobre/hosting/models.py b/src/coulobre/hosting/models.py index bde7460..7f1f597 100644 --- a/src/coulobre/hosting/models.py +++ b/src/coulobre/hosting/models.py @@ -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) diff --git a/src/coulobre/hosting/php_settings.py b/src/coulobre/hosting/php_settings.py index ea2dae8..7a2c65f 100644 --- a/src/coulobre/hosting/php_settings.py +++ b/src/coulobre/hosting/php_settings.py @@ -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) diff --git a/src/coulobre/hosting/templates/hosting/plan_detail.html b/src/coulobre/hosting/templates/hosting/plan_detail.html index f246e4d..0cf765e 100644 --- a/src/coulobre/hosting/templates/hosting/plan_detail.html +++ b/src/coulobre/hosting/templates/hosting/plan_detail.html @@ -58,8 +58,9 @@ {% if local_activation_enabled and plan.can_export %} {% if not activation or activation.state == "failed" %} -
+ {% csrf_token %} + {% if not activation %}{% endif %}
{% endif %} diff --git a/src/coulobre/hosting/test_independent_websites.py b/src/coulobre/hosting/test_independent_websites.py index 37fe61f..24c0504 100644 --- a/src/coulobre/hosting/test_independent_websites.py +++ b/src/coulobre/hosting/test_independent_websites.py @@ -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() diff --git a/src/coulobre/hosting/test_php_settings.py b/src/coulobre/hosting/test_php_settings.py index b734304..b3966a6 100644 --- a/src/coulobre/hosting/test_php_settings.py +++ b/src/coulobre/hosting/test_php_settings.py @@ -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, diff --git a/src/coulobre/hosting/test_web_activation.py b/src/coulobre/hosting/test_web_activation.py index c699594..87bbc8b 100644 --- a/src/coulobre/hosting/test_web_activation.py +++ b/src/coulobre/hosting/test_web_activation.py @@ -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, ): diff --git a/src/coulobre/hosting/test_wordpress.py b/src/coulobre/hosting/test_wordpress.py index 37a1119..cc770da 100644 --- a/src/coulobre/hosting/test_wordpress.py +++ b/src/coulobre/hosting/test_wordpress.py @@ -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( diff --git a/src/coulobre/hosting/views.py b/src/coulobre/hosting/views.py index 0494e51..0534bdd 100644 --- a/src/coulobre/hosting/views.py +++ b/src/coulobre/hosting/views.py @@ -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) diff --git a/src/coulobre/test_website_starter.py b/src/coulobre/test_website_starter.py new file mode 100644 index 0000000..fe9e2fa --- /dev/null +++ b/src/coulobre/test_website_starter.py @@ -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()) diff --git a/src/coulobre/web_node_apply.py b/src/coulobre/web_node_apply.py index d745c06..d3ed8c9 100644 --- a/src/coulobre/web_node_apply.py +++ b/src/coulobre/web_node_apply.py @@ -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 = ( '' "Website ready

Your website is ready

" "

Upload your website files to replace this page.

" "\n" ) +STARTER_PAGE = ( + '' + '' + '' + "Website ready
" + "

Your website is ready

" + "

Hosting is set up. The site owner has not published " + "the website yet.

" + "

Hosted with Coulobre Panel.

" + "
\n" +) @dataclass(frozen=True) diff --git a/src/coulobre/wordpress_node.py b/src/coulobre/wordpress_node.py index 72fbb93..ee759d8 100644 --- a/src/coulobre/wordpress_node.py +++ b/src/coulobre/wordpress_node.py @@ -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): From 445f41f15dfe6252d7a04cae4e41f84c0165c785 Mon Sep 17 00:00:00 2001 From: Peter van Arkel Date: Thu, 3 Dec 2026 13:01:23 +0100 Subject: [PATCH 2/2] Prepare Coulobre Core 1.3.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 07df1e2..8c65308 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"