from __future__ import annotations from ..ddns_service import DdnsService from .html_utils import SafeHtml, escape, trusted from .templates import ( _code_window, _copy_menu, _copy_row, _fritzbox_fields, _manual_update_commands, _manual_update_panel, _one_time_secret_notice, _secret_notice, ) def _linux_installer_section() -> SafeHtml: system_install = "curl -fsSL https://karldns.de/install.sh | sudo sh" system_uninstall = "curl -fsSL https://karldns.de/uninstall.sh | sudo sh" user_install = "curl -fsSL https://karldns.de/install.sh | sh -s -- --mode user" clean_uninstall = "curl -fsSL https://karldns.de/uninstall.sh | sh -s -- --mode user --delete-config" return trusted( f"""

Linux cron updater

Linux updater.

Run this on a Linux box that is always on. It creates a hostname, installs the updater, schedules it, and prints your private dashboard link.

Install

System install for most Linux servers.

{_code_window(system_install, copy_label="install command")}

Uninstall

Stops the updater and leaves your private URLs on disk.

{_code_window(system_uninstall, copy_label="uninstall command")}
Uninstall keeps your private URLs by default. Use --delete-config only when you want to remove everything.

User install

Use this when you do not want a system-wide install.

{_code_window(user_install, copy_label="user install command")} {_copy_menu("More copy options", [("Clean user uninstall", clean_uninstall)])}
""" ) def _credentials_panel(service: DdnsService, created_account: dict[str, str] | None) -> SafeHtml: if not created_account: return trusted("") hostname = created_account["hostname"] username = created_account["username"] password = created_account["password"] update_url = service.fritz_update_url(created_account) credentialed_update_url = service.credentialed_update_url(created_account) management_url = service.magic_management_url(created_account) cname_record = f"your-subdomain.example.com. CNAME {hostname}." fritzbox_fields = _fritzbox_fields(update_url, hostname, username, password, management_url) manual_commands = _manual_update_commands(update_url) return trusted( f"""

Hostname ready

{escape(hostname)}

Use the Update-URL directly. Username and password are only for routers that require separate fields.

{_one_time_secret_notice()} {_secret_notice()}
{_copy_menu("Copy setup values", [("Router fields", fritzbox_fields), ("Full update URL", credentialed_update_url), ("CNAME", cname_record)])}
{_copy_row("Update-URL:", update_url, "Secret")} {_copy_row("Full update URL:", credentialed_update_url, "Secret")} {_copy_row("Domainnamen:", hostname, "Public")} {_copy_row("CNAME target:", hostname, "Public")} {_copy_row("Benutzername (optional):", username, "Public")} {_copy_row("Kennwort (optional):", password, "Secret")} {_copy_row("Private dashboard:", management_url, "Secret")}
{_manual_update_panel(manual_commands)}
""" )