Archived
88 lines
4.0 KiB
Python
88 lines
4.0 KiB
Python
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"""
|
||
|
|
<section class="section" id="linux-installer">
|
||
|
|
<div class="container narrow">
|
||
|
|
<div class="text-center mb-4">
|
||
|
|
<p class="eyebrow">Linux cron updater</p>
|
||
|
|
<h2>Linux updater.</h2>
|
||
|
|
<p class="section-copy mx-auto">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.</p>
|
||
|
|
</div>
|
||
|
|
<div class="installer-commands">
|
||
|
|
<div class="installer-command">
|
||
|
|
<h3>Install</h3>
|
||
|
|
<p class="section-copy">Sets up the updater and cron job.</p>
|
||
|
|
{_code_window(system_install, copy_label="install command", class_name="mt-3")}
|
||
|
|
</div>
|
||
|
|
<div class="installer-command">
|
||
|
|
<h3>Uninstall</h3>
|
||
|
|
<p class="section-copy">Stops the updater and leaves private URLs on disk.</p>
|
||
|
|
{_code_window(system_uninstall, copy_label="uninstall command", class_name="mt-3")}
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</section>
|
||
|
|
"""
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
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"""
|
||
|
|
<section class="section success-section">
|
||
|
|
<div class="container">
|
||
|
|
<p class="eyebrow">Pending setup</p>
|
||
|
|
<h2>{escape(hostname)}</h2>
|
||
|
|
<p class="section-copy">Copy these values now. Then register the hostname so router updates can start. Unregistered setups are removed after 24 hours.</p>
|
||
|
|
{_one_time_secret_notice()}
|
||
|
|
{_secret_notice(include_registration=True)}
|
||
|
|
<div class="copy-actions my-3">
|
||
|
|
{_copy_menu("Copy setup values", [("Router fields", fritzbox_fields), ("Register URL", registration_url), ("CNAME", cname_record)])}
|
||
|
|
</div>
|
||
|
|
<div class="d-grid gap-2">
|
||
|
|
{_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")}
|
||
|
|
</div>
|
||
|
|
<form class="mt-4" method="post" action="/m/{management_slug}/activate">
|
||
|
|
<input type="hidden" name="csrf" value="{attr(csrf_token)}">
|
||
|
|
<button class="btn btn-primary rounded-pill" type="submit">Register hostname</button>
|
||
|
|
</form>
|
||
|
|
{_manual_update_panel(manual_commands)}
|
||
|
|
</div>
|
||
|
|
</section>
|
||
|
|
"""
|
||
|
|
)
|