Archived
96 lines
4.3 KiB
Python
96 lines
4.3 KiB
Python
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"""
|
|
<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 a hostname, installs the updater, schedules it, and prints your private dashboard link.</p>
|
|
</div>
|
|
<div class="card card-body gap-3">
|
|
<div>
|
|
<h3>Install</h3>
|
|
<p class="section-copy">System install for most Linux servers.</p>
|
|
</div>
|
|
{_code_window(system_install, copy_label="install command")}
|
|
<div>
|
|
<h3>Uninstall</h3>
|
|
<p class="section-copy">Stops the updater and leaves your private URLs on disk.</p>
|
|
</div>
|
|
{_code_window(system_uninstall, copy_label="uninstall command")}
|
|
<div class="alert alert-info my-0 py-2 small" role="note">
|
|
Uninstall keeps your private URLs by default. Use <code>--delete-config</code> only when you want to remove everything.
|
|
</div>
|
|
<div>
|
|
<h3>User install</h3>
|
|
<p class="section-copy">Use this when you do not want a system-wide install.</p>
|
|
</div>
|
|
{_code_window(user_install, copy_label="user install command")}
|
|
{_copy_menu("More copy options", [("Clean user uninstall", clean_uninstall)])}
|
|
</div>
|
|
</div>
|
|
</section>
|
|
"""
|
|
)
|
|
|
|
|
|
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"""
|
|
<section class="section success-section">
|
|
<div class="container">
|
|
<p class="eyebrow">Hostname ready</p>
|
|
<h2>{escape(hostname)}</h2>
|
|
<p class="section-copy">Use the Update-URL directly. Username and password are only for routers that require separate fields.</p>
|
|
{_one_time_secret_notice()}
|
|
{_secret_notice()}
|
|
<div class="copy-actions my-3">
|
|
{_copy_menu("Copy setup values", [("Router fields", fritzbox_fields), ("Full update URL", credentialed_update_url), ("CNAME", cname_record)])}
|
|
</div>
|
|
<div class="d-grid gap-2">
|
|
{_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")}
|
|
</div>
|
|
{_manual_update_panel(manual_commands)}
|
|
</div>
|
|
</section>
|
|
"""
|
|
)
|