from __future__ import annotations from ..security import dashboard_csrf_token from ..services.ddns import DdnsService from .components import ( _code_window, _copy_menu, _copy_row, _fritzbox_fields, _manual_update_commands, _manual_update_panel, _one_time_secret_notice, _secret_notice, ) from .html_utils import SafeHtml, attr, escape, trusted def _linux_installer_section(base_url: str) -> SafeHtml: base_url = base_url.rstrip("/") system_install = f"curl -fsSL {base_url}/install.sh | sudo sh" system_uninstall = f"curl -fsSL {base_url}/uninstall.sh | sudo sh" return trusted( f"""

Linux cron updater

Linux updater.

Run this on a Linux box that is always on. It creates and registers a hostname, installs the updater, schedules cron, and prints your private dashboard link. Works with Debian, Ubuntu, Fedora, Arch, Alpine, and Proxmox hosts.

Install

Sets up the updater and cron job.

{_code_window(system_install, copy_label="install command", class_name="mt-3")}

Uninstall

Stops the updater and leaves private URLs on disk.

{_code_window(system_uninstall, copy_label="uninstall command", class_name="mt-3")}
""" ) def _created_hostname_panel(service: DdnsService, created_account: dict[str, str] | None, request_ip: str | None = None) -> SafeHtml: if not created_account: return trusted("") hostname = created_account["hostname"] update_url = service.fritz_update_url(created_account) management_url = service.dashboard_url(created_account) registration_url = service.registration_url(created_account) csrf_token = dashboard_csrf_token(created_account["management_slug"], created_account) management_slug = attr(created_account["management_slug"]) cname_record = f"your-subdomain.example.com. CNAME {hostname}." fritzbox_fields = _fritzbox_fields(update_url, hostname, management_url) manual_commands = _manual_update_commands(update_url, request_ip) return trusted( f"""

Pending setup

{escape(hostname)}

Copy these values now. Then register the hostname so router updates can start. Unregistered setups are removed after 24 hours.

{_one_time_secret_notice()} {_secret_notice(include_registration=True)}
{_copy_menu("Copy setup values", [("Router fields", fritzbox_fields), ("Register URL", registration_url), ("CNAME", cname_record)])}
{_copy_row("Update-URL:", update_url, "Secret")} {_copy_row("Register URL:", registration_url, "Secret")} {_copy_row("Domainnamen:", hostname, "Public")} {_copy_row("CNAME target:", hostname, "Public")} {_copy_row("Private dashboard:", management_url, "Secret")}
{_manual_update_panel(manual_commands)}
""" )