Compare commits
No commits in common. "main" and "fix/updater-start-new-timers" have entirely different histories.
main
...
fix/update
|
|
@ -12,7 +12,6 @@ on:
|
|||
- '**/*.md'
|
||||
- 'docs/**'
|
||||
- 'website/**'
|
||||
- 'ops/**'
|
||||
- 'CHANGELOG.md'
|
||||
- 'RELEASING.md'
|
||||
workflow_dispatch:
|
||||
|
|
|
|||
|
|
@ -57,13 +57,3 @@ jobs:
|
|||
env:
|
||||
FORGEJO_TOKEN: ${{ secrets.FORGEJO_RELEASE_TOKEN }}
|
||||
run: ./scripts/publish-release.sh "${GITHUB_REF_NAME}"
|
||||
|
||||
- name: Refresh furtka.org download page
|
||||
# The download page reads the latest release (ISO, size, date,
|
||||
# checksum) from the Forgejo API at build time, so rebuild the site
|
||||
# now that the release exists. Same runner + bind mounts as
|
||||
# deploy-site.yml. A failure here doesn't touch the release.
|
||||
continue-on-error: true
|
||||
run: |
|
||||
apk add --no-cache hugo rsync
|
||||
./website/deploy-ci.sh
|
||||
|
|
|
|||
89
CHANGELOG.md
|
|
@ -7,80 +7,8 @@ This project uses calendar versioning: `YY.N-stage` (e.g. `26.0-alpha` = 2026, r
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [26.21-alpha] - 2026-10-23
|
||||
|
||||
### Added
|
||||
|
||||
- **Furtka Gateway: apps reachable from the internet** (behind NAT/CGNAT,
|
||||
no port forwarding). Settings → *Furtka Gateway*: enter the gateway URL
|
||||
and registration token, the box registers and keeps a WireGuard tunnel to
|
||||
a [furtka-gateway](https://forgejo.sourcegate.online/robert/furtka-gateway)
|
||||
server (Traefik + wg-easy + control plane). Apps → ⋯ → *Expose to
|
||||
Internet* publishes an app under its own hostname with Let's Encrypt;
|
||||
*Stop exposing* takes it down again. Only apps whose manifest declares
|
||||
`internet.viable: true` can be exposed. Client in `furtka/gateway.py` +
|
||||
`furtka/wireguard.py`, CLI `furtka gateway …`.
|
||||
- **New logo: Mark M** (a lowercase *f* cut out of an arched gate), winner of
|
||||
the furtka.org vote (29 of 42 votes). It is now in the website header,
|
||||
favicon and share card, the installer header and tab icon, the on-box UI
|
||||
(every page and the login), the console welcome screens of the live ISO
|
||||
and the installed box, and the BIOS boot-menu splash. Brand files in
|
||||
`docs/brand/`, generated by `website/tools/brand-assets.py`.
|
||||
- **furtka.org/download/** (and `/de/download/`): ISO download with size,
|
||||
date and checksum, requirements and step-by-step install guide. Releases
|
||||
now publish `furtka-<ver>.iso.sha256` and refresh the site.
|
||||
|
||||
### Security
|
||||
|
||||
- **App names are validated everywhere.** `POST /api/apps/remove` with
|
||||
`{"name": ".."}` or `"/"` sent `shutil.rmtree` at `/var/lib/furtka` or the
|
||||
root filesystem (and wiping `users.json` reopened first-run admin setup to
|
||||
the LAN). Names from URLs, JSON bodies and manifests must now match
|
||||
`^[a-z][a-z0-9_-]*$`; `installer.remove`/`update_env` check it too.
|
||||
- **Settings can't inject into `.env`.** Line breaks are refused; values
|
||||
with `$` are single-quoted so compose doesn't expand them (`pa$word` used
|
||||
to become `pa`). Validation runs before the write, so a rejected `/etc`
|
||||
path is no longer saved anyway.
|
||||
- **Damaged `users.json` fails closed.** An empty/corrupt file used to read
|
||||
as "no admin yet" and turned `/login` into an open create-admin form.
|
||||
`/login` now answers 503 with SSH recovery steps; `save_users` fsyncs.
|
||||
- **API server hardening:** threaded (state changes still serialised), 1 MiB
|
||||
body cap, 30 s socket timeout, cross-site POSTs refused via
|
||||
`Sec-Fetch-Site`, JSON 500 instead of dropped connections.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **Installer disk picker:** SATA SSDs were labelled "HDD" and lost the
|
||||
recommendation to bigger spinning disks; type now comes from lsblk
|
||||
`TRAN`/`ROTA`. zram, eMMC boot/RPMB areas, read-only and 0-byte disks are
|
||||
hidden; disks under 16 GB are greyed out; USB disks rank last; >2 TB disks
|
||||
on BIOS machines get an MBR warning; the boot stick is also found via the
|
||||
archiso kernel args when `bootmnt` is gone. Step 2 only accepts a listed disk.
|
||||
- **Installer runs one install at a time** (double-click / second browser
|
||||
started a second archinstall on the same disk), and a crashed archinstall
|
||||
(OOM kill, signal) now shows as an error instead of a progress bar stuck
|
||||
forever. Disk-probe exceptions land in the log instead of a bare 500.
|
||||
- **Failed installs can be retried** from the error page without re-entering
|
||||
everything.
|
||||
- **No 2-minute boot stall on boards with a second NIC:** the target gets a
|
||||
`systemd-networkd-wait-online --any` drop-in.
|
||||
- **Self-update:** symlink flip is atomic; any error after the flip rolls
|
||||
back (and restores the previous Caddyfile); health check survives read
|
||||
timeouts; every failure ends in an `error` stage the settings page shows.
|
||||
- **Interrupted app installs no longer block all later installs** — a stale
|
||||
state with no live runner is marked failed after 60 s.
|
||||
- **Catalog sync / update checks** no longer strand on socket resets or disk
|
||||
full.
|
||||
- **Apps page after an API restart** redirects to `/login` instead of
|
||||
showing an empty app list.
|
||||
- **32-bit UEFI machines** (Atom Bay Trail / Cherry Trail) get Limine
|
||||
instead of systemd-boot: Arch has no ia32 systemd-boot and archinstall's
|
||||
GRUB path hardcodes `x86_64-efi`, so these boxes installed but didn't boot.
|
||||
- **Force-HTTPS redirect** only covers `<hostname>.local` / `<hostname>` and
|
||||
is a 302. The old 301 for every host sent devices that use the IP to a
|
||||
TLS handshake that can't succeed, and stayed cached after HTTPS was
|
||||
turned off. Self-update migrates the old snippet.
|
||||
|
||||
- **Self-update starts newly added timers immediately and links units
|
||||
through `current`.** `_link_new_units()` enabled a timer a release
|
||||
introduced but never started it, so after the 26.19 → 26.20 update the
|
||||
|
|
@ -91,20 +19,6 @@ This project uses calendar versioning: `YY.N-stage` (e.g. `26.0-alpha` = 2026, r
|
|||
(installer-created links use `current`). Now: link via `current`, enable,
|
||||
start.
|
||||
|
||||
### Changed
|
||||
|
||||
- Wizard wording: "Server name" with a live `http://<name>.local` preview,
|
||||
"Pick a disk" with an explicit erase warning, readable confirm table,
|
||||
password hint explains it's also the SSH/console password, names are
|
||||
lowercased instead of rejected, system account names are refused.
|
||||
- Live console banner says a network cable with internet is required.
|
||||
- ISO builds pin archinstall (4.4-1, sha256-checked from the Arch archive)
|
||||
instead of taking whatever the repos ship that day; the build fails
|
||||
clearly when Arch's Python moves on. Bump steps in `iso/README.md`.
|
||||
- On-box UI polish: sticky top nav, bordered cards and status tiles, app
|
||||
tile hover lift, brand-red section markers; animations respect
|
||||
`prefers-reduced-motion`.
|
||||
|
||||
## [26.20-alpha] - 2026-08-25
|
||||
|
||||
First release shaped by a real-hardware install (old laptop mainboard, BIOS boot,
|
||||
|
|
@ -659,8 +573,7 @@ First tagged snapshot. Pre-alpha — the installer does not yet boot, but the de
|
|||
- **Containers:** Docker + Compose
|
||||
- **License:** AGPL-3.0
|
||||
|
||||
[Unreleased]: https://forgejo.sourcegate.online/daniel/furtka/compare/26.21-alpha...HEAD
|
||||
[26.21-alpha]: https://forgejo.sourcegate.online/daniel/furtka/releases/tag/26.21-alpha
|
||||
[Unreleased]: https://forgejo.sourcegate.online/daniel/furtka/compare/26.20-alpha...HEAD
|
||||
[26.20-alpha]: https://forgejo.sourcegate.online/daniel/furtka/releases/tag/26.20-alpha
|
||||
[26.19-alpha]: https://forgejo.sourcegate.online/daniel/furtka/releases/tag/26.19-alpha
|
||||
[26.18-alpha]: https://forgejo.sourcegate.online/daniel/furtka/releases/tag/26.18-alpha
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
<p><img src="docs/brand/furtka-lockup.svg" alt="Furtka" height="56"></p>
|
||||
|
||||
# Furtka
|
||||
|
||||
**Open-source home server OS — simple enough for everyone.** · [furtka.org](https://furtka.org)
|
||||
|
|
@ -56,7 +54,7 @@ Furtka aims to be:
|
|||
| Identity provider | Authentik | Bundled SSO from day one — every app template auto-wires to it at install |
|
||||
| Managed gateway DNS | NS delegation to `ns1.furtka.org` | User delegates once at registrar; we handle wildcard cert + subdomain creation |
|
||||
| Local HTTPS | Local CA | One-click CA install → green padlock on every service, no browser warnings |
|
||||
| Gateway | Traefik + wg-easy ([furtka-gateway](https://forgejo.sourcegate.online/robert/furtka-gateway)) | Decided 2026-10-23. Self-hosted on any VPS with a public IPv4 via `deploy.sh`, or managed through our infrastructure later. Boxes dial out over WireGuard, so no port forwarding at home. |
|
||||
| Gateway | Flexible | Own reverse proxy OR managed through our infrastructure |
|
||||
| UI approach | UI-first | Design the simplest possible UI, then build everything to match |
|
||||
|
||||
## Landscape (Existing Projects)
|
||||
|
|
@ -122,13 +120,10 @@ None of these nail the "your dad can set this up" experience. The installer wiza
|
|||
- [x] **Phase 2 Furtka self-update** — `/settings` → Check → Update now. Downloads signed tarball (SHA256), stages, atomic symlink flip, reloads Caddy, daemon-reload, restarts services, health-checks the new api with auto-rollback on failure. CLI: `furtka update [--check]` + `furtka rollback`. Validated end-to-end on VM 2026-04-16 (`26.0-alpha` → `26.3-alpha` → rollback → reboot).
|
||||
- [x] **Local HTTPS Phase 1** — Caddy `tls internal` on `:443` is fully opt-in via the `/settings` toggle (26.15-alpha); fresh installs stay HTTP-only so a half-trusted cert chain can't lock the user out. Per-box root CA generated on first enable, `rootCA.crt` downloadable from `/settings`, per-OS install guide at `/https-install/`. The "force HTTPS" sub-toggle still only appears once the current browser already trusts the cert.
|
||||
- [x] **Post-build smoke VM on Proxmox** — `.forgejo/workflows/build-iso.yml` hands the freshly built ISO to `scripts/smoke-vm.sh`, which boots it in a throwaway VM on `pollux` (192.168.178.165) and curls the webinstaller on `:5000`. VMID range 9000–9099, last 5 kept. Green end-to-end since 26.4-alpha.
|
||||
- [x] **Furtka Gateway (Access Gate)** — boxes behind NAT/CGNAT register with a [furtka-gateway](https://forgejo.sourcegate.online/robert/furtka-gateway) server (Traefik + wg-easy + control plane) over a WireGuard tunnel; Settings → *Furtka Gateway* connects, Apps → ⋯ → *Expose to Internet* publishes an app under its own hostname with Let's Encrypt. Only apps with `internet.viable: true` in the manifest can be exposed. Shipped in `26.21-alpha`; first gateway running at `gw.furtka.org` (Hetzner, 2026-10-23).
|
||||
- [x] **`26.21-alpha`** — security fixes (app-name validation, `.env` injection, fail-closed `users.json`, API hardening), installer fixes, Mark M logo, furtka.org/download, on-box UI polish. See [CHANGELOG](CHANGELOG.md).
|
||||
- [ ] Gateway dogfooding on real hardware — two old laptops as boxes, one per brother, both behind CGNAT
|
||||
- [ ] Installer wizard screens S3–S7 — per-device purpose, network, domain, SSL, diagnostic. S5/S6 blocked on managed-gateway DNS infra not yet built.
|
||||
- [ ] Local HTTPS Phase 2 — dedicated local CA (not Caddy's `tls internal`), streamlined one-click install across Win/Mac/Linux/Android, and HTTPS on the live-installer wizard (`https://proksi.local:5000`).
|
||||
- [ ] Caddy + Authentik wired into first-boot bootstrap
|
||||
- [ ] Managed gateway DNS — `ns1/ns2.furtka.org` + DNS-01 wildcard automation (the gateway itself works today with your own domain and per-app or wildcard A records)
|
||||
- [ ] Managed gateway infrastructure — `ns1/ns2.furtka.org` + DNS-01 wildcard automation
|
||||
- [ ] First containerized service (Nextcloud?) with auto-SSO + auto-subdomain
|
||||
- [ ] Competitor hands-on testing on Proxmox — validate findings from docs/competitors.md
|
||||
- [ ] UI mockups / drafts (Robert)
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ Tag per meaningful milestone, not on a calendar. A milestone is: ISO boots, a wi
|
|||
git push origin 26.1-alpha
|
||||
```
|
||||
|
||||
5. **The release workflow does the rest.** `.forgejo/workflows/release.yml` fires on the tag push and runs on the self-hosted runner: `scripts/build-release-tarball.sh` builds the self-update payload (tarball + sha256 + release.json under `dist/`), `iso/build.sh` builds the live-installer ISO, `scripts/publish-release.sh` uploads tarball + sha256 + release.json + ISO to the Forgejo release page. Pre-release is flagged automatically based on the suffix (`-alpha`/`-beta`/`-rc`). The ISO gets a `furtka-<ver>.iso.sha256` sidecar, and a last step rebuilds furtka.org so the download page (`/download/`) picks up the new ISO, size, date and checksum from the Forgejo API. ISO build is `continue-on-error`: a flaky ISO step doesn't block the core tarball (the thing boxes need for self-update).
|
||||
5. **The release workflow does the rest.** `.forgejo/workflows/release.yml` fires on the tag push and runs on the self-hosted runner: `scripts/build-release-tarball.sh` builds the self-update payload (tarball + sha256 + release.json under `dist/`), `iso/build.sh` builds the live-installer ISO, `scripts/publish-release.sh` uploads tarball + sha256 + release.json + ISO to the Forgejo release page. Pre-release is flagged automatically based on the suffix (`-alpha`/`-beta`/`-rc`). ISO build is `continue-on-error`: a flaky ISO step doesn't block the core tarball (the thing boxes need for self-update).
|
||||
|
||||
The release workflow needs one secret set at repo **Settings → Secrets → Actions**:
|
||||
- `FORGEJO_RELEASE_TOKEN` — a PAT with `write:repository` scope.
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@
|
|||
"git",
|
||||
"htop",
|
||||
"curl",
|
||||
"openssh",
|
||||
"wireguard-tools"
|
||||
"openssh"
|
||||
],
|
||||
|
||||
"profile": {
|
||||
|
|
|
|||
|
|
@ -13,17 +13,6 @@ hostname=$(cat /etc/hostname 2>/dev/null || hostname)
|
|||
mapfile -t ips < <(ip -4 -o addr show scope global 2>/dev/null | awk '{print $4}' | cut -d/ -f1)
|
||||
|
||||
new=$(
|
||||
# Furtka mark (docs/brand/console-banner.txt, from brand-assets.py)
|
||||
echo ' ▄▄▄▄▄▄▄▄'
|
||||
echo ' ▄██████████▄'
|
||||
echo ' █████▀▀▀▀▀▀███'
|
||||
echo ' ████▀ ████'
|
||||
echo ' ████ █████████'
|
||||
echo ' ████ ████'
|
||||
echo ' ████ ▄▄▄▄▄████'
|
||||
echo ' ████ █████████'
|
||||
echo ' ████ █████████'
|
||||
echo ' ▀▀▀▀ ▀▀▀▀▀▀▀▀▀'
|
||||
echo
|
||||
echo " Furtka is ready."
|
||||
echo
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><style>svg{color:#c03a28}@media (prefers-color-scheme:dark){svg{color:#ff6b56}}</style><path fill="currentColor" fill-rule="evenodd" d="M5 60V27a27 27 0 0 1 54 0v33Z M19.5 60V26A10 10 0 0 1 29.5 16H46v10H32a2.5 2.5 0 0 0-2.5 2.5V32H46v10H29.5v18Z"/></svg>
|
||||
|
Before Width: | Height: | Size: 316 B |
|
|
@ -2,7 +2,6 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||||
<title>Install local HTTPS · Furtka</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||||
<title>Furtka</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
|
|
@ -69,15 +68,6 @@
|
|||
</main>
|
||||
|
||||
<script>
|
||||
// Sessions live in API memory, so every restart or self-update logs
|
||||
// everyone out. Send the browser to the login page instead of rendering
|
||||
// the 401 body as if the box had no apps.
|
||||
const _fetch = window.fetch.bind(window);
|
||||
window.fetch = async (...args) => {
|
||||
const r = await _fetch(...args);
|
||||
if (r.status === 401) { location.href = '/login'; }
|
||||
return r;
|
||||
};
|
||||
// Revoke the cookie server-side and bounce to /login. Shared
|
||||
// shape with the _HTML in furtka/api.py so the two logout
|
||||
// links behave identically.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||||
<title>Settings · Furtka</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
|
|
@ -81,45 +80,6 @@
|
|||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Furtka Gateway</h2>
|
||||
<div class="card">
|
||||
<p class="lede">
|
||||
Connect this box to a furtka-gateway to expose individual apps to the
|
||||
internet over a WireGuard tunnel. Apps stay private until you explicitly
|
||||
publish one from the <a href="/apps">Apps</a> page — connecting here only
|
||||
opens the tunnel, nothing is exposed automatically.
|
||||
</p>
|
||||
<div id="gateway-disconnected" hidden>
|
||||
<div class="field">
|
||||
<label for="gw-url">Gateway URL</label>
|
||||
<input type="text" id="gw-url" placeholder="https://gw.example.com">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="gw-token">Registration token</label>
|
||||
<input type="password" id="gw-token" placeholder="from the gateway operator">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="gw-name">Box name</label>
|
||||
<input type="text" id="gw-name" placeholder="my-box">
|
||||
</div>
|
||||
<div class="update-actions">
|
||||
<button id="gateway-connect-btn">Connect</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gateway-connected" hidden>
|
||||
<dl class="kv">
|
||||
<dt>Gateway</dt><dd id="gw-connected-url">—</dd>
|
||||
<dt>Tunnel</dt><dd id="gw-tunnel-status">—</dd>
|
||||
</dl>
|
||||
<div class="update-actions">
|
||||
<button class="danger" id="gateway-disconnect-btn">Disconnect</button>
|
||||
</div>
|
||||
</div>
|
||||
<p id="gateway-status" class="hint"></p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>Appearance</h2>
|
||||
<div class="card">
|
||||
|
|
@ -152,6 +112,7 @@
|
|||
<a href="https://furtka.org/#planned">Change hostname</a>
|
||||
<a href="https://furtka.org/#planned">Backup</a>
|
||||
<a href="https://furtka.org/#planned">User accounts</a>
|
||||
<a href="https://furtka.org/#planned">Remote access</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
|
@ -161,15 +122,6 @@
|
|||
</main>
|
||||
|
||||
<script>
|
||||
// Sessions live in API memory, so every restart or self-update logs
|
||||
// everyone out. Send the browser to the login page instead of rendering
|
||||
// the 401 body as if the box had no apps.
|
||||
const _fetch = window.fetch.bind(window);
|
||||
window.fetch = async (...args) => {
|
||||
const r = await _fetch(...args);
|
||||
if (r.status === 401) { location.href = '/login'; }
|
||||
return r;
|
||||
};
|
||||
// Logout button in the nav — same shape as /apps and / pages.
|
||||
async function doLogout(ev) {
|
||||
ev.preventDefault();
|
||||
|
|
@ -210,7 +162,6 @@
|
|||
done: 'Update complete — reloading…',
|
||||
rolled_back: 'Update failed, rolled back to the previous version',
|
||||
rolled_back_manual: 'Rolled back manually',
|
||||
error: 'Update failed — nothing was changed',
|
||||
};
|
||||
|
||||
let pollHandle = null;
|
||||
|
|
@ -388,140 +339,18 @@
|
|||
await refreshHttpsStatus();
|
||||
})();
|
||||
|
||||
// --- Furtka Gateway -------------------------------------------------
|
||||
|
||||
const CONNECT_STAGE_LABELS = {
|
||||
registering: 'Registering with the gateway…',
|
||||
starting_tunnel: 'Starting the WireGuard tunnel…',
|
||||
done: 'Connected.',
|
||||
};
|
||||
|
||||
const gatewayDisconnectedEl = document.getElementById('gateway-disconnected');
|
||||
const gatewayConnectedEl = document.getElementById('gateway-connected');
|
||||
const gwConnectedUrlEl = document.getElementById('gw-connected-url');
|
||||
const gwTunnelStatusEl = document.getElementById('gw-tunnel-status');
|
||||
const gatewayStatusEl = document.getElementById('gateway-status');
|
||||
const gatewayConnectBtn = document.getElementById('gateway-connect-btn');
|
||||
const gatewayDisconnectBtn = document.getElementById('gateway-disconnect-btn');
|
||||
let gatewayPollHandle = null;
|
||||
|
||||
function setGatewayStatus(msg, isError = false) {
|
||||
gatewayStatusEl.textContent = msg;
|
||||
gatewayStatusEl.style.color = isError ? 'var(--danger)' : 'var(--muted)';
|
||||
}
|
||||
|
||||
function describeTunnel(tunnel) {
|
||||
if (!tunnel || !tunnel.configured) return 'not configured';
|
||||
return tunnel.latest_handshake ? `up (last handshake ${tunnel.latest_handshake})` : 'configured, no handshake yet';
|
||||
}
|
||||
|
||||
async function refreshGatewayStatus() {
|
||||
try {
|
||||
const r = await fetch('/api/gateway/status', { cache: 'no-store' });
|
||||
// Sessions are in-memory, so a furtka-api restart logs us
|
||||
// out. Both panels start hidden — never claim "not
|
||||
// connected" when we simply couldn't ask.
|
||||
if (r.status === 401) {
|
||||
window.location.href = '/login';
|
||||
return;
|
||||
}
|
||||
if (!r.ok) return;
|
||||
const s = await r.json();
|
||||
gatewayDisconnectedEl.hidden = !!s.connected;
|
||||
gatewayConnectedEl.hidden = !s.connected;
|
||||
if (s.connected) {
|
||||
gwConnectedUrlEl.textContent = s.gateway_url;
|
||||
gwTunnelStatusEl.textContent = describeTunnel(s.tunnel);
|
||||
}
|
||||
} catch (e) {
|
||||
/* next refresh will retry */
|
||||
}
|
||||
}
|
||||
refreshGatewayStatus();
|
||||
|
||||
gatewayConnectBtn.addEventListener('click', async () => {
|
||||
const gateway_url = document.getElementById('gw-url').value.trim();
|
||||
const registration_token = document.getElementById('gw-token').value;
|
||||
const box_name = document.getElementById('gw-name').value.trim();
|
||||
if (!gateway_url || !registration_token || !box_name) {
|
||||
setGatewayStatus('Gateway URL, registration token, and box name are all required.', true);
|
||||
return;
|
||||
}
|
||||
gatewayConnectBtn.disabled = true;
|
||||
setGatewayStatus('Connecting…');
|
||||
try {
|
||||
const r = await fetch('/api/gateway/connect', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ gateway_url, registration_token, box_name }),
|
||||
});
|
||||
const data = await r.json();
|
||||
if (!r.ok) {
|
||||
setGatewayStatus(data.error || `HTTP ${r.status}`, true);
|
||||
gatewayConnectBtn.disabled = false;
|
||||
return;
|
||||
}
|
||||
gatewayPollHandle = setInterval(pollGatewayConnectState, 2000);
|
||||
} catch (e) {
|
||||
setGatewayStatus(`Network error: ${e.message}`, true);
|
||||
gatewayConnectBtn.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
async function pollGatewayConnectState() {
|
||||
try {
|
||||
const r = await fetch('/api/gateway/connect/status', { cache: 'no-store' });
|
||||
if (!r.ok) return;
|
||||
const s = await r.json();
|
||||
const label = CONNECT_STAGE_LABELS[s.stage] || `Stage: ${s.stage}`;
|
||||
setGatewayStatus(label, s.stage === 'error');
|
||||
if (s.stage === 'done') {
|
||||
clearInterval(gatewayPollHandle);
|
||||
gatewayConnectBtn.disabled = false;
|
||||
await refreshGatewayStatus();
|
||||
} else if (s.stage === 'error') {
|
||||
clearInterval(gatewayPollHandle);
|
||||
gatewayConnectBtn.disabled = false;
|
||||
if (s.error) setGatewayStatus(`${label} — ${s.error}`, true);
|
||||
}
|
||||
} catch (e) {
|
||||
/* keep polling; transient blip expected */
|
||||
}
|
||||
}
|
||||
|
||||
gatewayDisconnectBtn.addEventListener('click', async () => {
|
||||
if (!confirm('Disconnect from the gateway? Any apps currently exposed to the internet will stop being reachable.')) return;
|
||||
gatewayDisconnectBtn.disabled = true;
|
||||
setGatewayStatus('Disconnecting…');
|
||||
try {
|
||||
const r = await fetch('/api/gateway/disconnect', { method: 'POST' });
|
||||
const data = await r.json();
|
||||
if (!r.ok) {
|
||||
setGatewayStatus(data.error || `HTTP ${r.status}`, true);
|
||||
return;
|
||||
}
|
||||
setGatewayStatus('Disconnected.');
|
||||
await refreshGatewayStatus();
|
||||
} catch (e) {
|
||||
setGatewayStatus(`Network error: ${e.message}`, true);
|
||||
} finally {
|
||||
gatewayDisconnectBtn.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
async function pollUpdateState() {
|
||||
try {
|
||||
const r = await fetch('/update-state.json', { cache: 'no-store' });
|
||||
if (!r.ok) return;
|
||||
const s = await r.json();
|
||||
const label = STAGE_LABELS[s.stage] || `Stage: ${s.stage}`;
|
||||
const failed = s.stage === 'rolled_back' || s.stage === 'error';
|
||||
setStatus(label, failed);
|
||||
setStatus(label, s.stage === 'rolled_back');
|
||||
if (s.stage === 'done') {
|
||||
clearInterval(pollHandle);
|
||||
clearTimeout(fallbackReloadHandle);
|
||||
setTimeout(() => location.reload(), 5000);
|
||||
} else if (failed) {
|
||||
} else if (s.stage === 'rolled_back') {
|
||||
clearInterval(pollHandle);
|
||||
clearTimeout(fallbackReloadHandle);
|
||||
if (s.reason) {
|
||||
|
|
|
|||
|
|
@ -21,13 +21,7 @@
|
|||
--r-pill: 999px;
|
||||
|
||||
--shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
|
||||
--shadow-lift: 0 8px 24px rgba(0, 0, 0, 0.35);
|
||||
--ring: 0 0 0 2px var(--accent);
|
||||
/* Brand red from the logo, used only for small highlights. */
|
||||
--brand: #ff6b56;
|
||||
--glow-a: rgba(255, 107, 86, 0.10);
|
||||
--glow-b: rgba(110, 231, 183, 0.08);
|
||||
--nav-bg: rgba(15, 17, 21, 0.72);
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
|
|
@ -44,11 +38,6 @@
|
|||
--warn-fg: #5a2a10;
|
||||
--danger: #c03a28;
|
||||
--shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
|
||||
--shadow-lift: 0 8px 24px rgba(0, 0, 0, 0.10);
|
||||
--brand: #c03a28;
|
||||
--glow-a: rgba(192, 58, 40, 0.07);
|
||||
--glow-b: rgba(15, 138, 95, 0.06);
|
||||
--nav-bg: rgba(247, 246, 243, 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,16 +45,9 @@
|
|||
body {
|
||||
margin: 0;
|
||||
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
||||
/* Two soft glows at the top (logo red, accent green) give the page some
|
||||
depth without competing with the content. */
|
||||
background:
|
||||
radial-gradient(60rem 28rem at 15% -10%, var(--glow-a), transparent 70%),
|
||||
radial-gradient(50rem 24rem at 95% -5%, var(--glow-b), transparent 70%),
|
||||
var(--bg);
|
||||
background-attachment: fixed;
|
||||
background: var(--bg);
|
||||
color: var(--fg);
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* Shared page container — both landing and /apps wrap content in
|
||||
|
|
@ -77,16 +59,9 @@ body {
|
|||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0.85rem 0;
|
||||
padding-bottom: 1.25rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
margin-bottom: 2rem;
|
||||
/* Stays in reach while scrolling long pages like /settings. */
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 20;
|
||||
background: var(--nav-bg);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
.brand {
|
||||
font-weight: 700;
|
||||
|
|
@ -98,17 +73,13 @@ body {
|
|||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
}
|
||||
/* Furtka mark (M), drawn as a mask so it takes the accent colour in both
|
||||
themes. Generated geometry: website/tools/brand-assets.py. */
|
||||
.brand::before {
|
||||
content: "";
|
||||
width: 1.35rem;
|
||||
height: 1.35rem;
|
||||
/* Brand red, not the UI's green accent — the logo keeps its colour.
|
||||
This stylesheet is dark-first; the light theme gets the deeper red. */
|
||||
background: #ff6b56;
|
||||
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath fill-rule='evenodd' d='M5 60V27a27 27 0 0 1 54 0v33Z M19.5 60V26A10 10 0 0 1 29.5 16H46v10H32a2.5 2.5 0 0 0-2.5 2.5V32H46v10H29.5v18Z'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath fill-rule='evenodd' d='M5 60V27a27 27 0 0 1 54 0v33Z M19.5 60V26A10 10 0 0 1 29.5 16H46v10H32a2.5 2.5 0 0 0-2.5 2.5V32H46v10H29.5v18Z'/%3E%3C/svg%3E") center / contain no-repeat;
|
||||
width: 0.7rem;
|
||||
height: 0.7rem;
|
||||
background: var(--accent);
|
||||
border-radius: 2px;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
.nav-links { display: flex; gap: 0.25rem; }
|
||||
.nav-links a {
|
||||
|
|
@ -116,52 +87,30 @@ body {
|
|||
text-decoration: none;
|
||||
font-size: 0.9rem;
|
||||
padding: 0.35rem 0.75rem;
|
||||
border-radius: var(--r-pill);
|
||||
transition: color 120ms, background 120ms;
|
||||
border-radius: var(--r-sm);
|
||||
}
|
||||
.nav-links a:hover { color: var(--fg); background: var(--card); }
|
||||
.nav-links a:hover { color: var(--fg); }
|
||||
.nav-links a[aria-current="page"] {
|
||||
color: var(--fg);
|
||||
background: var(--accent-soft);
|
||||
}
|
||||
|
||||
/* -- Landing page ---------------------------------------------- */
|
||||
header h1 {
|
||||
margin: 0 0 0.5rem;
|
||||
font-size: clamp(2rem, 6vw, 2.75rem);
|
||||
letter-spacing: -0.02em;
|
||||
line-height: 1.1;
|
||||
background: linear-gradient(100deg, var(--fg) 40%, var(--accent));
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
color: transparent;
|
||||
}
|
||||
header h1 { margin: 0 0 0.5rem; font-size: 2.5rem; }
|
||||
.lead { font-size: 1.25rem; color: var(--muted); margin: 0 0 0.25rem; }
|
||||
.host { color: var(--muted); margin: 0 0 3rem; }
|
||||
.host code {
|
||||
background: var(--accent-soft);
|
||||
padding: 0.2rem 0.65rem;
|
||||
border-radius: var(--r-pill);
|
||||
background: var(--card);
|
||||
padding: 0.15rem 0.5rem;
|
||||
border-radius: var(--r-sm);
|
||||
color: var(--accent);
|
||||
font-size: 0.9em;
|
||||
}
|
||||
section h2 {
|
||||
font-size: 0.85rem;
|
||||
font-size: 1.1rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.12em;
|
||||
letter-spacing: 0.1em;
|
||||
color: var(--muted);
|
||||
margin: 2.5rem 0 1rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
/* Small brand-red marker in front of each landing-page section title. */
|
||||
section h2::before {
|
||||
content: "";
|
||||
width: 0.45rem;
|
||||
height: 0.45rem;
|
||||
border-radius: var(--r-pill);
|
||||
background: var(--brand);
|
||||
margin: 2rem 0 1rem;
|
||||
}
|
||||
.tiles {
|
||||
display: grid;
|
||||
|
|
@ -171,21 +120,9 @@ section h2::before {
|
|||
.tile {
|
||||
background: var(--card);
|
||||
padding: 1.25rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-lg);
|
||||
border-radius: var(--r-md);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
/* Thin accent line along the top edge of each status tile. */
|
||||
.tile::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0 0 auto 0;
|
||||
height: 3px;
|
||||
background: linear-gradient(90deg, var(--accent), transparent);
|
||||
opacity: 0.7;
|
||||
}
|
||||
.tile .label {
|
||||
font-size: 0.8rem;
|
||||
|
|
@ -193,12 +130,7 @@ section h2::before {
|
|||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
.tile .value {
|
||||
font-size: 1.35rem;
|
||||
font-weight: 600;
|
||||
margin-top: 0.5rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.tile .value { font-size: 1.25rem; margin-top: 0.5rem; }
|
||||
.updated { font-size: 0.85rem; color: var(--muted); margin-top: 1rem; }
|
||||
.soon {
|
||||
background: var(--card);
|
||||
|
|
@ -236,9 +168,7 @@ h2 {
|
|||
.app {
|
||||
background: var(--card);
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-lg);
|
||||
transition: border-color 120ms;
|
||||
border-radius: var(--r-md);
|
||||
margin: 0.5rem 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
|
@ -285,69 +215,13 @@ button, .btn {
|
|||
text-decoration: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
transition: filter 120ms, transform 80ms;
|
||||
}
|
||||
button:hover:not(:disabled), .btn:hover { filter: brightness(1.08); }
|
||||
button:active:not(:disabled), .btn:active { transform: translateY(1px); }
|
||||
button.secondary, .btn.secondary {
|
||||
background: var(--card);
|
||||
color: var(--fg);
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
button.danger { background: var(--danger); color: #fff; }
|
||||
|
||||
/* Public-URL line under an app's description, shown while the app is
|
||||
exposed through furtka-gateway. */
|
||||
.public-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
margin-top: 0.25rem;
|
||||
font-size: 0.85rem;
|
||||
color: var(--accent);
|
||||
text-decoration: none;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.public-link:hover { text-decoration: underline; }
|
||||
.public-link .dot {
|
||||
width: 0.5rem;
|
||||
height: 0.5rem;
|
||||
border-radius: var(--r-pill);
|
||||
background: var(--accent);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* "⋯" overflow menu on an installed app row. */
|
||||
details.menu { position: relative; }
|
||||
details.menu > summary { list-style: none; padding: 0.5rem 0.75rem; }
|
||||
details.menu > summary::-webkit-details-marker { display: none; }
|
||||
.menu-list {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: calc(100% + 0.25rem);
|
||||
z-index: 10;
|
||||
min-width: 11rem;
|
||||
padding: 0.25rem;
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-md);
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.menu-list button {
|
||||
background: none;
|
||||
color: var(--fg);
|
||||
font-weight: 500;
|
||||
width: 100%;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.menu-list button:hover { background: var(--card-hover); }
|
||||
.menu-list button.danger { background: none; color: var(--danger); }
|
||||
.menu-list button.danger:hover { background: var(--card-hover); }
|
||||
.menu-list hr { border: none; border-top: 1px solid var(--border); margin: 0.25rem 0; }
|
||||
button:disabled { opacity: 0.5; cursor: wait; }
|
||||
button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--ring); }
|
||||
.empty { color: var(--muted); font-style: italic; padding: 0.5rem 0; }
|
||||
|
|
@ -520,8 +394,7 @@ details.log-details[open] > summary { color: var(--fg); }
|
|||
.card {
|
||||
background: var(--card);
|
||||
padding: 1.25rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-lg);
|
||||
border-radius: var(--r-md);
|
||||
box-shadow: var(--shadow-card);
|
||||
}
|
||||
.card + .card { margin-top: 1rem; }
|
||||
|
|
@ -576,9 +449,9 @@ details.log-details[open] > summary { color: var(--fg); }
|
|||
gap: 0.75rem;
|
||||
}
|
||||
.app-tile {
|
||||
background: var(--card);
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--r-lg);
|
||||
border-radius: var(--r-md);
|
||||
padding: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
|
@ -586,20 +459,12 @@ details.log-details[open] > summary { color: var(--fg); }
|
|||
align-items: flex-start;
|
||||
text-decoration: none;
|
||||
color: var(--fg);
|
||||
transition: border-color 120ms, background 120ms, transform 120ms, box-shadow 120ms;
|
||||
}
|
||||
.app-tile:hover {
|
||||
border-color: var(--accent);
|
||||
background: var(--card-hover);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: var(--shadow-lift);
|
||||
transition: border-color 120ms, background 120ms;
|
||||
}
|
||||
.app-tile:hover { border-color: var(--accent); background: var(--card-hover); }
|
||||
.app-tile .icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
padding: 6px;
|
||||
border-radius: var(--r-md);
|
||||
background: var(--accent-soft);
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
color: var(--accent);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
@ -625,15 +490,3 @@ details.log-details[open] > summary { color: var(--fg); }
|
|||
color: var(--accent);
|
||||
}
|
||||
.app-icon svg { width: 36px; height: 36px; }
|
||||
|
||||
.login-brand { margin: 0 0 1.5rem; font-size: 1.2rem; }
|
||||
|
||||
.app:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*, *::before, *::after { transition: none !important; }
|
||||
.app-tile:hover { transform: none; }
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
.brand::before { background: #c03a28; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
# Furtka brand files
|
||||
|
||||
The Furtka logo is **Mark M** — a lowercase *f* cut out of an arched gate. It won the
|
||||
public logo vote on furtka.org (closed 2026-09-28: M 29, R 13 of 42 votes).
|
||||
|
||||
| File | Use |
|
||||
|---|---|
|
||||
| `furtka-mark.svg` | The mark, 32 px and up |
|
||||
| `furtka-mark-small.svg` | Simplified drawing for 16–24 px (favicons, tab icons) |
|
||||
| `furtka-lockup.svg` | Mark + wordmark, accent colour on light grounds |
|
||||
| `furtka-lockup-white.svg` | Mark + wordmark in white, for dark or accent grounds |
|
||||
| `console-banner.txt` | Text-mode art for the console welcome screens |
|
||||
|
||||
Colours: accent `#c03a28` (dark UI: `#ff6b56`), ink `#0d0d0f`.
|
||||
|
||||
Everything here and the copies in `website/static/`, `webinstaller/static/`,
|
||||
`assets/www/` and `iso/overlay/splash.png` are generated by
|
||||
`website/tools/brand-assets.py` from the geometry in `website/tools/logo-assets.py`.
|
||||
Change the geometry there and re-run the script — don't edit the outputs by hand.
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
▄▄▄▄▄▄▄▄
|
||||
▄██████████▄
|
||||
█████▀▀▀▀▀▀███
|
||||
████▀ ████
|
||||
████ █████████
|
||||
████ ████
|
||||
████ ▄▄▄▄▄████
|
||||
████ █████████
|
||||
████ █████████
|
||||
▀▀▀▀ ▀▀▀▀▀▀▀▀▀
|
||||
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -4 232.44 64.00" role="img" aria-label="Furtka"><g transform="scale(1.0000) translate(-6 -2)"><path fill="#ffffff" fill-rule="evenodd" d="M6 60V28a26 26 0 0 1 52 0v32Z M20.0 60V26.5A10.5 10.5 0 0 1 30.5 16H45.0v8.6H32.5a3.5 3.5 0 0 0-3.5 3.5V32h16v8.6H29.0V60Z"/></g><g fill="#ffffff"><path transform="translate(68.24 58.00) scale(0.05354 -0.05354)" d="M115 0V494H30V600H115V637Q115 687 132.5 724.0Q150 761 192.0 781.5Q234 802 305 802Q333 802 358 799V695Q344 698 324 698Q287 698 273.5 682.0Q260 666 260 632V600H358V494H260V0Z"/><path transform="translate(87.21 58.00) scale(0.05354 -0.05354)" d="M271 -15Q169 -15 119.0 48.5Q69 112 69 218V600H218V244Q218 179 241.5 143.0Q265 107 316 107Q379 107 413.0 156.0Q447 205 447 276V600H596V0H462V90H438Q423 44 382.5 14.5Q342 -15 271 -15Z"/><path transform="translate(121.45 58.00) scale(0.05354 -0.05354)" d="M76 0V600H211V492H235Q241 521 257.0 547.0Q273 573 307.0 589.5Q341 606 399 606H428V471H387Q301 471 263.0 427.0Q225 383 225 294V0Z"/><path transform="translate(144.17 58.00) scale(0.05354 -0.05354)" d="M162 0Q139 27 125.5 65.0Q112 103 112 179V494H30V600H114V750H259V600H358V494H260V196Q260 116 278.0 74.5Q296 33 321 6V0Z"/><path transform="translate(163.14 58.00) scale(0.05354 -0.05354)" d="M78 0V800H226V366H274L449 600H608V594L397 320L632 6V0H457L274 254H226V0Z"/><path transform="translate(195.88 58.00) scale(0.05354 -0.05354)" d="M280 -13Q198 -13 144.0 27.5Q90 68 63.5 138.5Q37 209 37 301Q37 395 64.0 465.0Q91 535 145.0 574.0Q199 613 280 613Q344 613 384.5 587.5Q425 562 445 522H469V600H606V0H469V78H445Q425 41 385.0 14.0Q345 -13 280 -13ZM317 95Q381 95 419.5 151.0Q458 207 458 300Q458 394 419.5 449.5Q381 505 317 505Q257 505 223.5 453.0Q190 401 190 300Q190 199 223.5 147.0Q257 95 317 95Z"/></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.8 KiB |
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -4 232.44 64.00" role="img" aria-label="Furtka"><g transform="scale(1.0000) translate(-6 -2)"><path fill="#c03a28" fill-rule="evenodd" d="M6 60V28a26 26 0 0 1 52 0v32Z M20.0 60V26.5A10.5 10.5 0 0 1 30.5 16H45.0v8.6H32.5a3.5 3.5 0 0 0-3.5 3.5V32h16v8.6H29.0V60Z"/></g><g fill="#c03a28"><path transform="translate(68.24 58.00) scale(0.05354 -0.05354)" d="M115 0V494H30V600H115V637Q115 687 132.5 724.0Q150 761 192.0 781.5Q234 802 305 802Q333 802 358 799V695Q344 698 324 698Q287 698 273.5 682.0Q260 666 260 632V600H358V494H260V0Z"/><path transform="translate(87.21 58.00) scale(0.05354 -0.05354)" d="M271 -15Q169 -15 119.0 48.5Q69 112 69 218V600H218V244Q218 179 241.5 143.0Q265 107 316 107Q379 107 413.0 156.0Q447 205 447 276V600H596V0H462V90H438Q423 44 382.5 14.5Q342 -15 271 -15Z"/><path transform="translate(121.45 58.00) scale(0.05354 -0.05354)" d="M76 0V600H211V492H235Q241 521 257.0 547.0Q273 573 307.0 589.5Q341 606 399 606H428V471H387Q301 471 263.0 427.0Q225 383 225 294V0Z"/><path transform="translate(144.17 58.00) scale(0.05354 -0.05354)" d="M162 0Q139 27 125.5 65.0Q112 103 112 179V494H30V600H114V750H259V600H358V494H260V196Q260 116 278.0 74.5Q296 33 321 6V0Z"/><path transform="translate(163.14 58.00) scale(0.05354 -0.05354)" d="M78 0V800H226V366H274L449 600H608V594L397 320L632 6V0H457L274 254H226V0Z"/><path transform="translate(195.88 58.00) scale(0.05354 -0.05354)" d="M280 -13Q198 -13 144.0 27.5Q90 68 63.5 138.5Q37 209 37 301Q37 395 64.0 465.0Q91 535 145.0 574.0Q199 613 280 613Q344 613 384.5 587.5Q425 562 445 522H469V600H606V0H469V78H445Q425 41 385.0 14.0Q345 -13 280 -13ZM317 95Q381 95 419.5 151.0Q458 207 458 300Q458 394 419.5 449.5Q381 505 317 505Q257 505 223.5 453.0Q190 401 190 300Q190 199 223.5 147.0Q257 95 317 95Z"/></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.8 KiB |
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><path fill="#c03a28" fill-rule="evenodd" d="M5 60V27a27 27 0 0 1 54 0v33Z M19.5 60V26A10 10 0 0 1 29.5 16H46v10H32a2.5 2.5 0 0 0-2.5 2.5V32H46v10H29.5v18Z"/></svg>
|
||||
|
Before Width: | Height: | Size: 224 B |
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><path fill="#c03a28" fill-rule="evenodd" d="M6 60V28a26 26 0 0 1 52 0v32Z M20.0 60V26.5A10.5 10.5 0 0 1 30.5 16H45.0v8.6H32.5a3.5 3.5 0 0 0-3.5 3.5V32h16v8.6H29.0V60Z"/></svg>
|
||||
|
Before Width: | Height: | Size: 236 B |
|
|
@ -15,7 +15,6 @@ neutral ``ReleaseError`` for use in tests or standalone scripts.
|
|||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import http.client
|
||||
import json
|
||||
import shutil
|
||||
import tarfile
|
||||
|
|
@ -34,9 +33,7 @@ def forgejo_api(host: str, repo: str, path: str, *, error_cls: type = ReleaseErr
|
|||
try:
|
||||
with urllib.request.urlopen(req, timeout=15) as resp:
|
||||
return json.loads(resp.read())
|
||||
except (OSError, http.client.HTTPException, json.JSONDecodeError) as e:
|
||||
# OSError covers URLError plus socket timeouts and resets while
|
||||
# reading the body, which urllib doesn't wrap.
|
||||
except (urllib.error.URLError, json.JSONDecodeError) as e:
|
||||
raise error_cls(f"forgejo api {url}: {e}") from e
|
||||
|
||||
|
||||
|
|
@ -46,8 +43,7 @@ def download(url: str, dest: Path, *, error_cls: type = ReleaseError) -> None:
|
|||
try:
|
||||
with urllib.request.urlopen(req, timeout=60) as resp, dest.open("wb") as f:
|
||||
shutil.copyfileobj(resp, f)
|
||||
except (OSError, http.client.HTTPException) as e:
|
||||
# Includes disk full while writing `dest` and mid-body disconnects.
|
||||
except urllib.error.URLError as e:
|
||||
raise error_cls(f"download {url}: {e}") from e
|
||||
|
||||
|
||||
|
|
|
|||
452
furtka/api.py
|
|
@ -17,14 +17,12 @@ stopgap.
|
|||
|
||||
import json
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
from http.cookies import SimpleCookie
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
from furtka import auth, deps, dockerops, install_runner, installer, reconciler, sources
|
||||
from furtka.manifest import APP_NAME_RE, ManifestError, load_manifest
|
||||
from furtka.manifest import ManifestError, load_manifest
|
||||
from furtka.paths import apps_dir, static_www_dir
|
||||
from furtka.scanner import scan
|
||||
|
||||
|
|
@ -73,7 +71,6 @@ _HTML = """<!DOCTYPE html>
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||||
<title>Furtka Apps</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
|
|
@ -123,15 +120,6 @@ _HTML = """<!DOCTYPE html>
|
|||
</div>
|
||||
|
||||
<script>
|
||||
// Sessions live in API memory, so every restart or self-update logs
|
||||
// everyone out. Send the browser to the login page instead of rendering
|
||||
// the 401 body as if the box had no apps.
|
||||
const _fetch = window.fetch.bind(window);
|
||||
window.fetch = async (...args) => {
|
||||
const r = await _fetch(...args);
|
||||
if (r.status === 401) { location.href = '/login'; }
|
||||
return r;
|
||||
};
|
||||
function esc(s) {
|
||||
const d = document.createElement('div');
|
||||
d.textContent = s == null ? '' : String(s);
|
||||
|
|
@ -370,20 +358,6 @@ async function refresh() {
|
|||
const openBtn = openHref
|
||||
? `<a class="btn" href="${esc(openHref)}" target="_blank" rel="noopener">Open</a>`
|
||||
: '';
|
||||
// Both filled in async by loadInternetSlots() after this markup
|
||||
// lands — the current publish state needs its own fetch per app
|
||||
// (/api/apps/<name>/internet), so it can't be known at row-build
|
||||
// time. The status line sits under the description (public URL,
|
||||
// when exposed); the toggle lives in the "⋯" menu.
|
||||
const viable = a.internet && a.internet.viable;
|
||||
const internetStatus = viable
|
||||
? `<span class="internet-status" data-name="${esc(a.name)}"></span>`
|
||||
: '';
|
||||
const internetItem = viable
|
||||
? `<span class="internet-item" data-name="${esc(a.name)}"></span>`
|
||||
: '';
|
||||
// Only Open stays visible; everything else goes in a <details>
|
||||
// menu so the description isn't squeezed by a row of buttons.
|
||||
return `
|
||||
<div class="app">
|
||||
<div class="left">
|
||||
|
|
@ -391,22 +365,14 @@ async function refresh() {
|
|||
<div class="meta">
|
||||
<span class="name">${esc(a.display_name || a.name)} <small>${esc(a.version || '')}</small></span>
|
||||
<span class="desc">${esc(a.description || a.error || '')}</span>
|
||||
${internetStatus}
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
${openBtn}
|
||||
<details class="menu">
|
||||
<summary class="btn secondary" aria-label="More actions for ${esc(a.display_name || a.name)}">⋯</summary>
|
||||
<div class="menu-list">
|
||||
${hasSettings ? `<button data-op="edit" data-name="${esc(a.name)}">Settings</button>` : ''}
|
||||
${internetItem}
|
||||
<button data-op="update" data-name="${esc(a.name)}">Update</button>
|
||||
<button data-op="reinstall" data-name="${esc(a.name)}">Reinstall</button>
|
||||
<hr>
|
||||
<button class="danger" data-op="remove" data-name="${esc(a.name)}">Remove</button>
|
||||
</div>
|
||||
</details>
|
||||
${hasSettings ? `<button data-op="edit" data-name="${esc(a.name)}">Settings</button>` : ''}
|
||||
<button class="secondary" data-op="update" data-name="${esc(a.name)}">Update</button>
|
||||
<button class="secondary" data-op="reinstall" data-name="${esc(a.name)}">Reinstall</button>
|
||||
<button class="danger" data-op="remove" data-name="${esc(a.name)}">Remove</button>
|
||||
</div>
|
||||
</div>`;
|
||||
}).join('')
|
||||
|
|
@ -427,78 +393,6 @@ async function refresh() {
|
|||
for (const btn of document.querySelectorAll('button[data-op]')) {
|
||||
btn.addEventListener('click', () => handleButton(btn.dataset.op, btn.dataset.name, btn));
|
||||
}
|
||||
loadInternetSlots();
|
||||
}
|
||||
|
||||
// Populates each installed internet-viable app's public-URL status line
|
||||
// and its "Expose to Internet" / "Stop exposing" menu item. Separate from
|
||||
// the main refresh() render because the current publish state needs its
|
||||
// own per-app fetch — the /api/apps list only carries whether an app is
|
||||
// *capable* of being exposed, not whether it currently is.
|
||||
async function loadInternetSlots() {
|
||||
for (const item of document.querySelectorAll('.internet-item')) {
|
||||
const name = item.dataset.name;
|
||||
const status = document.querySelector(`.internet-status[data-name="${CSS.escape(name)}"]`);
|
||||
try {
|
||||
const r = await fetch(`/api/apps/${encodeURIComponent(name)}/internet`);
|
||||
if (!r.ok) continue;
|
||||
renderInternetSlot(item, status, name, await r.json());
|
||||
} catch (e) {
|
||||
// Leave the slots empty — next refresh() retries.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function renderInternetSlot(item, status, name, data) {
|
||||
if (data.enabled) {
|
||||
const host = data.public_url.replace(/^https?:\\/\\//, '').replace(/\\/$/, '');
|
||||
if (status) {
|
||||
status.innerHTML =
|
||||
`<a class="public-link" href="${esc(data.public_url)}" target="_blank" rel="noopener">` +
|
||||
`<span class="dot"></span>${esc(host)} ↗</a>`;
|
||||
}
|
||||
item.innerHTML = `<button data-internet="${esc(name)}">Stop exposing</button>`;
|
||||
} else {
|
||||
if (status) status.innerHTML = '';
|
||||
item.innerHTML = `<button data-internet="${esc(name)}">Expose to Internet</button>`;
|
||||
}
|
||||
item.querySelector('[data-internet]').addEventListener('click', () => handleInternetToggle(name, !!data.enabled));
|
||||
}
|
||||
|
||||
// <details> menus don't close on an outside click by themselves.
|
||||
document.addEventListener('click', (e) => {
|
||||
for (const menu of document.querySelectorAll('details.menu[open]')) {
|
||||
if (!menu.contains(e.target)) menu.removeAttribute('open');
|
||||
}
|
||||
});
|
||||
|
||||
async function handleInternetToggle(name, currentlyEnabled) {
|
||||
const logEl = document.getElementById('log');
|
||||
if (currentlyEnabled) {
|
||||
if (!confirm(`Stop exposing ${name} to the internet?`)) return;
|
||||
}
|
||||
let subdomain = null;
|
||||
if (!currentlyEnabled) {
|
||||
subdomain = prompt(
|
||||
`Public hostname for ${name} — needs its own DNS record already pointing at your gateway:`
|
||||
);
|
||||
if (!subdomain) return;
|
||||
}
|
||||
try {
|
||||
const r = await fetch(`/api/apps/${encodeURIComponent(name)}/internet`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(currentlyEnabled ? { enabled: false } : { enabled: true, subdomain }),
|
||||
});
|
||||
const data = await r.json();
|
||||
if (!r.ok) {
|
||||
logEl.textContent = `[internet ${name}] HTTP ${r.status}\\n` + JSON.stringify(data, null, 2);
|
||||
return;
|
||||
}
|
||||
await refresh();
|
||||
} catch (e) {
|
||||
logEl.textContent = `[internet ${name}] Network error: ${e.message}`;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleButton(op, name, btn) {
|
||||
|
|
@ -652,14 +546,12 @@ _HTML_LOGIN = """<!DOCTYPE html>
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||||
<title>Furtka · {{ TITLE }}</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="stylesheet" href="/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<main class="wrap login-wrap">
|
||||
<p class="brand login-brand">Furtka</p>
|
||||
<h1>{{ HEADING }}</h1>
|
||||
<p class="lede">{{ LEDE }}</p>
|
||||
<form id="login-form" onsubmit="return doLogin(event)">
|
||||
|
|
@ -777,7 +669,6 @@ def _manifest_summary(m, app_dir=None):
|
|||
{"app": req.app, "on_install": req.on_install, "on_start": req.on_start}
|
||||
for req in m.requires
|
||||
],
|
||||
"internet": {"viable": m.internet.viable, "port": m.internet.port},
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -874,7 +765,7 @@ def _do_get_settings(name):
|
|||
}
|
||||
|
||||
|
||||
_INSTALL_TERMINAL_STAGES = install_runner.TERMINAL_STAGES
|
||||
_INSTALL_TERMINAL_STAGES = frozenset({"done", "error"})
|
||||
|
||||
|
||||
def _do_install_plan(name):
|
||||
|
|
@ -928,9 +819,8 @@ def _do_install(name, settings=None, confirm_dependencies=False):
|
|||
# POST can sneak in during that tiny window. Reading the state
|
||||
# first closes that gap: as long as a previous install hasn't
|
||||
# written "done" or "error", we refuse.
|
||||
install_runner.clear_stale_state()
|
||||
current_state = install_runner.read_state()
|
||||
current_stage = current_state.get("stage", "")
|
||||
current_stage = current_state.get("stage", "") if isinstance(current_state, dict) else ""
|
||||
if current_stage and current_stage not in _INSTALL_TERMINAL_STAGES:
|
||||
return 409, {
|
||||
"error": (
|
||||
|
|
@ -1026,7 +916,6 @@ def _do_install(name, settings=None, confirm_dependencies=False):
|
|||
|
||||
def _do_install_status():
|
||||
"""Return the current install-state.json contents (or {})."""
|
||||
install_runner.clear_stale_state()
|
||||
return 200, install_runner.read_state()
|
||||
|
||||
|
||||
|
|
@ -1253,208 +1142,6 @@ def _do_catalog_status():
|
|||
}
|
||||
|
||||
|
||||
def _do_gateway_status():
|
||||
"""This box's furtka-gateway connection + tunnel state.
|
||||
|
||||
No connection at all is the common case (most boxes never connect to a
|
||||
gateway) — always 200s with connected=False rather than 404ing.
|
||||
"""
|
||||
from furtka import gateway, wireguard
|
||||
|
||||
config = gateway.load_config()
|
||||
if config is None:
|
||||
return 200, {"connected": False}
|
||||
return 200, {
|
||||
"connected": True,
|
||||
"gateway_url": config["gateway_url"],
|
||||
"box_id": config["box_id"],
|
||||
"tunnel": wireguard.status(),
|
||||
}
|
||||
|
||||
|
||||
def _do_gateway_connect(payload):
|
||||
"""Kick off gateway registration + tunnel setup detached from this process.
|
||||
|
||||
Fast validation happens here so a bad request comes back as an
|
||||
immediate 4xx. The slow part — a network call to a possibly slow or
|
||||
unreachable gateway, then `systemctl enable --now wg-quick@...` — is
|
||||
dispatched as a background systemd-run unit, the same idiom
|
||||
_do_install uses for its docker-facing phase, so it can't tie up the
|
||||
API thread. Client polls /api/gateway/connect/status.
|
||||
|
||||
Note: registration_token travels as a systemd-run argv entry, briefly
|
||||
visible to anything on this box that can read `ps`/`systemctl show`
|
||||
while the transient unit runs. Accepted here the same way furtka
|
||||
already treats local-box access as a trusted boundary (see _do_power's
|
||||
"anyone on the LAN can reboot" posture) — not something a home/single-
|
||||
tenant box's threat model treats as a meaningful new exposure.
|
||||
"""
|
||||
import subprocess
|
||||
|
||||
from furtka import gateway
|
||||
|
||||
gateway_url = payload.get("gateway_url")
|
||||
registration_token = payload.get("registration_token")
|
||||
box_name = payload.get("box_name")
|
||||
if not gateway_url or not registration_token or not box_name:
|
||||
return 400, {"error": "gateway_url, registration_token, and box_name are all required"}
|
||||
|
||||
try:
|
||||
fh = gateway.acquire_lock()
|
||||
except gateway.GatewayError as e:
|
||||
return 409, {"error": str(e)}
|
||||
try:
|
||||
# Initial state so the UI has something to show between this
|
||||
# response and the background job's first write.
|
||||
gateway.write_state("registering")
|
||||
finally:
|
||||
fh.close()
|
||||
|
||||
try:
|
||||
subprocess.run(
|
||||
[
|
||||
"systemd-run",
|
||||
"--unit=furtka-gateway-connect-api",
|
||||
"--no-block",
|
||||
"--collect",
|
||||
"/usr/local/bin/furtka",
|
||||
"gateway",
|
||||
"connect-bg",
|
||||
gateway_url,
|
||||
registration_token,
|
||||
box_name,
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
except FileNotFoundError:
|
||||
gateway.write_state("error", error="systemd-run not available")
|
||||
return 502, {"error": "systemd-run not available"}
|
||||
except subprocess.CalledProcessError as e:
|
||||
err = (e.stderr or e.stdout or "").strip()
|
||||
gateway.write_state("error", error=f"dispatch failed: {err}")
|
||||
return 502, {"error": f"systemd-run failed: {err}"}
|
||||
|
||||
return 202, {"status": "dispatched", "unit": "furtka-gateway-connect-api"}
|
||||
|
||||
|
||||
def _do_gateway_connect_status():
|
||||
from furtka import gateway
|
||||
|
||||
return 200, gateway.read_state()
|
||||
|
||||
|
||||
def _do_gateway_disconnect():
|
||||
"""Tear down the tunnel and deregister from the gateway.
|
||||
|
||||
Synchronous — deregistering is one HTTP call plus a systemctl disable,
|
||||
not a slow docker pull, so this doesn't need the async+poll dance
|
||||
(same posture as _do_update_settings).
|
||||
"""
|
||||
from furtka import gateway, wireguard
|
||||
|
||||
if gateway.load_config() is None:
|
||||
return 200, {"status": "not connected"}
|
||||
try:
|
||||
gateway.deregister()
|
||||
except gateway.GatewayError as e:
|
||||
return 502, {"error": str(e)}
|
||||
try:
|
||||
wireguard.set_tunnel_enabled(False)
|
||||
except wireguard.WireguardError as e:
|
||||
return 502, {"error": str(e)}
|
||||
return 200, {"status": "disconnected"}
|
||||
|
||||
|
||||
def _internet_routes() -> dict:
|
||||
from furtka.paths import internet_routes_file
|
||||
|
||||
path = internet_routes_file()
|
||||
if not path.is_file():
|
||||
return {}
|
||||
try:
|
||||
return json.loads(path.read_text())
|
||||
except json.JSONDecodeError:
|
||||
return {}
|
||||
|
||||
|
||||
def _save_internet_routes(routes: dict) -> None:
|
||||
from furtka.paths import internet_routes_file
|
||||
|
||||
path = internet_routes_file()
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
tmp = path.with_suffix(path.suffix + ".tmp")
|
||||
tmp.write_text(json.dumps(routes, indent=2))
|
||||
tmp.chmod(0o600)
|
||||
tmp.replace(path)
|
||||
|
||||
|
||||
def _do_get_internet(name):
|
||||
"""Current internet-exposure state for one installed app.
|
||||
|
||||
404s for apps that aren't installed or aren't internet.viable — the UI
|
||||
only ever renders the toggle for viable, installed apps, so either
|
||||
case means this request shouldn't have been made.
|
||||
"""
|
||||
m, _values, installed = _load_manifest_for(name)
|
||||
if m is None or not installed:
|
||||
return 404, {"error": f"{name!r} is not installed"}
|
||||
if not m.internet.viable:
|
||||
return 404, {"error": f"{name!r} is not internet-viable"}
|
||||
entry = _internet_routes().get(name)
|
||||
if entry is None:
|
||||
return 200, {"enabled": False}
|
||||
return 200, {"enabled": True, "public_url": entry.get("public_url")}
|
||||
|
||||
|
||||
def _do_set_internet(name, payload):
|
||||
"""Publish or unpublish an app through the connected gateway.
|
||||
|
||||
Synchronous — a plain HTTP call to the gateway's control plane, no
|
||||
image pull involved, same posture as _do_update_settings, not the
|
||||
async+poll pattern _do_gateway_connect needs.
|
||||
"""
|
||||
from furtka import gateway
|
||||
|
||||
enabled = payload.get("enabled")
|
||||
if not isinstance(enabled, bool):
|
||||
return 400, {"error": "'enabled' (bool) is required"}
|
||||
|
||||
m, _values, installed = _load_manifest_for(name)
|
||||
if m is None or not installed:
|
||||
return 404, {"error": f"{name!r} is not installed"}
|
||||
if not m.internet.viable:
|
||||
return 400, {"error": f"{name!r} is not internet-viable"}
|
||||
|
||||
if gateway.load_config() is None:
|
||||
return 409, {"error": "this box is not connected to a gateway"}
|
||||
|
||||
routes = _internet_routes()
|
||||
|
||||
if enabled:
|
||||
subdomain = payload.get("subdomain")
|
||||
if not subdomain:
|
||||
return 400, {"error": "'subdomain' is required to publish"}
|
||||
try:
|
||||
result = gateway.publish_route(name, subdomain, m.internet.port)
|
||||
except gateway.GatewayError as e:
|
||||
return 502, {"error": str(e)}
|
||||
routes[name] = {"route_id": result["route_id"], "public_url": result["public_url"]}
|
||||
_save_internet_routes(routes)
|
||||
return 200, {"enabled": True, "public_url": result["public_url"]}
|
||||
|
||||
entry = routes.pop(name, None)
|
||||
if entry is None:
|
||||
return 200, {"enabled": False}
|
||||
try:
|
||||
gateway.unpublish_route(entry["route_id"])
|
||||
except gateway.GatewayError as e:
|
||||
return 502, {"error": str(e)}
|
||||
_save_internet_routes(routes)
|
||||
return 200, {"enabled": False}
|
||||
|
||||
|
||||
_POWER_ACTIONS = {
|
||||
"reboot": "reboot",
|
||||
"poweroff": "poweroff",
|
||||
|
|
@ -1551,33 +1238,7 @@ def _parse_settings_body(payload):
|
|||
return out
|
||||
|
||||
|
||||
# Largest request body we read. Every legitimate body is a small JSON
|
||||
# object; without a cap a LAN client could make us buffer gigabytes.
|
||||
MAX_BODY_BYTES = 1024 * 1024
|
||||
|
||||
# The server is threaded so status polls and page loads keep answering while
|
||||
# a slow request (image pull, reconcile) runs. Requests that change state
|
||||
# still run one at a time, as they did on the single-threaded server.
|
||||
_MUTATION_LOCK = threading.Lock()
|
||||
# First-run admin creation is check-then-write; two setup POSTs racing on
|
||||
# the threaded server must not both create an admin.
|
||||
_SETUP_LOCK = threading.Lock()
|
||||
|
||||
_USERS_FILE_BROKEN = (
|
||||
"The login file on this box (/var/lib/furtka/users.json) is damaged. "
|
||||
"Log in over SSH, delete that file, then reload this page to set a new admin password."
|
||||
)
|
||||
|
||||
|
||||
def _valid_app_name(name) -> bool:
|
||||
return isinstance(name, str) and APP_NAME_RE.fullmatch(name) is not None
|
||||
|
||||
|
||||
class _Handler(BaseHTTPRequestHandler):
|
||||
# Socket read timeout: a client that stops sending mid-request gets
|
||||
# dropped instead of holding a worker forever.
|
||||
timeout = 30
|
||||
|
||||
def _json(self, status, payload, extra_headers=None):
|
||||
body = json.dumps(payload).encode()
|
||||
self.send_response(status)
|
||||
|
|
@ -1686,14 +1347,6 @@ class _Handler(BaseHTTPRequestHandler):
|
|||
return self._json(400, {"error": "password is required"})
|
||||
username = username.strip()
|
||||
|
||||
try:
|
||||
with _SETUP_LOCK:
|
||||
return self._login_or_setup(payload, username, password)
|
||||
except auth.UsersFileError:
|
||||
traceback.print_exc()
|
||||
return self._json(503, {"error": _USERS_FILE_BROKEN})
|
||||
|
||||
def _login_or_setup(self, payload, username, password):
|
||||
if auth.setup_needed():
|
||||
# First-run setup path — create the admin account, then log
|
||||
# in. Require password2 so a typo doesn't lock the user out
|
||||
|
|
@ -1740,39 +1393,13 @@ class _Handler(BaseHTTPRequestHandler):
|
|||
auth.SESSIONS.revoke(morsel.value)
|
||||
return self._json(200, {"ok": True}, extra_headers=[self._clear_cookie_header()])
|
||||
|
||||
def _internal_error(self):
|
||||
# Without this, an unexpected exception makes socketserver drop the
|
||||
# connection and the UI shows "Failed to fetch" with nothing to go on.
|
||||
traceback.print_exc()
|
||||
try:
|
||||
self._json(500, {"error": "internal error — see `journalctl -u furtka-api`"})
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
def do_GET(self): # noqa: N802 — http.server convention
|
||||
try:
|
||||
self._route_get()
|
||||
except Exception:
|
||||
self._internal_error()
|
||||
|
||||
def do_POST(self): # noqa: N802
|
||||
try:
|
||||
self._route_post()
|
||||
except Exception:
|
||||
self._internal_error()
|
||||
|
||||
def _route_get(self):
|
||||
# --- Public routes: login page + its assets ------------------
|
||||
if self.path in ("/login", "/login/"):
|
||||
# Already authed? Skip straight to the app list.
|
||||
if self._current_session() is not None:
|
||||
return self._redirect("/apps")
|
||||
try:
|
||||
setup = auth.setup_needed()
|
||||
except auth.UsersFileError:
|
||||
traceback.print_exc()
|
||||
return self._html(503, f"<h1>Login unavailable</h1><p>{_USERS_FILE_BROKEN}</p>")
|
||||
return self._html(200, _render_login_html(setup))
|
||||
return self._html(200, _render_login_html(auth.setup_needed()))
|
||||
|
||||
# --- Auth guard for everything below -------------------------
|
||||
session = self._current_session()
|
||||
|
|
@ -1817,42 +1444,17 @@ class _Handler(BaseHTTPRequestHandler):
|
|||
if self.path == "/api/apps/install/status":
|
||||
status, body = _do_install_status()
|
||||
return self._json(status, body)
|
||||
if self.path == "/api/gateway/status":
|
||||
status, body = _do_gateway_status()
|
||||
return self._json(status, body)
|
||||
if self.path == "/api/gateway/connect/status":
|
||||
status, body = _do_gateway_connect_status()
|
||||
return self._json(status, body)
|
||||
# /api/apps/<name>/settings
|
||||
if self.path.startswith("/api/apps/") and self.path.endswith("/settings"):
|
||||
name = self.path[len("/api/apps/") : -len("/settings")]
|
||||
if not _valid_app_name(name):
|
||||
if "/" in name or not name:
|
||||
return self._json(400, {"error": "invalid app name"})
|
||||
status, body = _do_get_settings(name)
|
||||
return self._json(status, body)
|
||||
# /api/apps/<name>/internet
|
||||
if self.path.startswith("/api/apps/") and self.path.endswith("/internet"):
|
||||
name = self.path[len("/api/apps/") : -len("/internet")]
|
||||
if "/" in name or not name:
|
||||
return self._json(400, {"error": "invalid app name"})
|
||||
status, body = _do_get_internet(name)
|
||||
return self._json(status, body)
|
||||
self._json(404, {"error": "not found"})
|
||||
|
||||
def _route_post(self):
|
||||
# Browsers tag every request with where it came from. Only accept
|
||||
# state changes from our own pages — an app on another port of the
|
||||
# same host counts as "same-site" and would pass SameSite=Strict.
|
||||
# Old browsers that don't send the header fall back to the cookie.
|
||||
fetch_site = self.headers.get("Sec-Fetch-Site")
|
||||
if fetch_site is not None and fetch_site not in ("same-origin", "none"):
|
||||
return self._json(403, {"error": "cross-site request refused"})
|
||||
try:
|
||||
length = int(self.headers.get("Content-Length", "0"))
|
||||
except ValueError:
|
||||
return self._json(400, {"error": "invalid Content-Length"})
|
||||
if length < 0 or length > MAX_BODY_BYTES:
|
||||
return self._json(413, {"error": "request body too large"})
|
||||
def do_POST(self): # noqa: N802
|
||||
length = int(self.headers.get("Content-Length", "0"))
|
||||
raw = self.rfile.read(length) if length else b""
|
||||
try:
|
||||
payload = json.loads(raw.decode()) if raw else {}
|
||||
|
|
@ -1871,15 +1473,10 @@ class _Handler(BaseHTTPRequestHandler):
|
|||
if self._current_session() is None:
|
||||
return self._json(401, {"error": "not authenticated"})
|
||||
|
||||
with _MUTATION_LOCK:
|
||||
return self._route_authed_post(payload)
|
||||
|
||||
def _route_authed_post(self, payload):
|
||||
|
||||
# Per-app settings update: /api/apps/<name>/settings
|
||||
if self.path.startswith("/api/apps/") and self.path.endswith("/settings"):
|
||||
name = self.path[len("/api/apps/") : -len("/settings")]
|
||||
if not _valid_app_name(name):
|
||||
if "/" in name or not name:
|
||||
return self._json(400, {"error": "invalid app name"})
|
||||
settings = _parse_settings_body(payload)
|
||||
if settings is False or settings is None:
|
||||
|
|
@ -1890,25 +1487,9 @@ class _Handler(BaseHTTPRequestHandler):
|
|||
# Per-app image update: /api/apps/<name>/update
|
||||
if self.path.startswith("/api/apps/") and self.path.endswith("/update"):
|
||||
name = self.path[len("/api/apps/") : -len("/update")]
|
||||
if not _valid_app_name(name):
|
||||
return self._json(400, {"error": "invalid app name"})
|
||||
status, body = _do_update(name)
|
||||
return self._json(status, body)
|
||||
|
||||
# Per-app internet-exposure toggle: /api/apps/<name>/internet
|
||||
if self.path.startswith("/api/apps/") and self.path.endswith("/internet"):
|
||||
name = self.path[len("/api/apps/") : -len("/internet")]
|
||||
if "/" in name or not name:
|
||||
return self._json(400, {"error": "invalid app name"})
|
||||
status, body = _do_set_internet(name, payload)
|
||||
return self._json(status, body)
|
||||
|
||||
# This box's furtka-gateway connection: connect / disconnect.
|
||||
if self.path == "/api/gateway/connect":
|
||||
status, body = _do_gateway_connect(payload)
|
||||
return self._json(status, body)
|
||||
if self.path == "/api/gateway/disconnect":
|
||||
status, body = _do_gateway_disconnect()
|
||||
status, body = _do_update(name)
|
||||
return self._json(status, body)
|
||||
|
||||
# Furtka itself: check + apply endpoints (Phase 2 self-update).
|
||||
|
|
@ -1938,8 +1519,6 @@ class _Handler(BaseHTTPRequestHandler):
|
|||
name = payload.get("name")
|
||||
if not isinstance(name, str) or not name:
|
||||
return self._json(400, {"error": "missing or empty 'name' field"})
|
||||
if not _valid_app_name(name):
|
||||
return self._json(400, {"error": "invalid app name"})
|
||||
|
||||
if self.path == "/api/apps/install/plan":
|
||||
status, body = _do_install_plan(name)
|
||||
|
|
@ -1962,8 +1541,7 @@ class _Handler(BaseHTTPRequestHandler):
|
|||
|
||||
def serve(host: str = "127.0.0.1", port: int = 7000) -> None:
|
||||
"""Run the API server. Blocks forever; exits on SIGINT/SIGTERM."""
|
||||
server = ThreadingHTTPServer((host, port), _Handler)
|
||||
server.daemon_threads = True
|
||||
server = HTTPServer((host, port), _Handler)
|
||||
print(f"Furtka API listening on http://{host}:{port}/")
|
||||
try:
|
||||
server.serve_forever()
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ from __future__ import annotations
|
|||
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import secrets
|
||||
import threading
|
||||
from dataclasses import dataclass
|
||||
|
|
@ -47,33 +46,27 @@ def verify_password(plain: str, hashed: str) -> bool:
|
|||
return _verify_password(plain, hashed)
|
||||
|
||||
|
||||
class UsersFileError(RuntimeError):
|
||||
"""users.json exists but can't be read or parsed."""
|
||||
|
||||
|
||||
def load_users() -> dict:
|
||||
"""Return the users dict, or {} if the file is missing.
|
||||
"""Return the users dict, or {} if the file is missing or empty.
|
||||
|
||||
Missing-file is the expected state on first boot and on upgrades from
|
||||
pre-auth versions — callers treat empty-dict as "setup required".
|
||||
|
||||
A file that exists but is unreadable, empty or corrupt raises
|
||||
UsersFileError instead: treating it as "no admin yet" would turn /login
|
||||
into an open "create admin" form for anyone on the network.
|
||||
"""
|
||||
path = users_file()
|
||||
if not path.exists():
|
||||
return {}
|
||||
try:
|
||||
raw = path.read_text()
|
||||
except FileNotFoundError:
|
||||
except OSError:
|
||||
return {}
|
||||
if not raw.strip():
|
||||
return {}
|
||||
except (OSError, UnicodeDecodeError) as e:
|
||||
raise UsersFileError(f"{path} is unreadable: {e}") from e
|
||||
try:
|
||||
data = json.loads(raw)
|
||||
except json.JSONDecodeError as e:
|
||||
raise UsersFileError(f"{path} is corrupt: {e}") from e
|
||||
except json.JSONDecodeError:
|
||||
return {}
|
||||
if not isinstance(data, dict):
|
||||
raise UsersFileError(f"{path} is corrupt: not a JSON object")
|
||||
return {}
|
||||
return data
|
||||
|
||||
|
||||
|
|
@ -87,12 +80,7 @@ def save_users(users: dict) -> None:
|
|||
path = users_file()
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
tmp = path.with_suffix(path.suffix + ".tmp")
|
||||
with open(tmp, "w") as fh:
|
||||
fh.write(json.dumps(users, indent=2) + "\n")
|
||||
# A power cut right after rename() can otherwise leave a zero-length
|
||||
# users.json, which load_users() refuses — locking the owner out.
|
||||
fh.flush()
|
||||
os.fsync(fh.fileno())
|
||||
tmp.write_text(json.dumps(users, indent=2) + "\n")
|
||||
tmp.chmod(0o600)
|
||||
tmp.replace(path)
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ from __future__ import annotations
|
|||
import fcntl
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import time
|
||||
from dataclasses import dataclass
|
||||
|
|
@ -151,9 +150,6 @@ def acquire_lock():
|
|||
return fh
|
||||
|
||||
|
||||
_PRIVILEGED_RE = re.compile(r"^\s*privileged:\s*true\s*$", re.MULTILINE)
|
||||
|
||||
|
||||
def _validate_staging(staging: Path, expected_version: str) -> None:
|
||||
"""Fail hard if the staging tree isn't a well-formed catalog release."""
|
||||
version_file = staging / _VERSION_FILE
|
||||
|
|
@ -174,23 +170,10 @@ def _validate_staging(staging: Path, expected_version: str) -> None:
|
|||
if not manifest_path.exists():
|
||||
raise CatalogError(f"catalog app {entry.name!r} has no manifest.json")
|
||||
try:
|
||||
manifest = load_manifest(manifest_path, expected_name=entry.name)
|
||||
load_manifest(manifest_path, expected_name=entry.name)
|
||||
except ManifestError as e:
|
||||
raise CatalogError(f"catalog app {entry.name!r}: invalid manifest: {e}") from e
|
||||
|
||||
if manifest.internet.viable:
|
||||
compose_path = entry / "docker-compose.yaml"
|
||||
if compose_path.exists() and _PRIVILEGED_RE.search(compose_path.read_text()):
|
||||
# Not a network-mode check — Traefik reaches a host-networked
|
||||
# container's port exactly like a bridge-published one. The
|
||||
# real risk of `internet.viable: true` here is a compromised
|
||||
# internet-facing container also having host device/kernel
|
||||
# access, which `privileged: true` grants outright.
|
||||
raise CatalogError(
|
||||
f"catalog app {entry.name!r}: internet.viable apps must not run "
|
||||
"privileged (docker-compose.yaml sets privileged: true)"
|
||||
)
|
||||
|
||||
|
||||
def _atomic_swap(staging: Path) -> None:
|
||||
"""Move staging → live catalog, keeping the previous tree as .prev until
|
||||
|
|
@ -233,9 +216,6 @@ def sync_catalog() -> CatalogCheck:
|
|||
except CatalogError as e:
|
||||
write_state("error", error=str(e))
|
||||
raise
|
||||
except Exception as e:
|
||||
write_state("error", error=str(e) or type(e).__name__)
|
||||
raise CatalogError(str(e) or type(e).__name__) from e
|
||||
|
||||
|
||||
def _sync_locked() -> CatalogCheck:
|
||||
|
|
|
|||
|
|
@ -46,10 +46,6 @@ def _cmd_app_list(args: argparse.Namespace) -> int:
|
|||
}
|
||||
for req in r.manifest.requires
|
||||
],
|
||||
"internet": {
|
||||
"viable": r.manifest.internet.viable,
|
||||
"port": r.manifest.internet.port,
|
||||
},
|
||||
}
|
||||
if r.manifest
|
||||
else None,
|
||||
|
|
@ -175,25 +171,6 @@ def _cmd_app_remove(args: argparse.Namespace) -> int:
|
|||
return 0
|
||||
|
||||
|
||||
def _cmd_gateway_connect_bg(args: argparse.Namespace) -> int:
|
||||
"""Register + bring up the tunnel — called by the API via systemd-run.
|
||||
|
||||
Internal subcommand; the UI drives this through
|
||||
`POST /api/gateway/connect`, which does fast input validation
|
||||
synchronously and dispatches this the same way `app install` dispatches
|
||||
`app install-bg`.
|
||||
"""
|
||||
from furtka import gateway
|
||||
|
||||
try:
|
||||
gateway.run_connect(args.gateway_url, args.registration_token, args.box_name)
|
||||
except Exception as e:
|
||||
# run_connect already wrote state="error"; echo for journald.
|
||||
print(f"gateway connect-bg failed: {e}", file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
def _cmd_serve(args: argparse.Namespace) -> int:
|
||||
# Imported lazily so `furtka` startup stays cheap when the user only runs
|
||||
# `app list` or `reconcile` (the common case during tests + scripts).
|
||||
|
|
@ -422,20 +399,6 @@ def build_parser() -> argparse.ArgumentParser:
|
|||
)
|
||||
catalog_status.set_defaults(func=_cmd_catalog_status)
|
||||
|
||||
gateway = sub.add_parser("gateway", help="Manage this box's furtka-gateway connection")
|
||||
gateway_sub = gateway.add_subparsers(dest="subcommand", required=True)
|
||||
|
||||
# Internal — called by the HTTP API via systemd-run. Deliberately
|
||||
# omitted from the help listing, same as `app install-bg`.
|
||||
gateway_connect_bg = gateway_sub.add_parser(
|
||||
"connect-bg",
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
gateway_connect_bg.add_argument("gateway_url")
|
||||
gateway_connect_bg.add_argument("registration_token")
|
||||
gateway_connect_bg.add_argument("box_name")
|
||||
gateway_connect_bg.set_defaults(func=_cmd_gateway_connect_bg)
|
||||
|
||||
return p
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,246 +0,0 @@
|
|||
"""Client for a Furtka box registering with (and talking to) a
|
||||
furtka-gateway.
|
||||
|
||||
Talks to the gateway's `/v1/boxes/*` API (see the furtka-gateway repo's
|
||||
`control_plane/api.py` for the server side) using the same stdlib-only
|
||||
`urllib.request` convention as `_release_common.py`/`updater.py` — no new
|
||||
dependency for this.
|
||||
|
||||
`register()` persists the result to `paths.gateway_config_file()` (0600,
|
||||
atomic write — the same tmp-file-then-replace pattern `auth.save_users`
|
||||
uses) so later calls don't need the box to re-register, and so
|
||||
`/api/gateway/status` has something to read without holding a live
|
||||
connection open.
|
||||
|
||||
`run_connect()` plus the state/lock helpers below follow the exact shape
|
||||
of furtka.catalog's own state/lock functions — this module is the
|
||||
"runner" `furtka gateway connect-bg` calls after `api.py`'s
|
||||
`POST /api/gateway/connect` dispatches it via systemd-run, the same
|
||||
async-with-state-file-polling idiom used for install/update/catalog-sync.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import fcntl
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
from furtka import wireguard
|
||||
from furtka.paths import gateway_config_file
|
||||
|
||||
_CONNECT_STATE = Path(
|
||||
os.environ.get("FURTKA_GATEWAY_CONNECT_STATE", "/var/lib/furtka/gateway-connect-state.json")
|
||||
)
|
||||
_CONNECT_LOCK = Path(
|
||||
os.environ.get("FURTKA_GATEWAY_CONNECT_LOCK", "/run/furtka/gateway-connect.lock")
|
||||
)
|
||||
|
||||
|
||||
class GatewayError(Exception):
|
||||
"""Recoverable failure talking to a furtka-gateway — the caller should 5xx."""
|
||||
|
||||
|
||||
def _request(method: str, url: str, body: dict | None = None, *, token: str | None = None) -> dict:
|
||||
data = json.dumps(body).encode() if body is not None else None
|
||||
headers = {}
|
||||
if data is not None:
|
||||
headers["Content-Type"] = "application/json"
|
||||
if token:
|
||||
headers["Authorization"] = f"Bearer {token}"
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=15) as resp:
|
||||
return json.loads(resp.read())
|
||||
except urllib.error.HTTPError as e:
|
||||
detail = e.read().decode(errors="replace")
|
||||
raise GatewayError(f"{method} {url} -> HTTP {e.code}: {detail}") from e
|
||||
except urllib.error.URLError as e:
|
||||
raise GatewayError(f"{method} {url}: {e}") from e
|
||||
|
||||
|
||||
def _post(url: str, body: dict, *, token: str | None = None) -> dict:
|
||||
return _request("POST", url, body, token=token)
|
||||
|
||||
|
||||
def _delete(url: str, *, token: str | None = None) -> dict:
|
||||
return _request("DELETE", url, token=token)
|
||||
|
||||
|
||||
def _save_config(config: dict) -> None:
|
||||
path = gateway_config_file()
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
tmp = path.with_suffix(path.suffix + ".tmp")
|
||||
tmp.write_text(json.dumps(config, indent=2) + "\n")
|
||||
tmp.chmod(0o600)
|
||||
tmp.replace(path)
|
||||
|
||||
|
||||
def load_config() -> dict | None:
|
||||
"""Return the persisted {gateway_url, box_id, box_token, wg} config, or
|
||||
None if this box has never registered with a gateway."""
|
||||
path = gateway_config_file()
|
||||
if not path.is_file():
|
||||
return None
|
||||
return json.loads(path.read_text())
|
||||
|
||||
|
||||
def register(gateway_url: str, registration_token: str, box_name: str) -> dict:
|
||||
"""Register this box with a furtka-gateway.
|
||||
|
||||
No local keypair is generated here — the gateway's response carries the
|
||||
full WireGuard interface config, private key included (see
|
||||
furtka-gateway's `wgeasy.py` module docstring for why stock wg-easy
|
||||
makes that unavoidable). Persists and returns
|
||||
{gateway_url, box_id, box_token, wg}.
|
||||
"""
|
||||
gateway_url = gateway_url.rstrip("/")
|
||||
result = _post(
|
||||
f"{gateway_url}/v1/boxes/register",
|
||||
{"registration_token": registration_token, "box_name": box_name},
|
||||
)
|
||||
config = {
|
||||
"gateway_url": gateway_url,
|
||||
"box_id": result["box_id"],
|
||||
"box_token": result["box_token"],
|
||||
"wg": result["wg"],
|
||||
}
|
||||
_save_config(config)
|
||||
return config
|
||||
|
||||
|
||||
def rotate_token() -> str:
|
||||
"""Ask the gateway for a new box token, replacing the stored one."""
|
||||
config = load_config()
|
||||
if config is None:
|
||||
raise GatewayError("not connected to a gateway")
|
||||
result = _post(
|
||||
f"{config['gateway_url']}/v1/boxes/{config['box_id']}/rotate-token",
|
||||
{},
|
||||
token=config["box_token"],
|
||||
)
|
||||
config["box_token"] = result["box_token"]
|
||||
_save_config(config)
|
||||
return config["box_token"]
|
||||
|
||||
|
||||
def deregister() -> None:
|
||||
"""Tell the gateway to forget this box, then drop the local config.
|
||||
|
||||
Raises on a failed gateway call rather than silently clearing local
|
||||
state — a box that can't reach the gateway should stay "connected"
|
||||
locally so the operation can be retried, instead of losing its
|
||||
box_token while the gateway's own row (and the wg-easy peer / any
|
||||
published routes) linger orphaned.
|
||||
"""
|
||||
config = load_config()
|
||||
if config is None:
|
||||
return
|
||||
_post(
|
||||
f"{config['gateway_url']}/v1/boxes/{config['box_id']}/deregister",
|
||||
{},
|
||||
token=config["box_token"],
|
||||
)
|
||||
gateway_config_file().unlink(missing_ok=True)
|
||||
|
||||
|
||||
def publish_route(app_name: str, subdomain: str, port: int) -> dict:
|
||||
"""Publish `app_name` at `subdomain` through the connected gateway.
|
||||
|
||||
Returns {route_id, public_url}. The gateway independently re-validates
|
||||
subdomain/port server-side regardless of what's sent here — see
|
||||
furtka-gateway's routes.py — this call just carries the box owner's
|
||||
request, it isn't itself the security boundary.
|
||||
"""
|
||||
config = load_config()
|
||||
if config is None:
|
||||
raise GatewayError("not connected to a gateway")
|
||||
return _post(
|
||||
f"{config['gateway_url']}/v1/routes",
|
||||
{"app_name": app_name, "subdomain": subdomain, "port": port},
|
||||
token=config["box_token"],
|
||||
)
|
||||
|
||||
|
||||
def unpublish_route(route_id: str) -> None:
|
||||
config = load_config()
|
||||
if config is None:
|
||||
raise GatewayError("not connected to a gateway")
|
||||
_delete(f"{config['gateway_url']}/v1/routes/{route_id}", token=config["box_token"])
|
||||
|
||||
|
||||
def state_path() -> Path:
|
||||
return _CONNECT_STATE
|
||||
|
||||
|
||||
def lock_path() -> Path:
|
||||
return _CONNECT_LOCK
|
||||
|
||||
|
||||
def write_state(stage: str, **extra) -> None:
|
||||
"""Atomic JSON state write — same shape as catalog/update-state."""
|
||||
state_path().parent.mkdir(parents=True, exist_ok=True)
|
||||
tmp = state_path().with_suffix(".tmp")
|
||||
payload = {"stage": stage, "updated_at": time.strftime("%Y-%m-%dT%H:%M:%S%z"), **extra}
|
||||
tmp.write_text(json.dumps(payload, indent=2))
|
||||
tmp.replace(state_path())
|
||||
|
||||
|
||||
def read_state() -> dict:
|
||||
try:
|
||||
return json.loads(state_path().read_text())
|
||||
except (FileNotFoundError, json.JSONDecodeError):
|
||||
return {}
|
||||
|
||||
|
||||
def acquire_lock():
|
||||
path = lock_path()
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
fh = path.open("w")
|
||||
try:
|
||||
fcntl.flock(fh, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
except BlockingIOError as e:
|
||||
fh.close()
|
||||
raise GatewayError("another gateway connect is already in progress") from e
|
||||
return fh
|
||||
|
||||
|
||||
def run_connect(gateway_url: str, registration_token: str, box_name: str) -> None:
|
||||
"""Register with the gateway, then bring the tunnel up — the slow part
|
||||
`furtka gateway connect-bg` runs in the background (dispatched via
|
||||
systemd-run from `POST /api/gateway/connect`), writing state
|
||||
transitions as it goes so the UI can poll instead of the request
|
||||
thread blocking on a slow/unreachable gateway.
|
||||
|
||||
A registration saved by an earlier attempt whose tunnel failed to come
|
||||
up is reused rather than registering again — re-registering would leave
|
||||
the first box (and its wg-easy peer) orphaned on the gateway.
|
||||
"""
|
||||
existing = load_config()
|
||||
if existing is not None:
|
||||
if existing["gateway_url"] != gateway_url.rstrip("/"):
|
||||
write_state(
|
||||
"error",
|
||||
error=f"already registered with {existing['gateway_url']} — disconnect first",
|
||||
)
|
||||
return
|
||||
config = existing
|
||||
else:
|
||||
write_state("registering")
|
||||
try:
|
||||
config = register(gateway_url, registration_token, box_name)
|
||||
except GatewayError as e:
|
||||
write_state("error", error=str(e))
|
||||
return
|
||||
|
||||
write_state("starting_tunnel")
|
||||
try:
|
||||
wireguard.set_tunnel_enabled(True, wg=config["wg"])
|
||||
except wireguard.WireguardError as e:
|
||||
write_state("error", error=str(e))
|
||||
return
|
||||
|
||||
write_state("done")
|
||||
|
|
@ -36,11 +36,7 @@ from pathlib import Path
|
|||
CA_CERT_PATH = Path("/var/lib/caddy/pki/authorities/local/root.crt")
|
||||
SNIPPET_DIR = Path("/etc/caddy/furtka.d")
|
||||
REDIRECT_SNIPPET = SNIPPET_DIR / "redirect.caddyfile"
|
||||
# Pre-26.21 redirect: permanent (browsers cache a 301 indefinitely, so
|
||||
# turning HTTPS off left them bouncing to a dead :443) and for every Host —
|
||||
# including a bare IP, which has no certificate, so devices that reach the
|
||||
# box by IP (no mDNS on Android / older Windows) couldn't load the UI at all.
|
||||
LEGACY_REDIRECT_CONTENT = "redir https://{host}{uri} permanent\n"
|
||||
REDIRECT_CONTENT = "redir https://{host}{uri} permanent\n"
|
||||
HTTPS_SNIPPET_DIR = Path("/etc/caddy/furtka-https.d")
|
||||
HTTPS_SNIPPET = HTTPS_SNIPPET_DIR / "https.caddyfile"
|
||||
HOSTNAME_FILE = Path("/etc/hostname")
|
||||
|
|
@ -66,19 +62,6 @@ def _read_hostname(hostname_file: Path = HOSTNAME_FILE) -> str:
|
|||
return value or "furtka"
|
||||
|
||||
|
||||
def _redirect_snippet_content(hostname: str) -> str:
|
||||
"""HTTP→HTTPS redirect for the names the HTTPS block has a cert for.
|
||||
|
||||
Only those hosts are redirected: an IP or any other name keeps plain
|
||||
HTTP instead of landing on a TLS handshake that can't succeed. 302 so
|
||||
switching HTTPS off takes effect in browsers immediately.
|
||||
"""
|
||||
return (
|
||||
f"@furtka_https_host host {hostname}.local {hostname}\n"
|
||||
"redir @furtka_https_host https://{host}{uri} 302\n"
|
||||
)
|
||||
|
||||
|
||||
def _https_snippet_content(hostname: str) -> str:
|
||||
"""Caddy site block the HTTPS toggle installs at opt-in.
|
||||
|
||||
|
|
@ -168,9 +151,8 @@ def set_force_https(
|
|||
previous_https = https_snippet.read_text() if had_https else None
|
||||
|
||||
if enabled:
|
||||
hostname = _read_hostname(hostname_file)
|
||||
snippet.write_text(_redirect_snippet_content(hostname))
|
||||
https_snippet.write_text(_https_snippet_content(hostname))
|
||||
snippet.write_text(REDIRECT_CONTENT)
|
||||
https_snippet.write_text(_https_snippet_content(_read_hostname(hostname_file)))
|
||||
else:
|
||||
if had_redirect:
|
||||
snippet.unlink()
|
||||
|
|
|
|||
|
|
@ -91,53 +91,9 @@ def write_state(stage: str, **extra) -> None:
|
|||
|
||||
def read_state() -> dict:
|
||||
try:
|
||||
data = json.loads(state_path().read_text())
|
||||
except (OSError, UnicodeDecodeError, json.JSONDecodeError):
|
||||
return json.loads(state_path().read_text())
|
||||
except (FileNotFoundError, json.JSONDecodeError):
|
||||
return {}
|
||||
return data if isinstance(data, dict) else {}
|
||||
|
||||
|
||||
TERMINAL_STAGES = frozenset({"done", "error"})
|
||||
|
||||
# How old an unfinished state must be before we believe the job is gone.
|
||||
# Covers the gap between the API writing the first stage and the detached
|
||||
# runner taking the lock.
|
||||
_STALE_AFTER_SECONDS = 60
|
||||
|
||||
|
||||
def clear_stale_state(now: float | None = None) -> bool:
|
||||
"""Mark an unfinished install as failed if no runner is alive any more.
|
||||
|
||||
install-state.json lives in /var/lib and survives reboots, OOM kills and
|
||||
a runner that never started — each of which used to block every later
|
||||
install with "another install is in progress" until someone fixed it
|
||||
over SSH. The runner holds the flock for its whole run, so a free lock
|
||||
plus an old timestamp means nobody is coming back to finish. Returns
|
||||
True when it reset the state.
|
||||
"""
|
||||
state = read_state()
|
||||
stage = state.get("stage", "")
|
||||
if not stage or stage in TERMINAL_STAGES:
|
||||
return False
|
||||
try:
|
||||
updated = time.mktime(time.strptime(state.get("updated_at", ""), "%Y-%m-%dT%H:%M:%S%z"))
|
||||
except (TypeError, ValueError):
|
||||
updated = 0.0
|
||||
if (now if now is not None else time.time()) - updated < _STALE_AFTER_SECONDS:
|
||||
return False
|
||||
try:
|
||||
fh = acquire_lock()
|
||||
except (InstallRunnerError, OSError):
|
||||
return False # a runner is still working
|
||||
try:
|
||||
write_state(
|
||||
"error",
|
||||
app=state.get("app", ""),
|
||||
error=f"the install was interrupted at '{stage}' (restart or crash) — try again",
|
||||
)
|
||||
finally:
|
||||
fh.close()
|
||||
return True
|
||||
|
||||
|
||||
def _read_plan(target: str) -> dict:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import shutil
|
|||
from pathlib import Path
|
||||
|
||||
from furtka import sources
|
||||
from furtka.manifest import APP_NAME_RE, Manifest, ManifestError, load_manifest
|
||||
from furtka.manifest import Manifest, ManifestError, load_manifest
|
||||
from furtka.paths import apps_dir
|
||||
|
||||
# Values that an app's .env.example may use as obvious "fill me in" markers.
|
||||
|
|
@ -35,26 +35,19 @@ class InstallError(RuntimeError):
|
|||
pass
|
||||
|
||||
|
||||
def app_dir(name: str) -> Path:
|
||||
"""/var/lib/furtka/apps/<name>, refusing anything that isn't a plain app name.
|
||||
|
||||
Names reach us from API bodies and URL paths; without this check "..",
|
||||
"." or "/" would point remove()'s rmtree at /var/lib/furtka, every app,
|
||||
or the root filesystem.
|
||||
"""
|
||||
if not isinstance(name, str) or not APP_NAME_RE.fullmatch(name):
|
||||
raise InstallError(f"{name!r} is not a valid app name")
|
||||
return apps_dir() / name
|
||||
|
||||
|
||||
def _placeholder_values(values: dict[str, str]) -> list[str]:
|
||||
return [k for k, v in values.items() if v.strip() in PLACEHOLDER_SECRETS]
|
||||
|
||||
|
||||
def _placeholder_keys(env_path: Path) -> list[str]:
|
||||
if not env_path.exists():
|
||||
return []
|
||||
return _placeholder_values(_read_env(env_path))
|
||||
bad: list[str] = []
|
||||
for raw in env_path.read_text().splitlines():
|
||||
line = raw.strip()
|
||||
if not line or line.startswith("#") or "=" not in line:
|
||||
continue
|
||||
key, _, value = line.partition("=")
|
||||
value = value.strip().strip('"').strip("'")
|
||||
if value in PLACEHOLDER_SECRETS:
|
||||
bad.append(key.strip())
|
||||
return bad
|
||||
|
||||
|
||||
def _is_denied_system_path(resolved: str) -> bool:
|
||||
|
|
@ -66,13 +59,16 @@ def _is_denied_system_path(resolved: str) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def _path_setting_errors(m: Manifest, values: dict[str, str]) -> list[str]:
|
||||
def _path_setting_errors(m: Manifest, env_path: Path) -> list[str]:
|
||||
"""Validate the filesystem paths named by `path`-type settings.
|
||||
|
||||
Returns one human-readable message per offending setting. Empty values
|
||||
on non-required settings are allowed — the required-field check in the
|
||||
caller already refuses blanks on required fields before write.
|
||||
"""
|
||||
if not env_path.exists():
|
||||
return []
|
||||
values = _read_env(env_path)
|
||||
errors: list[str] = []
|
||||
for s in m.settings:
|
||||
if s.type != "path":
|
||||
|
|
@ -101,35 +97,10 @@ def _path_setting_errors(m: Manifest, values: dict[str, str]) -> list[str]:
|
|||
return errors
|
||||
|
||||
|
||||
def _validate_settings(m: Manifest, values: dict[str, str]) -> None:
|
||||
"""Refuse a merged settings view before it is written to .env.
|
||||
|
||||
Runs in memory so a rejected value (placeholder, system path, line
|
||||
break) never reaches the live .env where the next reconcile would use it.
|
||||
"""
|
||||
for k, v in values.items():
|
||||
if any(c in v for c in "\r\n\0"):
|
||||
raise InstallError(f"{m.name}: setting {k!r} must not contain line breaks")
|
||||
bad = _placeholder_values({s.name: values.get(s.name, "") for s in m.settings})
|
||||
if bad:
|
||||
raise InstallError(
|
||||
f"{m.name}: please replace the example value for {', '.join(bad)} with your own"
|
||||
)
|
||||
path_errors = _path_setting_errors(m, values)
|
||||
if path_errors:
|
||||
raise InstallError(f"{m.name}: {'; '.join(path_errors)}")
|
||||
|
||||
|
||||
def _format_env_value(v: str) -> str:
|
||||
# Quote values that contain whitespace, quotes, or shell metacharacters so
|
||||
# docker-compose's env substitution reads them back intact. Simple values
|
||||
# stay unquoted to keep the file readable when a user SSHes in.
|
||||
if any(c in v for c in "\r\n\0"):
|
||||
raise InstallError("setting values must not contain line breaks")
|
||||
if "$" in v and "'" not in v:
|
||||
# Compose expands ${VAR} inside double quotes, so "pa$word" would
|
||||
# silently turn into "pa". Single-quoted values are taken literally.
|
||||
return f"'{v}'"
|
||||
if v == "" or any(c in v for c in " \t\"'$`\\#"):
|
||||
escaped = v.replace("\\", "\\\\").replace('"', '\\"')
|
||||
return f'"{escaped}"'
|
||||
|
|
@ -196,7 +167,7 @@ def install_from(src: Path, settings: dict[str, str] | None = None) -> Path:
|
|||
if key not in declared:
|
||||
raise InstallError(f"{m.name}: unknown setting {key!r}")
|
||||
|
||||
target = app_dir(m.name)
|
||||
target = apps_dir() / m.name
|
||||
target.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for item in src.iterdir():
|
||||
|
|
@ -245,7 +216,6 @@ def install_from(src: Path, settings: dict[str, str] | None = None) -> Path:
|
|||
for s in m.settings:
|
||||
if s.required and not merged.get(s.name):
|
||||
raise InstallError(f"{m.name}: setting {s.name!r} is required")
|
||||
_validate_settings(m, merged)
|
||||
write_env(env, merged)
|
||||
elif not env.exists() and env_example.exists():
|
||||
# First install with no settings and no .env shipped: bootstrap from
|
||||
|
|
@ -265,7 +235,7 @@ def install_from(src: Path, settings: dict[str, str] | None = None) -> Path:
|
|||
f"file and re-run `furtka app install {m.name}`."
|
||||
)
|
||||
|
||||
path_errors = _path_setting_errors(m, read_env_values(env))
|
||||
path_errors = _path_setting_errors(m, env)
|
||||
if path_errors:
|
||||
raise InstallError(f"{m.name}: {'; '.join(path_errors)}")
|
||||
|
||||
|
|
@ -286,11 +256,10 @@ def parse_env_text(text: str) -> dict[str, str]:
|
|||
continue
|
||||
key, _, value = line.partition("=")
|
||||
value = value.strip()
|
||||
if len(value) >= 2 and value.startswith('"') and value.endswith('"'):
|
||||
if (value.startswith('"') and value.endswith('"')) or (
|
||||
value.startswith("'") and value.endswith("'")
|
||||
):
|
||||
value = value[1:-1].replace('\\"', '"').replace("\\\\", "\\")
|
||||
elif len(value) >= 2 and value.startswith("'") and value.endswith("'"):
|
||||
# Single quotes are literal in compose's dotenv — no escapes.
|
||||
value = value[1:-1]
|
||||
out[key.strip()] = value
|
||||
return out
|
||||
|
||||
|
|
@ -315,7 +284,7 @@ def update_env(name: str, settings: dict[str, str]) -> Path:
|
|||
apps only. Returns the target folder; caller is expected to run
|
||||
reconcile to restart the containers.
|
||||
"""
|
||||
target = app_dir(name)
|
||||
target = apps_dir() / name
|
||||
manifest_path = target / "manifest.json"
|
||||
if not manifest_path.exists():
|
||||
raise InstallError(f"{name!r} is not installed")
|
||||
|
|
@ -347,8 +316,13 @@ def update_env(name: str, settings: dict[str, str]) -> Path:
|
|||
for s in m.settings:
|
||||
if s.required and not merged.get(s.name):
|
||||
raise InstallError(f"{m.name}: setting {s.name!r} is required")
|
||||
_validate_settings(m, merged)
|
||||
write_env(env, merged)
|
||||
bad = _placeholder_keys(env)
|
||||
if bad:
|
||||
raise InstallError(f"{m.name}: {env} still has placeholder values for {', '.join(bad)}.")
|
||||
path_errors = _path_setting_errors(m, env)
|
||||
if path_errors:
|
||||
raise InstallError(f"{m.name}: {'; '.join(path_errors)}")
|
||||
return target
|
||||
|
||||
|
||||
|
|
@ -379,7 +353,7 @@ def remove(name: str) -> Path:
|
|||
|
||||
Caller is responsible for stopping the compose project first.
|
||||
"""
|
||||
target = app_dir(name)
|
||||
target = apps_dir() / name
|
||||
if not target.exists():
|
||||
raise InstallError(f"{name!r} is not installed")
|
||||
shutil.rmtree(target)
|
||||
|
|
|
|||
|
|
@ -32,21 +32,6 @@ class Setting:
|
|||
default: str | None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Internet:
|
||||
# Whether this app is safe to expose to the internet through a
|
||||
# furtka-gateway at all. Only ever a catalog author's self-declaration —
|
||||
# the gateway independently re-validates the port it's given at publish
|
||||
# time regardless of what this says (see furtka-gateway's routes.py).
|
||||
viable: bool
|
||||
# Which declared `ports` entry is the exposable web UI. Required when
|
||||
# viable is True — an app declaring several ports (e.g. a DNS service
|
||||
# exposing both its resolver port and an admin UI port) must say which
|
||||
# one is actually meant to be reachable from the internet; there is no
|
||||
# way to infer that from `ports` alone.
|
||||
port: int | None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Requirement:
|
||||
app: str # name of the required app — must resolve in installed/catalog/bundled
|
||||
|
|
@ -77,7 +62,6 @@ class Manifest:
|
|||
# no frontend (CLI-only, background workers) leave this empty.
|
||||
open_url: str = ""
|
||||
requires: tuple[Requirement, ...] = field(default_factory=tuple)
|
||||
internet: Internet = field(default_factory=lambda: Internet(viable=False, port=None))
|
||||
|
||||
def volume_name(self, short: str) -> str:
|
||||
# Namespace volume names so two apps can each declare e.g. "data"
|
||||
|
|
@ -171,27 +155,6 @@ def _parse_requires(raw: object, manifest_path: Path, self_name: str) -> tuple[R
|
|||
return tuple(out)
|
||||
|
||||
|
||||
def _parse_internet(raw: object, manifest_path: Path, ports: list[int]) -> Internet:
|
||||
if raw is None:
|
||||
return Internet(viable=False, port=None)
|
||||
if not isinstance(raw, dict):
|
||||
raise ManifestError(f"{manifest_path}: internet must be an object")
|
||||
|
||||
viable = bool(raw.get("viable", False))
|
||||
port = raw.get("port")
|
||||
|
||||
if not viable:
|
||||
return Internet(viable=False, port=None)
|
||||
|
||||
if not isinstance(port, int) or isinstance(port, bool):
|
||||
raise ManifestError(f"{manifest_path}: internet.port must be an integer when viable")
|
||||
if port not in ports:
|
||||
raise ManifestError(
|
||||
f"{manifest_path}: internet.port {port} must be one of the declared ports {ports}"
|
||||
)
|
||||
return Internet(viable=True, port=port)
|
||||
|
||||
|
||||
def load_manifest(path: Path, expected_name: str | None = None) -> Manifest:
|
||||
"""Parse and validate a manifest.json.
|
||||
|
||||
|
|
@ -212,10 +175,8 @@ def load_manifest(path: Path, expected_name: str | None = None) -> Manifest:
|
|||
raise ManifestError(f"{path}: missing required fields: {', '.join(missing)}")
|
||||
|
||||
name = raw["name"]
|
||||
if not isinstance(name, str) or not APP_NAME_RE.fullmatch(name):
|
||||
raise ManifestError(
|
||||
f"{path}: name must be lowercase letters, digits, '-' or '_' (got {name!r})"
|
||||
)
|
||||
if not isinstance(name, str) or not name:
|
||||
raise ManifestError(f"{path}: name must be a non-empty string")
|
||||
if expected_name is not None and name != expected_name:
|
||||
raise ManifestError(f"{path}: name {name!r} must equal {expected_name!r}")
|
||||
|
||||
|
|
@ -229,7 +190,6 @@ def load_manifest(path: Path, expected_name: str | None = None) -> Manifest:
|
|||
|
||||
settings = _parse_settings(raw.get("settings"), path)
|
||||
requires = _parse_requires(raw.get("requires"), path, name)
|
||||
internet = _parse_internet(raw.get("internet"), path, ports)
|
||||
|
||||
open_url_raw = raw.get("open_url", "")
|
||||
if not isinstance(open_url_raw, str):
|
||||
|
|
@ -247,5 +207,4 @@ def load_manifest(path: Path, expected_name: str | None = None) -> Manifest:
|
|||
settings=settings,
|
||||
open_url=open_url_raw,
|
||||
requires=requires,
|
||||
internet=internet,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -20,18 +20,6 @@ DEFAULT_USERS_FILE = Path("/var/lib/furtka/users.json")
|
|||
# /settings* so those pages pick up the auth-guard. Caddy also serves
|
||||
# /style.css and other assets directly from here for the login page.
|
||||
DEFAULT_STATIC_WWW = Path("/opt/furtka/current/assets/www")
|
||||
# This box's furtka-gateway registration: {gateway_url, box_id, box_token,
|
||||
# wg: {...}}. Written once by furtka.gateway.register(), 0600 (it carries
|
||||
# the box's WireGuard private key — see furtka-gateway's wgeasy.py for why
|
||||
# that's unavoidable with stock wg-easy). Lives under /var/lib/furtka/ so
|
||||
# self-updates don't stomp it, same as users.json.
|
||||
DEFAULT_GATEWAY_CONFIG = Path("/var/lib/furtka/gateway.json")
|
||||
# Which installed apps are currently published through the connected
|
||||
# gateway, keyed by app name: {app_name: {route_id, subdomain, port}}.
|
||||
# Separate from gateway.json since this changes per-app-toggle, not per
|
||||
# gateway-connection — no reason to rewrite the (more sensitive) box
|
||||
# credentials file on every publish/unpublish.
|
||||
DEFAULT_INTERNET_ROUTES_FILE = Path("/var/lib/furtka/internet-routes.json")
|
||||
|
||||
|
||||
def apps_dir() -> Path:
|
||||
|
|
@ -56,11 +44,3 @@ def users_file() -> Path:
|
|||
|
||||
def static_www_dir() -> Path:
|
||||
return Path(os.environ.get("FURTKA_STATIC_WWW", DEFAULT_STATIC_WWW))
|
||||
|
||||
|
||||
def gateway_config_file() -> Path:
|
||||
return Path(os.environ.get("FURTKA_GATEWAY_CONFIG", DEFAULT_GATEWAY_CONFIG))
|
||||
|
||||
|
||||
def internet_routes_file() -> Path:
|
||||
return Path(os.environ.get("FURTKA_INTERNET_ROUTES_FILE", DEFAULT_INTERNET_ROUTES_FILE))
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ the updater at a tmpdir.
|
|||
from __future__ import annotations
|
||||
|
||||
import fcntl
|
||||
import http.client
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
|
|
@ -192,20 +191,6 @@ def _maybe_migrate_preserve_https() -> None:
|
|||
)
|
||||
|
||||
|
||||
def _maybe_migrate_redirect_snippet() -> None:
|
||||
"""26.21 migration: swap the old catch-all 301 redirect for the
|
||||
hostname-scoped 302 one, so boxes reached by IP can load the UI again
|
||||
and turning HTTPS off stops sticking in browser caches."""
|
||||
from furtka import https
|
||||
|
||||
redirect_snippet = _CADDY_SNIPPET_DIR / "redirect.caddyfile"
|
||||
if not redirect_snippet.is_file():
|
||||
return
|
||||
if redirect_snippet.read_text() != https.LEGACY_REDIRECT_CONTENT:
|
||||
return
|
||||
redirect_snippet.write_text(https._redirect_snippet_content(_current_hostname()))
|
||||
|
||||
|
||||
def _refresh_caddyfile(source: Path) -> bool:
|
||||
"""Copy the shipped Caddyfile to /etc/caddy/ iff it differs. Returns True
|
||||
if the file changed (so caddy needs more than a bare reload).
|
||||
|
|
@ -229,7 +214,6 @@ def _refresh_caddyfile(source: Path) -> bool:
|
|||
# hostname block is gone, so the redirect would 301 to a dead :443.
|
||||
# Preserve intent by writing the HTTPS listener snippet too.
|
||||
_maybe_migrate_preserve_https()
|
||||
_maybe_migrate_redirect_snippet()
|
||||
rendered = source.read_text().replace(_CADDYFILE_HOSTNAME_MARKER, _current_hostname())
|
||||
if _CADDYFILE_LIVE.is_file() and rendered == _CADDYFILE_LIVE.read_text():
|
||||
return False
|
||||
|
|
@ -281,10 +265,9 @@ def write_state(stage: str, **extra) -> None:
|
|||
|
||||
def read_state() -> dict:
|
||||
try:
|
||||
data = json.loads(state_path().read_text())
|
||||
except (OSError, UnicodeDecodeError, json.JSONDecodeError):
|
||||
return json.loads(state_path().read_text())
|
||||
except (FileNotFoundError, json.JSONDecodeError):
|
||||
return {}
|
||||
return data if isinstance(data, dict) else {}
|
||||
|
||||
|
||||
def acquire_lock():
|
||||
|
|
@ -335,29 +318,13 @@ def _health_check(url: str, deadline_s: float = 30.0) -> bool:
|
|||
# check. 5xx → genuinely broken, don't accept.
|
||||
if 400 <= e.code < 500:
|
||||
return True
|
||||
except (OSError, http.client.HTTPException):
|
||||
# Connection refused / reset / timeout (URLError is an OSError;
|
||||
# a read timeout or RemoteDisconnected is not wrapped by urllib)
|
||||
# → not up yet, retry.
|
||||
except urllib.error.URLError:
|
||||
# Connection refused / DNS / timeout → not up yet, retry.
|
||||
pass
|
||||
time.sleep(1)
|
||||
return False
|
||||
|
||||
|
||||
def _swap_symlink(link: Path, target: str | Path) -> None:
|
||||
"""Point `link` at `target` atomically.
|
||||
|
||||
unlink() + symlink_to() leaves a window with no /opt/furtka/current at
|
||||
all — a power cut there boots a box with no services. rename() over the
|
||||
old link is atomic.
|
||||
"""
|
||||
tmp = link.with_name(link.name + ".new")
|
||||
if tmp.is_symlink() or tmp.exists():
|
||||
tmp.unlink()
|
||||
tmp.symlink_to(target)
|
||||
os.replace(tmp, link)
|
||||
|
||||
|
||||
def prepare_update(check: UpdateCheck, download_dir: Path | None = None) -> tuple[Path, str]:
|
||||
"""Download + verify the tarball. Returns (tarball_path, version)."""
|
||||
if not check.tarball_url or not check.sha256_url:
|
||||
|
|
@ -402,11 +369,15 @@ def apply_update(tarball: Path, version: str) -> None:
|
|||
target.chmod(0o755)
|
||||
|
||||
write_state("swapping", latest=version)
|
||||
previous = os.readlink(current) if current.is_symlink() else None
|
||||
old_caddyfile = _CADDYFILE_LIVE.read_text() if _CADDYFILE_LIVE.is_file() else None
|
||||
previous = None
|
||||
if current.is_symlink():
|
||||
previous = os.readlink(current)
|
||||
current.unlink()
|
||||
try:
|
||||
_swap_symlink(current, target)
|
||||
current.symlink_to(target)
|
||||
except OSError as e:
|
||||
if previous:
|
||||
current.symlink_to(previous)
|
||||
raise UpdateError(f"symlink swap failed: {e}") from e
|
||||
|
||||
write_state("restarting", latest=version)
|
||||
|
|
@ -422,41 +393,27 @@ def apply_update(tarball: Path, version: str) -> None:
|
|||
_run(["systemctl", "daemon-reload"])
|
||||
_run(["systemctl", "try-restart", "furtka-reconcile.service"])
|
||||
_run(["systemctl", "restart", "furtka-api.service"])
|
||||
except (UpdateError, OSError) as e:
|
||||
# OSError: e.g. disk full or EACCES writing the Caddyfile — the new
|
||||
# version is already live, so this must roll back too.
|
||||
_rollback(previous, version, f"service restart failed: {e}", old_caddyfile)
|
||||
raise UpdateError(f"service restart failed: {e} — rolled back") from e
|
||||
except UpdateError as e:
|
||||
_rollback(previous, version, f"service restart failed: {e}")
|
||||
raise
|
||||
|
||||
write_state("verifying", latest=version)
|
||||
ok = _health_check("http://127.0.0.1:7000/api/apps", deadline_s=30.0)
|
||||
if not ok:
|
||||
_rollback(previous, version, "health check failed after restart", old_caddyfile)
|
||||
_rollback(previous, version, "health check failed after restart")
|
||||
raise UpdateError("new version failed health check — rolled back")
|
||||
|
||||
write_state("done", version=version)
|
||||
|
||||
|
||||
def _rollback(
|
||||
previous_target: str | None,
|
||||
failed_version: str,
|
||||
reason: str,
|
||||
old_caddyfile: str | None = None,
|
||||
) -> None:
|
||||
def _rollback(previous_target: str | None, failed_version: str, reason: str) -> None:
|
||||
current = current_symlink()
|
||||
if previous_target:
|
||||
_swap_symlink(current, previous_target)
|
||||
# The new release may have shipped Caddy routes the old code
|
||||
# doesn't serve; put the previous Caddyfile back before reloading.
|
||||
if old_caddyfile is not None:
|
||||
try:
|
||||
_CADDYFILE_LIVE.write_text(old_caddyfile)
|
||||
except OSError:
|
||||
pass
|
||||
if current.is_symlink():
|
||||
current.unlink()
|
||||
current.symlink_to(previous_target)
|
||||
# Best-effort restart on the previous target — if it fails too the
|
||||
# box is in a hard state, but we can only surface the reason.
|
||||
subprocess.run(["systemctl", "daemon-reload"], check=False)
|
||||
subprocess.run(["systemctl", "reload", "caddy"], check=False)
|
||||
subprocess.run(["systemctl", "restart", "furtka-api.service"], check=False)
|
||||
write_state(
|
||||
"rolled_back",
|
||||
|
|
@ -473,25 +430,13 @@ def run_update() -> UpdateCheck:
|
|||
UpdateError on any failure; the state file records the stage.
|
||||
"""
|
||||
with acquire_lock():
|
||||
try:
|
||||
check = check_update()
|
||||
if not check.update_available:
|
||||
write_state("done", version=check.current, note="already up to date")
|
||||
return check
|
||||
tarball, version = prepare_update(check)
|
||||
apply_update(tarball, version)
|
||||
check = check_update()
|
||||
if not check.update_available:
|
||||
write_state("done", version=check.current, note="already up to date")
|
||||
return check
|
||||
except Exception as e:
|
||||
# Without a terminal stage the settings page keeps showing
|
||||
# "Downloading…" forever. Rollback already wrote its own stage.
|
||||
if read_state().get("stage") != "rolled_back":
|
||||
try:
|
||||
write_state("error", reason=str(e) or type(e).__name__)
|
||||
except OSError:
|
||||
pass
|
||||
if isinstance(e, UpdateError):
|
||||
raise
|
||||
raise UpdateError(str(e) or type(e).__name__) from e
|
||||
tarball, version = prepare_update(check)
|
||||
apply_update(tarball, version)
|
||||
return check
|
||||
|
||||
|
||||
def rollback() -> str:
|
||||
|
|
@ -511,7 +456,8 @@ def rollback() -> str:
|
|||
raise UpdateError("no other version slots available to roll back to")
|
||||
target_name = candidates[0]
|
||||
target = versions_dir() / target_name
|
||||
_swap_symlink(current, target)
|
||||
current.unlink()
|
||||
current.symlink_to(target)
|
||||
subprocess.run(["systemctl", "daemon-reload"], check=False)
|
||||
subprocess.run(["systemctl", "restart", "furtka-api.service"], check=False)
|
||||
write_state("rolled_back_manual", restored_to=target_name)
|
||||
|
|
|
|||
|
|
@ -1,160 +0,0 @@
|
|||
"""WireGuard tunnel to a connected furtka-gateway.
|
||||
|
||||
Structural mirror of furtka.https's snippet-write-plus-reload pattern:
|
||||
write/remove /etc/wireguard/furtka-gw.conf, then flip the wg-quick@furtka-gw
|
||||
systemd unit, reverting the conf file if that call fails so a bad config
|
||||
can't leave the tunnel half-configured. One deliberate difference from
|
||||
https.py: enabling and disabling are genuinely different systemctl
|
||||
subcommands here (Caddy only ever needs a single `reload` either way), so
|
||||
the injectable `reload` callable takes the resolved action ("enable" or
|
||||
"disable") rather than being a fixed zero-argument call.
|
||||
|
||||
This module never generates its own keypair or contacts furtka-gateway
|
||||
directly — furtka.gateway.register() gets the full WireGuard interface
|
||||
config (including the private key; see furtka-gateway's wgeasy.py for why
|
||||
that's unavoidable with stock wg-easy) and hands it to
|
||||
set_tunnel_enabled() here.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
DEFAULT_CONF_PATH = Path("/etc/wireguard/furtka-gw.conf")
|
||||
INTERFACE = "furtka-gw"
|
||||
|
||||
|
||||
def default_conf_path() -> Path:
|
||||
return Path(os.environ.get("FURTKA_WIREGUARD_CONF", DEFAULT_CONF_PATH))
|
||||
|
||||
|
||||
class WireguardError(Exception):
|
||||
"""Recoverable failure from set_tunnel_enabled — the caller should 5xx."""
|
||||
|
||||
|
||||
def _conf_content(wg: dict) -> str:
|
||||
"""Render a wg-quick .conf from a furtka-gateway registration response's
|
||||
`wg` block. AllowedIPs here governs what THIS box routes *through* the
|
||||
tunnel — furtka-gateway hands back a split-tunnel value (its own peer
|
||||
subnet only), which this module passes through verbatim rather than
|
||||
widening it, so a compromised gateway can't pull the box's other
|
||||
traffic through it.
|
||||
|
||||
`preshared_key` is only present when the gateway's wg-easy is v15
|
||||
(which generates one per client by default and enforces it
|
||||
server-side) — omitted (None/missing) for v14, which has none.
|
||||
Dropping a present preshared key here would break the handshake
|
||||
silently, since the server side would still expect it.
|
||||
"""
|
||||
preshared_key_line = ""
|
||||
if wg.get("preshared_key"):
|
||||
preshared_key_line = f"PresharedKey = {wg['preshared_key']}\n"
|
||||
return (
|
||||
"[Interface]\n"
|
||||
f"PrivateKey = {wg['private_key']}\n"
|
||||
f"Address = {wg['address']}\n"
|
||||
"\n"
|
||||
"[Peer]\n"
|
||||
f"PublicKey = {wg['server_public_key']}\n"
|
||||
f"{preshared_key_line}"
|
||||
f"Endpoint = {wg['endpoint']}\n"
|
||||
f"AllowedIPs = {wg['allowed_ips']}\n"
|
||||
"PersistentKeepalive = 25\n"
|
||||
)
|
||||
|
||||
|
||||
def _default_reload(action: str) -> None:
|
||||
subprocess.run(
|
||||
["systemctl", action, "--now", f"wg-quick@{INTERFACE}"],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
|
||||
def set_tunnel_enabled(
|
||||
enabled: bool,
|
||||
wg: dict | None = None,
|
||||
conf_path: Path | None = None,
|
||||
reload=_default_reload,
|
||||
) -> bool:
|
||||
"""Bring the tunnel up (writing conf_path from `wg`) or down.
|
||||
|
||||
`wg` is required when enabling ({private_key, address, server_public_key,
|
||||
endpoint, allowed_ips} — furtka.gateway.register()'s return shape),
|
||||
ignored when disabling. Reverts conf_path to its pre-call state if the
|
||||
systemctl action fails, so a bad config can't leave the tunnel wedged.
|
||||
"""
|
||||
if enabled and wg is None:
|
||||
raise ValueError("wg config is required to enable the tunnel")
|
||||
if conf_path is None:
|
||||
conf_path = default_conf_path()
|
||||
|
||||
try:
|
||||
conf_path.parent.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||
had_conf = conf_path.is_file()
|
||||
previous = conf_path.read_text() if had_conf else None
|
||||
|
||||
if enabled:
|
||||
conf_path.write_text(_conf_content(wg))
|
||||
conf_path.chmod(0o600)
|
||||
elif had_conf:
|
||||
conf_path.unlink()
|
||||
except OSError as e:
|
||||
raise WireguardError(f"could not access {conf_path}: {e}") from e
|
||||
|
||||
try:
|
||||
reload("enable" if enabled else "disable")
|
||||
except subprocess.CalledProcessError as e:
|
||||
_revert(conf_path, previous)
|
||||
msg = (e.stderr or e.stdout or "").strip() or f"exit {e.returncode}"
|
||||
raise WireguardError(f"systemctl failed: {msg}") from e
|
||||
except FileNotFoundError as e:
|
||||
_revert(conf_path, previous)
|
||||
raise WireguardError(f"systemctl not available: {e}") from e
|
||||
return enabled
|
||||
|
||||
|
||||
def _revert(conf_path: Path, previous: str | None) -> None:
|
||||
if previous is None:
|
||||
try:
|
||||
conf_path.unlink()
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
else:
|
||||
conf_path.write_text(previous)
|
||||
|
||||
|
||||
def _default_wg_show() -> str:
|
||||
result = subprocess.run(
|
||||
["wg", "show", INTERFACE, "latest-handshakes"],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
return result.stdout.strip()
|
||||
|
||||
|
||||
def status(conf_path: Path | None = None, wg_show=_default_wg_show) -> dict:
|
||||
"""Whether the tunnel is configured, and its latest handshake if `wg`
|
||||
tooling is available (None if not — e.g. wg-tools missing, or the
|
||||
interface isn't actually up yet right after enabling).
|
||||
|
||||
Read-only and best-effort: any OSError stat-ing conf_path (missing
|
||||
parent dir, an unexpected permission situation) is treated the same as
|
||||
"not configured" rather than raised — a status check must never 500
|
||||
the whole request over something this innocuous.
|
||||
"""
|
||||
if conf_path is None:
|
||||
conf_path = default_conf_path()
|
||||
try:
|
||||
configured = conf_path.is_file()
|
||||
except OSError:
|
||||
configured = False
|
||||
latest_handshake = None
|
||||
if configured:
|
||||
try:
|
||||
latest_handshake = wg_show()
|
||||
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||
latest_handshake = None
|
||||
return {"configured": configured, "latest_handshake": latest_handshake}
|
||||
|
|
@ -34,17 +34,6 @@ The systemd service runs `flask --app app run --host 0.0.0.0 --port 5000` under
|
|||
|
||||
mDNS is wired: `avahi-daemon` + `nss-mdns` come from `packages.extra`, the live ISO's hostname is `proksi`, and as soon as `systemd-networkd-wait-online` fires the installer is reachable at `http://proksi.local:5000`. The raw IP still shows on the console for fallback — some Windows clients need the Bonjour service for `.local` to resolve at all.
|
||||
|
||||
### archinstall is pinned
|
||||
|
||||
The webinstaller imports archinstall internals and `furtka-webinstaller.service` sed-patches one of its files, so `build.sh` does not take whatever archinstall the Arch repos currently ship. It downloads the version in `ARCHINSTALL_PIN` from `archive.archlinux.org`, checks it against `ARCHINSTALL_SHA256`, and serves it from a local `[furtka-pinned]` repo listed before `[core]` in the build's `pacman.conf` (pacman takes a package from the first repo that has it). Only the build uses that repo; the live system's own `pacman.conf` is untouched.
|
||||
|
||||
The build fails with "pinned archinstall … targets Python X, Arch now ships Y" once Arch moves to a new Python — the pinned package would install into a dead `site-packages`. To bump:
|
||||
|
||||
1. Pick the new version from <https://archive.archlinux.org/packages/a/archinstall/>.
|
||||
2. `curl -LO` the `.pkg.tar.zst`, `sha256sum` it, and update `ARCHINSTALL_PIN` + `ARCHINSTALL_SHA256` at the top of `build.sh`.
|
||||
3. Check that `webinstaller/app.py:build_disk_config` still imports and that the `ExecStartPre` sed in `furtka-webinstaller.service` still matches (`journalctl -u furtka-webinstaller` on the live ISO).
|
||||
4. Full VM install (UEFI and BIOS) before merging.
|
||||
|
||||
`build.sh` also deletes releng's `getty@tty1.service.d/autologin.conf`. With root auto-logged-in, tty1 belongs to a shell and `agetty --reload` can't redraw the banner, so the IP line was a snapshot of whatever DHCP had done by the time getty started. Without autologin tty1 sits at the login prompt showing the live banner; for a shell type `root` + Enter (releng's root has no password) — the banner says so.
|
||||
|
||||
## Test flow
|
||||
|
|
|
|||
40
iso/build.sh
|
|
@ -27,11 +27,7 @@ fi
|
|||
# ---- inside the container from here on ----
|
||||
|
||||
echo "==> Syncing pacman, installing archiso"
|
||||
pacman -Syu --noconfirm --needed archiso curl zstd
|
||||
|
||||
# archinstall build the webinstaller is validated against (see pin step below).
|
||||
ARCHINSTALL_PIN="4.4-1"
|
||||
ARCHINSTALL_SHA256="6cb5da75c108ef2f5d25a7a20baf6c52cc927d5e06890dd10182e6eb4be815cb"
|
||||
pacman -Syu --noconfirm --needed archiso
|
||||
|
||||
PROFILE_SRC="/usr/share/archiso/configs/releng"
|
||||
PROFILE_WORK="/tmp/furtka-profile"
|
||||
|
|
@ -47,37 +43,6 @@ cat "$SCRIPT_DIR/overlay/packages.extra" >> "$PROFILE_WORK/packages.x86_64"
|
|||
|
||||
cat "$SCRIPT_DIR/overlay/profiledef.sh" >> "$PROFILE_WORK/profiledef.sh"
|
||||
|
||||
echo "==> Pinning archinstall ${ARCHINSTALL_PIN}"
|
||||
# The webinstaller imports archinstall internals (build_disk_config) and
|
||||
# sed-patches one of its files at service start, so a silent archinstall
|
||||
# upgrade in the Arch repos can break every install with no change on our
|
||||
# side. Serve the validated build from a local repo listed *before* [core]:
|
||||
# pacman takes a package from the first repo that has it, whatever the
|
||||
# version elsewhere. Bump deliberately: new version + sha256 below, rebuild,
|
||||
# run the smoke VM (see iso/README.md).
|
||||
PINNED_REPO="/tmp/furtka-pinned-repo"
|
||||
rm -rf "$PINNED_REPO" && mkdir -p "$PINNED_REPO"
|
||||
ARCHINSTALL_PKG="archinstall-${ARCHINSTALL_PIN}-any.pkg.tar.zst"
|
||||
curl -fsSL --retry 3 -o "$PINNED_REPO/$ARCHINSTALL_PKG" \
|
||||
"https://archive.archlinux.org/packages/a/archinstall/$ARCHINSTALL_PKG"
|
||||
echo "${ARCHINSTALL_SHA256} $PINNED_REPO/$ARCHINSTALL_PKG" | sha256sum -c -
|
||||
# archinstall is an "any" package installed under /usr/lib/python3.X; after
|
||||
# Arch moves to a new Python it would install into a dead directory. Fail
|
||||
# the build with a clear message instead of shipping a broken installer.
|
||||
pkg_py=$(tar --zstd -tf "$PINNED_REPO/$ARCHINSTALL_PKG" \
|
||||
| sed -n 's|^usr/lib/python\(3\.[0-9]*\)/.*|\1|p' | sort -u)
|
||||
repo_py=$(pacman -Si python | awk -F': ' '/^Version/ {split($2, v, "."); print v[1] "." v[2]}')
|
||||
if [ "$pkg_py" != "$repo_py" ]; then
|
||||
echo "ERROR: pinned archinstall ${ARCHINSTALL_PIN} targets Python $pkg_py, Arch now ships $repo_py." >&2
|
||||
echo " Bump ARCHINSTALL_PIN/ARCHINSTALL_SHA256 in iso/build.sh (see iso/README.md)." >&2
|
||||
exit 1
|
||||
fi
|
||||
repo-add -q "$PINNED_REPO/furtka-pinned.db.tar.gz" "$PINNED_REPO/$ARCHINSTALL_PKG"
|
||||
# The sha256 above already pins the exact bytes.
|
||||
sed -i "0,/^\[core\]/s||[furtka-pinned]\nSigLevel = Optional TrustAll\nServer = file://$PINNED_REPO\n\n[core]|" \
|
||||
"$PROFILE_WORK/pacman.conf"
|
||||
grep -q '^\[furtka-pinned\]' "$PROFILE_WORK/pacman.conf"
|
||||
|
||||
cp -a "$SCRIPT_DIR/overlay/airootfs/." "$PROFILE_WORK/airootfs/"
|
||||
|
||||
# releng auto-logs root in on tty1. That turns our /etc/issue banner into a
|
||||
|
|
@ -90,9 +55,6 @@ cp -a "$SCRIPT_DIR/overlay/airootfs/." "$PROFILE_WORK/airootfs/"
|
|||
rm -rf "$PROFILE_WORK/airootfs/etc/systemd/system/getty@tty1.service.d"
|
||||
|
||||
echo "==> Rebranding boot menu (GRUB + syslinux + systemd-boot)"
|
||||
# BIOS boot menu background: Furtka lockup instead of the Arch logo
|
||||
# (generated by website/tools/brand-assets.py, 640x480 as syslinux wants).
|
||||
cp "$SCRIPT_DIR/overlay/splash.png" "$PROFILE_WORK/syslinux/splash.png"
|
||||
# releng ships menu entries labelled "Arch Linux install medium" across three
|
||||
# bootloader configs (BIOS syslinux, GRUB, systemd-boot for UEFI). Rewrite to
|
||||
# our brand. Done with sed (not a static overlay) so upstream archiso file
|
||||
|
|
|
|||
|
|
@ -16,17 +16,6 @@ issue=/etc/issue
|
|||
mapfile -t ips < <(ip -4 -o addr show scope global 2>/dev/null | awk '{print $4}' | cut -d/ -f1)
|
||||
|
||||
new=$(
|
||||
# Furtka mark (docs/brand/console-banner.txt, from brand-assets.py)
|
||||
echo ' ▄▄▄▄▄▄▄▄'
|
||||
echo ' ▄██████████▄'
|
||||
echo ' █████▀▀▀▀▀▀███'
|
||||
echo ' ████▀ ████'
|
||||
echo ' ████ █████████'
|
||||
echo ' ████ ████'
|
||||
echo ' ████ ▄▄▄▄▄████'
|
||||
echo ' ████ █████████'
|
||||
echo ' ████ █████████'
|
||||
echo ' ▀▀▀▀ ▀▀▀▀▀▀▀▀▀'
|
||||
echo
|
||||
echo " Open Furtka in a browser on another device on your network:"
|
||||
echo
|
||||
|
|
@ -41,8 +30,6 @@ new=$(
|
|||
fi
|
||||
echo
|
||||
echo " Then follow the wizard to install Furtka on this machine."
|
||||
echo " The install downloads packages, so this machine needs a network"
|
||||
echo " cable with internet access. Wi-Fi is not set up automatically."
|
||||
echo
|
||||
echo " Need a shell? Log in as root (no password)."
|
||||
echo
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 4.3 KiB |
|
|
@ -29,22 +29,6 @@ server {
|
|||
try_files $uri $uri/ $uri.html =404;
|
||||
}
|
||||
|
||||
# Poll counter (ops/poll/pollsvc.py) — cookie-free, rate-limited.
|
||||
location /api/poll/ {
|
||||
# Public traffic arrives from the edge proxy via 192.168.178.164.
|
||||
# Only that hop is trusted when unwinding X-Forwarded-For, so a
|
||||
# client-supplied X-Forwarded-For cannot forge a fresh "device".
|
||||
set_real_ip_from 192.168.178.164;
|
||||
real_ip_header X-Forwarded-For;
|
||||
real_ip_recursive on;
|
||||
|
||||
limit_req zone=poll burst=10 nodelay;
|
||||
proxy_pass http://127.0.0.1:8090/;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header User-Agent $http_user_agent;
|
||||
proxy_read_timeout 5s;
|
||||
}
|
||||
|
||||
location = /favicon.svg {
|
||||
access_log off;
|
||||
log_not_found off;
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
# Rate limit for the poll API (http context; included from conf.d).
|
||||
limit_req_zone $binary_remote_addr zone=poll:1m rate=30r/m;
|
||||
|
|
@ -16,7 +16,6 @@ install -d -o "$OWNER" -g "$OWNER" -m 0755 "$WEBROOT"
|
|||
install -d -o "$OWNER" -g "$OWNER" -m 0755 "$SRCROOT"
|
||||
|
||||
cp "$(dirname "$0")/furtka.org.conf" "$SITE_CONF"
|
||||
cp "$(dirname "$0")/poll-ratelimit.conf" /etc/nginx/conf.d/poll-ratelimit.conf
|
||||
ln -sfn "$SITE_CONF" "$SITE_LINK"
|
||||
|
||||
# Drop the Ubuntu default site so it doesn't shadow us on :80.
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
[Unit]
|
||||
Description=furtka.org poll counter
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/python3 /opt/furtka-poll/pollsvc.py
|
||||
DynamicUser=yes
|
||||
StateDirectory=furtka-poll
|
||||
Restart=on-failure
|
||||
RestartSec=3
|
||||
NoNewPrivileges=yes
|
||||
ProtectSystem=strict
|
||||
ProtectHome=yes
|
||||
PrivateTmp=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Tiny cookie-free poll counter for furtka.org.
|
||||
|
||||
Runs behind nginx on 127.0.0.1:8090. One SQLite file, no dependencies
|
||||
beyond the standard library.
|
||||
|
||||
GET /<poll> -> {"poll": "logo", "counts": {"m": 3, "r": 5}, "total": 8}
|
||||
POST /<poll> -> body {"choice": "m"}; answers like GET plus "yours"
|
||||
|
||||
A device is identified by a salted SHA-256 of client IP (as resolved by
|
||||
nginx from the trusted edge proxy) + User-Agent, so nobody needs a cookie
|
||||
and the raw address is never stored. Voting again
|
||||
from the same device changes the vote instead of adding one.
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import sqlite3
|
||||
import sys
|
||||
import threading
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
|
||||
POLLS = {
|
||||
"logo": ("m", "r"),
|
||||
}
|
||||
STATE_DIR = os.environ.get("STATE_DIRECTORY", "/var/lib/furtka-poll")
|
||||
DB_PATH = os.path.join(STATE_DIR, "votes.db")
|
||||
SALT_PATH = os.path.join(STATE_DIR, "salt")
|
||||
LISTEN = os.environ.get("POLL_LISTEN", "127.0.0.1")
|
||||
PORT = int(os.environ.get("POLL_PORT", "8090"))
|
||||
MAX_BODY = 512
|
||||
|
||||
log = logging.getLogger("pollsvc")
|
||||
_lock = threading.Lock()
|
||||
|
||||
|
||||
def _salt() -> bytes:
|
||||
try:
|
||||
with open(SALT_PATH, "rb") as f:
|
||||
s = f.read()
|
||||
if len(s) >= 16:
|
||||
return s
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
s = os.urandom(32)
|
||||
with open(SALT_PATH, "wb") as f:
|
||||
f.write(s)
|
||||
os.chmod(SALT_PATH, 0o600)
|
||||
return s
|
||||
|
||||
|
||||
def _db() -> sqlite3.Connection:
|
||||
conn = sqlite3.connect(DB_PATH, check_same_thread=False)
|
||||
conn.execute(
|
||||
"CREATE TABLE IF NOT EXISTS votes ("
|
||||
" poll TEXT NOT NULL, device TEXT NOT NULL, choice TEXT NOT NULL,"
|
||||
" ts INTEGER NOT NULL DEFAULT (unixepoch()),"
|
||||
" PRIMARY KEY (poll, device))"
|
||||
)
|
||||
conn.commit()
|
||||
return conn
|
||||
|
||||
|
||||
SALT = None
|
||||
CONN = None
|
||||
|
||||
|
||||
def counts(poll: str) -> dict:
|
||||
with _lock:
|
||||
rows = CONN.execute(
|
||||
"SELECT choice, COUNT(*) FROM votes WHERE poll=? GROUP BY choice", (poll,)
|
||||
).fetchall()
|
||||
c = {k: 0 for k in POLLS[poll]}
|
||||
for choice, n in rows:
|
||||
if choice in c:
|
||||
c[choice] = n
|
||||
return {"poll": poll, "counts": c, "total": sum(c.values())}
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
server_version = "furtka-poll/1"
|
||||
|
||||
def log_message(self, fmt, *args): # quiet; nginx has the access log
|
||||
log.debug(fmt, *args)
|
||||
|
||||
def _client_ip(self) -> str:
|
||||
# nginx resolves the trusted proxy chain (real_ip module, see
|
||||
# ops/nginx/furtka.org.conf) and hands us the result as X-Real-IP.
|
||||
# We never parse X-Forwarded-For here: its leading entries are
|
||||
# whatever the client chose to send.
|
||||
return self.headers.get("X-Real-IP") or self.client_address[0]
|
||||
|
||||
def _device(self) -> str:
|
||||
ua = self.headers.get("User-Agent", "")
|
||||
h = hashlib.sha256(SALT + self._client_ip().encode() + b"|" + ua.encode())
|
||||
return h.hexdigest()[:32]
|
||||
|
||||
def _json(self, status: int, payload: dict):
|
||||
body = json.dumps(payload).encode()
|
||||
self.send_response(status)
|
||||
self.send_header("Content-Type", "application/json; charset=utf-8")
|
||||
self.send_header("Content-Length", str(len(body)))
|
||||
self.send_header("Cache-Control", "no-store")
|
||||
self.end_headers()
|
||||
self.wfile.write(body)
|
||||
|
||||
def _poll(self):
|
||||
name = self.path.strip("/").split("?")[0]
|
||||
if name not in POLLS:
|
||||
self._json(404, {"error": "no such poll"})
|
||||
return None
|
||||
return name
|
||||
|
||||
def do_GET(self):
|
||||
poll = self._poll()
|
||||
if not poll:
|
||||
return
|
||||
payload = counts(poll)
|
||||
with _lock:
|
||||
row = CONN.execute(
|
||||
"SELECT choice FROM votes WHERE poll=? AND device=?", (poll, self._device())
|
||||
).fetchone()
|
||||
payload["yours"] = row[0] if row else None
|
||||
self._json(200, payload)
|
||||
|
||||
def do_POST(self):
|
||||
poll = self._poll()
|
||||
if not poll:
|
||||
return
|
||||
try:
|
||||
n = int(self.headers.get("Content-Length", "0"))
|
||||
if n > MAX_BODY:
|
||||
raise ValueError("body too large")
|
||||
data = json.loads(self.rfile.read(n) or b"{}")
|
||||
choice = str(data.get("choice", ""))
|
||||
except (ValueError, json.JSONDecodeError):
|
||||
self._json(400, {"error": "bad request"})
|
||||
return
|
||||
if choice not in POLLS[poll]:
|
||||
self._json(400, {"error": "unknown choice"})
|
||||
return
|
||||
with _lock:
|
||||
CONN.execute(
|
||||
"INSERT INTO votes (poll, device, choice) VALUES (?,?,?)"
|
||||
" ON CONFLICT(poll, device) DO UPDATE SET choice=excluded.choice, ts=unixepoch()",
|
||||
(poll, self._device(), choice),
|
||||
)
|
||||
CONN.commit()
|
||||
payload = counts(poll)
|
||||
payload["yours"] = choice
|
||||
self._json(200, payload)
|
||||
|
||||
|
||||
def main():
|
||||
global SALT, CONN
|
||||
logging.basicConfig(
|
||||
level=os.environ.get("POLL_LOGLEVEL", "INFO"),
|
||||
stream=sys.stderr,
|
||||
format="%(levelname)s %(message)s",
|
||||
)
|
||||
os.makedirs(STATE_DIR, exist_ok=True)
|
||||
SALT = _salt()
|
||||
CONN = _db()
|
||||
srv = ThreadingHTTPServer((LISTEN, PORT), Handler)
|
||||
log.info("listening on %s:%d, db %s", LISTEN, PORT, DB_PATH)
|
||||
srv.serve_forever()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# Install / update the poll counter on forge-runner-01. Idempotent.
|
||||
#
|
||||
# Usage (on the VM, with sudo):
|
||||
# sudo ops/poll/setup-poll.sh # install / update
|
||||
# sudo ops/poll/setup-poll.sh --reset # ... and wipe all votes
|
||||
set -euo pipefail
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
|
||||
if [ "${1:-}" = "--reset" ]; then
|
||||
systemctl stop furtka-poll 2>/dev/null || true
|
||||
rm -f /var/lib/furtka-poll/votes.db
|
||||
echo "votes wiped"
|
||||
fi
|
||||
|
||||
install -d -m 0755 /opt/furtka-poll
|
||||
install -m 0644 "$HERE/pollsvc.py" /opt/furtka-poll/pollsvc.py
|
||||
install -m 0644 "$HERE/furtka-poll.service" /etc/systemd/system/furtka-poll.service
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now furtka-poll
|
||||
systemctl restart furtka-poll
|
||||
sleep 1
|
||||
systemctl --no-pager --lines=3 status furtka-poll
|
||||
curl -fsS http://127.0.0.1:8090/logo && echo
|
||||
echo "OK: furtka-poll running on 127.0.0.1:8090"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[project]
|
||||
name = "furtka"
|
||||
version = "26.21-alpha"
|
||||
version = "26.20-alpha"
|
||||
description = "Open-source home server OS — simple enough for everyone."
|
||||
requires-python = ">=3.11"
|
||||
readme = "README.md"
|
||||
|
|
|
|||
|
|
@ -113,15 +113,6 @@ if [ -f "$ISO" ]; then
|
|||
if ! upload_asset "$ISO"; then
|
||||
echo "warning: ISO upload failed — release published without ISO asset" >&2
|
||||
fi
|
||||
# Checksum sidecar for the download page on furtka.org (and anyone
|
||||
# verifying by hand). Uploaded even when the ISO upload reported a
|
||||
# failure — a 504 there often still lands the file. Written from inside
|
||||
# dist/ so the line carries the bare filename `sha256sum -c` expects.
|
||||
ISO_SHA="$ISO.sha256"
|
||||
(cd "$DIST_DIR" && sha256sum "$(basename "$ISO")" > "$(basename "$ISO_SHA")")
|
||||
if ! upload_asset "$ISO_SHA"; then
|
||||
echo "warning: ISO checksum upload failed" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Release $VERSION published: https://$HOST/$REPO/releases/tag/$VERSION"
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ def _request(port, path, cookie=None, method="GET", body=None):
|
|||
|
||||
def test_http_get_apps_route(fake_dirs, no_docker, admin_session):
|
||||
"""Smoke test the actual HTTP server with a real socket, urllib client."""
|
||||
server = api.ThreadingHTTPServer(("127.0.0.1", 0), api._Handler) # port 0 → ephemeral
|
||||
server = api.HTTPServer(("127.0.0.1", 0), api._Handler) # port 0 → ephemeral
|
||||
port = server.server_address[1]
|
||||
t = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
t.start()
|
||||
|
|
@ -431,7 +431,7 @@ def test_http_get_apps_route(fake_dirs, no_docker, admin_session):
|
|||
|
||||
|
||||
def test_http_post_install_unknown_app(fake_dirs, admin_session):
|
||||
server = api.ThreadingHTTPServer(("127.0.0.1", 0), api._Handler)
|
||||
server = api.HTTPServer(("127.0.0.1", 0), api._Handler)
|
||||
port = server.server_address[1]
|
||||
t = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
t.start()
|
||||
|
|
@ -459,7 +459,7 @@ def test_http_post_install_unknown_app(fake_dirs, admin_session):
|
|||
|
||||
|
||||
def _start_server():
|
||||
server = api.ThreadingHTTPServer(("127.0.0.1", 0), api._Handler)
|
||||
server = api.HTTPServer(("127.0.0.1", 0), api._Handler)
|
||||
port = server.server_address[1]
|
||||
t = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
t.start()
|
||||
|
|
@ -980,7 +980,7 @@ def test_update_settings_unknown_app(fake_dirs):
|
|||
def test_http_get_settings_route(fake_dirs, no_docker, admin_session):
|
||||
_, bundled = fake_dirs
|
||||
_write_bundled(bundled, "fileshare", manifest=SETTINGS_MANIFEST)
|
||||
server = api.ThreadingHTTPServer(("127.0.0.1", 0), api._Handler)
|
||||
server = api.HTTPServer(("127.0.0.1", 0), api._Handler)
|
||||
port = server.server_address[1]
|
||||
t = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
t.start()
|
||||
|
|
@ -1211,7 +1211,7 @@ def test_http_post_update_route(
|
|||
api._do_install("fileshare")
|
||||
update_docker_stubs["up_called"] = 0 # reset counter after install
|
||||
update_docker_stubs["local"] = {"samba": "sha256:NEW"}
|
||||
server = api.ThreadingHTTPServer(("127.0.0.1", 0), api._Handler)
|
||||
server = api.HTTPServer(("127.0.0.1", 0), api._Handler)
|
||||
port = server.server_address[1]
|
||||
t = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
t.start()
|
||||
|
|
@ -1236,7 +1236,7 @@ def test_http_post_update_route(
|
|||
def test_http_post_install_with_settings(fake_dirs, no_docker, no_systemd_run, admin_session):
|
||||
_, bundled = fake_dirs
|
||||
_write_bundled(bundled, "fileshare", manifest=SETTINGS_MANIFEST)
|
||||
server = api.ThreadingHTTPServer(("127.0.0.1", 0), api._Handler)
|
||||
server = api.HTTPServer(("127.0.0.1", 0), api._Handler)
|
||||
port = server.server_address[1]
|
||||
t = threading.Thread(target=server.serve_forever, daemon=True)
|
||||
t.start()
|
||||
|
|
@ -1424,425 +1424,3 @@ def test_power_surfaces_systemd_run_missing(fake_dirs, monkeypatch):
|
|||
status, body = api._do_power({"action": "reboot"})
|
||||
assert status == 502
|
||||
assert "systemd-run" in body["error"]
|
||||
|
||||
|
||||
# --- Gateway endpoints -------------------------------------------------------
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def gateway_paths(fake_dirs, monkeypatch):
|
||||
"""Redirect furtka.gateway's own env-cached state/lock paths into
|
||||
tmp_path — same "set env, reload module" idiom fake_dirs already uses
|
||||
for install_runner. gateway_config_file()/internet_routes_file() read
|
||||
FURTKA_GATEWAY_CONFIG/FURTKA_INTERNET_ROUTES_FILE fresh on every call
|
||||
(no caching), so they don't need a reload — only gateway.py's module-
|
||||
level connect-state/lock constants do.
|
||||
"""
|
||||
apps_dir, _ = fake_dirs
|
||||
root = apps_dir.parent
|
||||
monkeypatch.setenv("FURTKA_GATEWAY_CONFIG", str(root / "gateway.json"))
|
||||
monkeypatch.setenv("FURTKA_INTERNET_ROUTES_FILE", str(root / "internet-routes.json"))
|
||||
monkeypatch.setenv("FURTKA_GATEWAY_CONNECT_STATE", str(root / "gateway-connect-state.json"))
|
||||
monkeypatch.setenv("FURTKA_GATEWAY_CONNECT_LOCK", str(root / "gateway-connect.lock"))
|
||||
import importlib
|
||||
|
||||
from furtka import gateway as g
|
||||
|
||||
importlib.reload(g)
|
||||
return g
|
||||
|
||||
|
||||
def test_gateway_status_not_connected(gateway_paths):
|
||||
status, body = api._do_gateway_status()
|
||||
assert status == 200
|
||||
assert body == {"connected": False}
|
||||
|
||||
|
||||
def test_gateway_status_connected(gateway_paths, monkeypatch):
|
||||
gateway_paths._save_config(
|
||||
{"gateway_url": "https://gw.example.com", "box_id": "abc", "box_token": "abc.x", "wg": {}}
|
||||
)
|
||||
from furtka import wireguard
|
||||
|
||||
monkeypatch.setattr(
|
||||
wireguard, "status", lambda: {"configured": True, "latest_handshake": "123"}
|
||||
)
|
||||
status, body = api._do_gateway_status()
|
||||
assert status == 200
|
||||
assert body["connected"] is True
|
||||
assert body["gateway_url"] == "https://gw.example.com"
|
||||
assert body["box_id"] == "abc"
|
||||
assert body["tunnel"] == {"configured": True, "latest_handshake": "123"}
|
||||
|
||||
|
||||
def test_gateway_connect_requires_all_fields(gateway_paths):
|
||||
status, body = api._do_gateway_connect({"gateway_url": "https://gw.example.com"})
|
||||
assert status == 400
|
||||
assert "required" in body["error"]
|
||||
|
||||
|
||||
def test_gateway_connect_dispatches_systemd_run(gateway_paths, no_systemd_run):
|
||||
status, body = api._do_gateway_connect(
|
||||
{
|
||||
"gateway_url": "https://gw.example.com",
|
||||
"registration_token": "reg-tok",
|
||||
"box_name": "my-box",
|
||||
}
|
||||
)
|
||||
assert status == 202
|
||||
assert body["status"] == "dispatched"
|
||||
[cmd] = no_systemd_run
|
||||
assert cmd[:1] == ["systemd-run"]
|
||||
assert cmd[-5:] == [
|
||||
"gateway",
|
||||
"connect-bg",
|
||||
"https://gw.example.com",
|
||||
"reg-tok",
|
||||
"my-box",
|
||||
]
|
||||
# Initial state written synchronously so the UI has something to poll
|
||||
# before the background job's first write.
|
||||
assert gateway_paths.read_state()["stage"] == "registering"
|
||||
|
||||
|
||||
def test_gateway_connect_lock_contention(gateway_paths):
|
||||
fh = gateway_paths.acquire_lock()
|
||||
try:
|
||||
status, body = api._do_gateway_connect(
|
||||
{
|
||||
"gateway_url": "https://gw.example.com",
|
||||
"registration_token": "reg-tok",
|
||||
"box_name": "my-box",
|
||||
}
|
||||
)
|
||||
assert status == 409
|
||||
assert "already in progress" in body["error"]
|
||||
finally:
|
||||
fh.close()
|
||||
|
||||
|
||||
def test_gateway_connect_surfaces_systemd_run_missing(gateway_paths, monkeypatch):
|
||||
def boom(*a, **kw):
|
||||
raise FileNotFoundError(2, "No such file", "systemd-run")
|
||||
|
||||
monkeypatch.setattr("subprocess.run", boom)
|
||||
status, body = api._do_gateway_connect(
|
||||
{
|
||||
"gateway_url": "https://gw.example.com",
|
||||
"registration_token": "reg-tok",
|
||||
"box_name": "my-box",
|
||||
}
|
||||
)
|
||||
assert status == 502
|
||||
assert "systemd-run" in body["error"]
|
||||
assert gateway_paths.read_state()["stage"] == "error"
|
||||
|
||||
|
||||
def test_gateway_connect_status_reads_state(gateway_paths):
|
||||
gateway_paths.write_state("starting_tunnel")
|
||||
status, body = api._do_gateway_connect_status()
|
||||
assert status == 200
|
||||
assert body["stage"] == "starting_tunnel"
|
||||
|
||||
|
||||
def test_gateway_disconnect_when_not_connected(gateway_paths):
|
||||
status, body = api._do_gateway_disconnect()
|
||||
assert status == 200
|
||||
assert body == {"status": "not connected"}
|
||||
|
||||
|
||||
def test_gateway_disconnect_happy_path(gateway_paths, monkeypatch):
|
||||
gateway_paths._save_config(
|
||||
{"gateway_url": "https://gw.example.com", "box_id": "abc", "box_token": "abc.x", "wg": {}}
|
||||
)
|
||||
from furtka import wireguard
|
||||
|
||||
deregister_calls = []
|
||||
tunnel_calls = []
|
||||
monkeypatch.setattr(gateway_paths, "deregister", lambda: deregister_calls.append(1))
|
||||
monkeypatch.setattr(
|
||||
wireguard, "set_tunnel_enabled", lambda enabled: tunnel_calls.append(enabled)
|
||||
)
|
||||
|
||||
status, body = api._do_gateway_disconnect()
|
||||
|
||||
assert status == 200
|
||||
assert body == {"status": "disconnected"}
|
||||
assert deregister_calls == [1]
|
||||
assert tunnel_calls == [False]
|
||||
|
||||
|
||||
def test_gateway_disconnect_surfaces_deregister_failure(gateway_paths, monkeypatch):
|
||||
gateway_paths._save_config(
|
||||
{"gateway_url": "https://gw.example.com", "box_id": "abc", "box_token": "abc.x", "wg": {}}
|
||||
)
|
||||
|
||||
def boom():
|
||||
raise gateway_paths.GatewayError("gateway unreachable")
|
||||
|
||||
monkeypatch.setattr(gateway_paths, "deregister", boom)
|
||||
status, body = api._do_gateway_disconnect()
|
||||
assert status == 502
|
||||
assert "gateway unreachable" in body["error"]
|
||||
|
||||
|
||||
# --- Internet exposure toggle ------------------------------------------------
|
||||
|
||||
VIABLE_MANIFEST = dict(
|
||||
VALID_MANIFEST,
|
||||
internet={"viable": True, "port": 445},
|
||||
)
|
||||
|
||||
|
||||
def test_get_internet_not_installed(gateway_paths):
|
||||
status, body = api._do_get_internet("ghost")
|
||||
assert status == 404
|
||||
|
||||
|
||||
def _install_app(fake_dirs, manifest, no_docker, no_systemd_run):
|
||||
apps, bundled = fake_dirs
|
||||
_write_bundled(bundled, manifest["name"], manifest=manifest)
|
||||
status, body = api._do_install(manifest["name"])
|
||||
assert status == 202, body
|
||||
return apps / manifest["name"]
|
||||
|
||||
|
||||
def test_get_internet_not_viable_app(gateway_paths, fake_dirs, no_docker, no_systemd_run):
|
||||
_install_app(fake_dirs, VALID_MANIFEST, no_docker, no_systemd_run)
|
||||
status, body = api._do_get_internet("fileshare")
|
||||
assert status == 404
|
||||
assert "not internet-viable" in body["error"]
|
||||
|
||||
|
||||
def test_get_internet_viable_app_not_published(gateway_paths, fake_dirs, no_docker, no_systemd_run):
|
||||
_install_app(fake_dirs, VIABLE_MANIFEST, no_docker, no_systemd_run)
|
||||
status, body = api._do_get_internet("fileshare")
|
||||
assert status == 200
|
||||
assert body == {"enabled": False}
|
||||
|
||||
|
||||
def test_get_internet_viable_app_published(gateway_paths, fake_dirs, no_docker, no_systemd_run):
|
||||
_install_app(fake_dirs, VIABLE_MANIFEST, no_docker, no_systemd_run)
|
||||
api._save_internet_routes(
|
||||
{"fileshare": {"route_id": "r1", "public_url": "https://fs.example.com/"}}
|
||||
)
|
||||
status, body = api._do_get_internet("fileshare")
|
||||
assert status == 200
|
||||
assert body == {"enabled": True, "public_url": "https://fs.example.com/"}
|
||||
|
||||
|
||||
def test_set_internet_requires_enabled_bool(gateway_paths, fake_dirs, no_docker, no_systemd_run):
|
||||
_install_app(fake_dirs, VIABLE_MANIFEST, no_docker, no_systemd_run)
|
||||
status, body = api._do_set_internet("fileshare", {})
|
||||
assert status == 400
|
||||
|
||||
|
||||
def test_set_internet_rejects_non_viable_app(gateway_paths, fake_dirs, no_docker, no_systemd_run):
|
||||
_install_app(fake_dirs, VALID_MANIFEST, no_docker, no_systemd_run)
|
||||
status, body = api._do_set_internet(
|
||||
"fileshare", {"enabled": True, "subdomain": "x.example.com"}
|
||||
)
|
||||
assert status == 400
|
||||
assert "not internet-viable" in body["error"]
|
||||
|
||||
|
||||
def test_set_internet_requires_gateway_connection(
|
||||
gateway_paths, fake_dirs, no_docker, no_systemd_run
|
||||
):
|
||||
_install_app(fake_dirs, VIABLE_MANIFEST, no_docker, no_systemd_run)
|
||||
status, body = api._do_set_internet(
|
||||
"fileshare", {"enabled": True, "subdomain": "x.example.com"}
|
||||
)
|
||||
assert status == 409
|
||||
assert "not connected" in body["error"]
|
||||
|
||||
|
||||
def test_set_internet_enable_requires_subdomain(
|
||||
gateway_paths, fake_dirs, no_docker, no_systemd_run
|
||||
):
|
||||
_install_app(fake_dirs, VIABLE_MANIFEST, no_docker, no_systemd_run)
|
||||
gateway_paths._save_config(
|
||||
{"gateway_url": "https://gw.example.com", "box_id": "abc", "box_token": "abc.x", "wg": {}}
|
||||
)
|
||||
status, body = api._do_set_internet("fileshare", {"enabled": True})
|
||||
assert status == 400
|
||||
assert "subdomain" in body["error"]
|
||||
|
||||
|
||||
def test_set_internet_enable_happy_path(
|
||||
gateway_paths, fake_dirs, no_docker, no_systemd_run, monkeypatch
|
||||
):
|
||||
_install_app(fake_dirs, VIABLE_MANIFEST, no_docker, no_systemd_run)
|
||||
gateway_paths._save_config(
|
||||
{"gateway_url": "https://gw.example.com", "box_id": "abc", "box_token": "abc.x", "wg": {}}
|
||||
)
|
||||
calls = []
|
||||
|
||||
def fake_publish(app_name, subdomain, port):
|
||||
calls.append((app_name, subdomain, port))
|
||||
return {"route_id": "r1", "public_url": "https://fs.example.com/"}
|
||||
|
||||
monkeypatch.setattr(gateway_paths, "publish_route", fake_publish)
|
||||
|
||||
status, body = api._do_set_internet(
|
||||
"fileshare", {"enabled": True, "subdomain": "fs.example.com"}
|
||||
)
|
||||
|
||||
assert status == 200
|
||||
assert body == {"enabled": True, "public_url": "https://fs.example.com/"}
|
||||
assert calls == [("fileshare", "fs.example.com", 445)]
|
||||
assert api._internet_routes()["fileshare"]["route_id"] == "r1"
|
||||
|
||||
|
||||
def test_set_internet_enable_surfaces_gateway_error(
|
||||
gateway_paths, fake_dirs, no_docker, no_systemd_run, monkeypatch
|
||||
):
|
||||
_install_app(fake_dirs, VIABLE_MANIFEST, no_docker, no_systemd_run)
|
||||
gateway_paths._save_config(
|
||||
{"gateway_url": "https://gw.example.com", "box_id": "abc", "box_token": "abc.x", "wg": {}}
|
||||
)
|
||||
|
||||
def boom(app_name, subdomain, port):
|
||||
raise gateway_paths.GatewayError("subdomain already in use")
|
||||
|
||||
monkeypatch.setattr(gateway_paths, "publish_route", boom)
|
||||
|
||||
status, body = api._do_set_internet(
|
||||
"fileshare", {"enabled": True, "subdomain": "fs.example.com"}
|
||||
)
|
||||
assert status == 502
|
||||
assert "subdomain already in use" in body["error"]
|
||||
assert api._internet_routes() == {}
|
||||
|
||||
|
||||
def test_set_internet_disable_happy_path(
|
||||
gateway_paths, fake_dirs, no_docker, no_systemd_run, monkeypatch
|
||||
):
|
||||
_install_app(fake_dirs, VIABLE_MANIFEST, no_docker, no_systemd_run)
|
||||
gateway_paths._save_config(
|
||||
{"gateway_url": "https://gw.example.com", "box_id": "abc", "box_token": "abc.x", "wg": {}}
|
||||
)
|
||||
api._save_internet_routes(
|
||||
{"fileshare": {"route_id": "r1", "public_url": "https://fs.example.com/"}}
|
||||
)
|
||||
calls = []
|
||||
monkeypatch.setattr(gateway_paths, "unpublish_route", lambda route_id: calls.append(route_id))
|
||||
|
||||
status, body = api._do_set_internet("fileshare", {"enabled": False})
|
||||
|
||||
assert status == 200
|
||||
assert body == {"enabled": False}
|
||||
assert calls == ["r1"]
|
||||
assert api._internet_routes() == {}
|
||||
|
||||
|
||||
def test_set_internet_disable_when_not_published_is_a_noop(
|
||||
gateway_paths, fake_dirs, no_docker, no_systemd_run
|
||||
):
|
||||
_install_app(fake_dirs, VIABLE_MANIFEST, no_docker, no_systemd_run)
|
||||
gateway_paths._save_config(
|
||||
{"gateway_url": "https://gw.example.com", "box_id": "abc", "box_token": "abc.x", "wg": {}}
|
||||
)
|
||||
status, body = api._do_set_internet("fileshare", {"enabled": False})
|
||||
assert status == 200
|
||||
assert body == {"enabled": False}
|
||||
|
||||
|
||||
# --- hardening: names, body size, cross-site POSTs, crash handling ----------
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bad", ["/", ".", "..", "../catalog"])
|
||||
def test_http_remove_rejects_path_names(fake_dirs, no_docker, admin_session, bad):
|
||||
apps, _ = fake_dirs
|
||||
(apps / "fileshare").mkdir()
|
||||
server, port = _start_server()
|
||||
try:
|
||||
req = _request(
|
||||
port, "/api/apps/remove", cookie=admin_session, method="POST", body={"name": bad}
|
||||
)
|
||||
with pytest.raises(urllib.error.HTTPError) as e:
|
||||
urllib.request.urlopen(req)
|
||||
assert e.value.code == 400
|
||||
assert (apps / "fileshare").exists()
|
||||
finally:
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
|
||||
|
||||
def test_http_post_rejects_oversized_body(fake_dirs, admin_session):
|
||||
server, port = _start_server()
|
||||
try:
|
||||
import http.client
|
||||
|
||||
# Announce a huge body but never send it: the server must answer
|
||||
# from the header alone instead of waiting to buffer it.
|
||||
conn = http.client.HTTPConnection("127.0.0.1", port, timeout=5)
|
||||
conn.putrequest("POST", "/api/apps/remove")
|
||||
conn.putheader("Cookie", admin_session)
|
||||
conn.putheader("Content-Length", str(api.MAX_BODY_BYTES + 1))
|
||||
conn.endheaders()
|
||||
assert conn.getresponse().status == 413
|
||||
conn.close()
|
||||
finally:
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
|
||||
|
||||
def test_http_post_rejects_same_site_other_origin(fake_dirs, no_docker, admin_session):
|
||||
apps, _ = fake_dirs
|
||||
(apps / "fileshare").mkdir()
|
||||
server, port = _start_server()
|
||||
try:
|
||||
req = _request(
|
||||
port,
|
||||
"/api/apps/remove",
|
||||
cookie=admin_session,
|
||||
method="POST",
|
||||
body={"name": "fileshare"},
|
||||
)
|
||||
req.add_header("Sec-Fetch-Site", "same-site")
|
||||
with pytest.raises(urllib.error.HTTPError) as e:
|
||||
urllib.request.urlopen(req)
|
||||
assert e.value.code == 403
|
||||
assert (apps / "fileshare").exists()
|
||||
finally:
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
|
||||
|
||||
def test_http_unexpected_exception_returns_json_500(fake_dirs, admin_session, monkeypatch):
|
||||
def boom():
|
||||
raise FileNotFoundError("docker")
|
||||
|
||||
monkeypatch.setattr(api, "_list_installed", boom)
|
||||
server, port = _start_server()
|
||||
try:
|
||||
with pytest.raises(urllib.error.HTTPError) as e:
|
||||
urllib.request.urlopen(_request(port, "/api/apps", cookie=admin_session))
|
||||
assert e.value.code == 500
|
||||
assert "internal error" in json.loads(e.value.read())["error"]
|
||||
finally:
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
|
||||
|
||||
def test_login_with_corrupt_users_file_is_503_not_setup(fake_dirs, tmp_path):
|
||||
(tmp_path / "users.json").write_text("")
|
||||
server, port = _start_server()
|
||||
try:
|
||||
with pytest.raises(urllib.error.HTTPError) as e:
|
||||
urllib.request.urlopen(_request(port, "/login"))
|
||||
assert e.value.code == 503
|
||||
req = _request(
|
||||
port,
|
||||
"/login",
|
||||
method="POST",
|
||||
body={"username": "mallory", "password": "longenough1", "password2": "longenough1"},
|
||||
)
|
||||
with pytest.raises(urllib.error.HTTPError) as e:
|
||||
urllib.request.urlopen(req)
|
||||
assert e.value.code == 503
|
||||
assert (tmp_path / "users.json").read_text() == ""
|
||||
finally:
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ def test_build_archinstall_config_includes_post_install_bootstrap(monkeypatch, t
|
|||
}
|
||||
)
|
||||
|
||||
for pkg in ("caddy", "avahi", "nss-mdns", "wireguard-tools"):
|
||||
for pkg in ("caddy", "avahi", "nss-mdns"):
|
||||
assert pkg in cfg["packages"]
|
||||
# Packaged units go in `services` (enabled before custom_commands runs);
|
||||
# our own units don't exist at that point, so they must be enabled from
|
||||
|
|
@ -226,180 +226,3 @@ def test_log_page_running_state_has_no_restart_button(monkeypatch, tmp_path):
|
|||
html = app_module.app.test_client().get("/install/log").get_data(as_text=True)
|
||||
assert "next-steps" not in html
|
||||
assert "install_reboot" not in html and "restart now" not in html
|
||||
|
||||
|
||||
def test_nonzero_exit_without_traceback_is_an_error():
|
||||
import app as app_module
|
||||
|
||||
# OOM kill / signal: archinstall dies mid-pacstrap and prints nothing.
|
||||
log = "Installing packages: ['base'\n"
|
||||
assert app_module.parse_install_progress(log)["status"] == "running"
|
||||
assert app_module.parse_install_progress(log, exit_code=-9)["status"] == "error"
|
||||
assert app_module.parse_install_progress(log, exit_code=0)["status"] == "running"
|
||||
|
||||
|
||||
class _FakeProc:
|
||||
def __init__(self, code=None):
|
||||
self.code = code
|
||||
|
||||
def poll(self):
|
||||
return self.code
|
||||
|
||||
|
||||
def _install_env(monkeypatch, tmp_path):
|
||||
import app as app_module
|
||||
|
||||
monkeypatch.setattr(app_module, "STATE_DIR", tmp_path)
|
||||
monkeypatch.setattr(app_module, "INSTALL_LOG", tmp_path / "install.log")
|
||||
monkeypatch.setattr(app_module, "_install_proc", None)
|
||||
monkeypatch.delenv("FURTKA_DRY_RUN", raising=False)
|
||||
monkeypatch.setitem(app_module.settings, "boot_drive", "/dev/sda")
|
||||
monkeypatch.setitem(app_module.settings, "username", "u")
|
||||
monkeypatch.setitem(app_module.settings, "password", "pw12345678")
|
||||
monkeypatch.setattr(app_module, "release_disk", lambda d: [f"released {d}"])
|
||||
monkeypatch.setattr(app_module, "build_disk_config", lambda d: {"device": d})
|
||||
return app_module
|
||||
|
||||
|
||||
def test_install_run_refuses_second_concurrent_install(monkeypatch, tmp_path):
|
||||
app_module = _install_env(monkeypatch, tmp_path)
|
||||
spawned = []
|
||||
monkeypatch.setattr(
|
||||
app_module, "spawn_archinstall", lambda *a: spawned.append(a) or _FakeProc()
|
||||
)
|
||||
client = app_module.app.test_client()
|
||||
assert client.post("/install/run").status_code == 302
|
||||
assert client.post("/install/run").status_code == 302
|
||||
assert len(spawned) == 1
|
||||
|
||||
|
||||
def test_install_run_disk_probe_failure_lands_in_log(monkeypatch, tmp_path):
|
||||
app_module = _install_env(monkeypatch, tmp_path)
|
||||
|
||||
def boom(_):
|
||||
raise RuntimeError("parted could not read /dev/sda")
|
||||
|
||||
monkeypatch.setattr(app_module, "build_disk_config", boom)
|
||||
resp = app_module.app.test_client().post("/install/run")
|
||||
assert resp.status_code == 302
|
||||
log = (tmp_path / "install.log").read_text()
|
||||
assert "Traceback (most recent call last)" in log
|
||||
assert app_module.parse_install_progress(log)["status"] == "error"
|
||||
|
||||
|
||||
def test_install_log_json_reports_crashed_archinstall(monkeypatch, tmp_path):
|
||||
app_module = _install_env(monkeypatch, tmp_path)
|
||||
(tmp_path / "install.log").write_text("Installing packages: ['base'\n")
|
||||
monkeypatch.setattr(app_module, "_install_proc", _FakeProc(code=137))
|
||||
data = app_module.app.test_client().get("/install/log.json").get_json()
|
||||
assert data["progress"]["status"] == "error"
|
||||
assert "exit code 137" in data["log"]
|
||||
|
||||
|
||||
def test_step2_rejects_disk_not_offered(monkeypatch):
|
||||
import app as app_module
|
||||
|
||||
offered = [
|
||||
{
|
||||
"name": "/dev/sda",
|
||||
"usable": True,
|
||||
"size": "500 GB",
|
||||
"type_label": "SSD",
|
||||
"health_label": "Healthy",
|
||||
"score": 27,
|
||||
"reason": "",
|
||||
"warning": "",
|
||||
},
|
||||
{
|
||||
"name": "/dev/sdb",
|
||||
"usable": False,
|
||||
"size": "8 GB",
|
||||
"type_label": "USB",
|
||||
"health_label": "Status unknown",
|
||||
"score": 10,
|
||||
"reason": "Too small",
|
||||
"warning": "",
|
||||
},
|
||||
]
|
||||
monkeypatch.setattr(app_module, "list_scored_devices", lambda: offered)
|
||||
monkeypatch.setitem(app_module.settings, "boot_drive", "")
|
||||
client = app_module.app.test_client()
|
||||
for bad in ("/dev/sdb", "/dev/nope", "/etc/passwd"):
|
||||
resp = client.post("/install/step2", data={"boot_drive": bad})
|
||||
assert resp.status_code == 200
|
||||
assert app_module.settings["boot_drive"] == ""
|
||||
resp = client.post("/install/step2", data={"boot_drive": "/dev/sda"})
|
||||
assert resp.status_code == 302
|
||||
assert app_module.settings["boot_drive"] == "/dev/sda"
|
||||
|
||||
|
||||
def test_validate_step1_lowercases_names():
|
||||
errors, values = validate_step1(
|
||||
{
|
||||
"hostname": "Furtka",
|
||||
"username": "Daniel",
|
||||
"password": "topsecretpw",
|
||||
"password2": "topsecretpw",
|
||||
"language": "de",
|
||||
}
|
||||
)
|
||||
assert errors == []
|
||||
assert values["hostname"] == "furtka"
|
||||
assert values["username"] == "daniel"
|
||||
|
||||
|
||||
def test_validate_step1_rejects_reserved_usernames():
|
||||
for name in ("root", "caddy", "docker", "nobody"):
|
||||
errors, _ = validate_step1(
|
||||
{
|
||||
"hostname": "furtka",
|
||||
"username": name,
|
||||
"password": "topsecretpw",
|
||||
"password2": "topsecretpw",
|
||||
"language": "en",
|
||||
}
|
||||
)
|
||||
assert len(errors) == 1 and "reserved" in errors[0], name
|
||||
|
||||
|
||||
def test_post_install_sets_wait_online_any(monkeypatch):
|
||||
import base64
|
||||
|
||||
import app as app_module
|
||||
|
||||
cmds = app_module._post_install_commands("h", "u", "pw12345678")
|
||||
hits = [c for c in cmds if "systemd-networkd-wait-online.service.d" in c]
|
||||
assert len(hits) == 1
|
||||
payload = hits[0].split("printf %s ")[1].split(" |")[0]
|
||||
assert "--any" in base64.b64decode(payload).decode()
|
||||
|
||||
|
||||
def test_wizard_pages_redirect_to_progress_while_installing(monkeypatch, tmp_path):
|
||||
app_module = _install_env(monkeypatch, tmp_path)
|
||||
monkeypatch.setattr(app_module, "_install_proc", _FakeProc(code=None))
|
||||
client = app_module.app.test_client()
|
||||
for path in ("/install/step1", "/install/step2", "/install/overview"):
|
||||
resp = client.get(path)
|
||||
assert resp.status_code == 302
|
||||
assert resp.headers["Location"].endswith("/install/log")
|
||||
|
||||
|
||||
def test_error_page_offers_retry(monkeypatch, tmp_path):
|
||||
app_module = _install_env(monkeypatch, tmp_path)
|
||||
(tmp_path / "install.log").write_text("Traceback (most recent call last)\nboom\n")
|
||||
html = app_module.app.test_client().get("/install/log").get_data(as_text=True)
|
||||
assert "Try again" in html
|
||||
assert "next-steps" not in html
|
||||
|
||||
|
||||
def test_detect_bootloader_by_firmware(tmp_path):
|
||||
import app as app_module
|
||||
|
||||
efi = tmp_path / "efi"
|
||||
assert app_module._detect_bootloader(efi) == "Grub" # BIOS / legacy
|
||||
efi.mkdir()
|
||||
assert app_module._detect_bootloader(efi) == "Systemd-boot" # no bitness file
|
||||
(efi / "fw_platform_size").write_text("64\n")
|
||||
assert app_module._detect_bootloader(efi) == "Systemd-boot"
|
||||
(efi / "fw_platform_size").write_text("32\n")
|
||||
assert app_module._detect_bootloader(efi) == "Limine"
|
||||
|
|
|
|||
|
|
@ -40,15 +40,14 @@ def test_load_users_returns_empty_when_missing(tmp_users_file):
|
|||
assert auth.load_users() == {}
|
||||
|
||||
|
||||
@pytest.mark.parametrize("content", ["{not json", "[]", "", "\x00\x00"])
|
||||
def test_load_users_fails_closed_on_corrupt_file(tmp_users_file, content):
|
||||
"""A damaged users.json must not read as "no admin yet" — that would
|
||||
turn /login into an open create-admin form for anyone on the LAN."""
|
||||
tmp_users_file.write_text(content)
|
||||
with pytest.raises(auth.UsersFileError):
|
||||
auth.load_users()
|
||||
with pytest.raises(auth.UsersFileError):
|
||||
auth.setup_needed()
|
||||
def test_load_users_returns_empty_on_junk(tmp_users_file):
|
||||
tmp_users_file.write_text("{not json")
|
||||
assert auth.load_users() == {}
|
||||
|
||||
|
||||
def test_load_users_returns_empty_on_non_dict(tmp_users_file):
|
||||
tmp_users_file.write_text("[]")
|
||||
assert auth.load_users() == {}
|
||||
|
||||
|
||||
def test_save_users_atomic_and_0600(tmp_users_file):
|
||||
|
|
|
|||
|
|
@ -56,27 +56,23 @@ def _make_catalog_tarball(
|
|||
*,
|
||||
apps: list[tuple[str, dict]] | None = None,
|
||||
extra_entries: list[tuple[str, bytes]] | None = None,
|
||||
compose_overrides: dict[str, bytes] | None = None,
|
||||
) -> None:
|
||||
"""Build a minimal valid catalog tarball.
|
||||
|
||||
`apps` is a list of (folder_name, manifest_dict). Each app folder gets
|
||||
a `manifest.json` + a stub `docker-compose.yaml` + `icon.svg`.
|
||||
`compose_overrides` (folder_name -> bytes) replaces that stub content
|
||||
for specific apps — for testing catalog-side compose checks (e.g.
|
||||
`internet.viable` + `privileged: true`) without needing a real image.
|
||||
`extra_entries` lets tests inject malformed content (path-traversal,
|
||||
missing VERSION, ...) without rebuilding the helper.
|
||||
"""
|
||||
apps = apps if apps is not None else [("fileshare", _manifest())]
|
||||
compose_overrides = compose_overrides or {}
|
||||
buf = io.BytesIO()
|
||||
with tarfile.open(fileobj=buf, mode="w:gz") as tf:
|
||||
entries: list[tuple[str, bytes]] = [("VERSION", f"{version}\n".encode())]
|
||||
for folder, m in apps:
|
||||
entries.append((f"apps/{folder}/manifest.json", json.dumps(m).encode()))
|
||||
compose = compose_overrides.get(folder, b"services:\n app:\n image: scratch\n")
|
||||
entries.append((f"apps/{folder}/docker-compose.yaml", compose))
|
||||
entries.append(
|
||||
(f"apps/{folder}/docker-compose.yaml", b"services:\n app:\n image: scratch\n")
|
||||
)
|
||||
entries.append((f"apps/{folder}/icon.svg", b"<svg/>"))
|
||||
if extra_entries:
|
||||
entries.extend(extra_entries)
|
||||
|
|
@ -270,76 +266,6 @@ def test_sync_catalog_refuses_tarball_with_invalid_manifest(catalog, monkeypatch
|
|||
assert not catalog.catalog_dir().exists()
|
||||
|
||||
|
||||
def test_sync_catalog_refuses_privileged_internet_viable_app(catalog, monkeypatch, tmp_path):
|
||||
import hashlib
|
||||
|
||||
viable_manifest = dict(_manifest(), internet={"viable": True, "port": 445})
|
||||
|
||||
tarball_path = tmp_path / "tarball.tar.gz"
|
||||
_make_catalog_tarball(
|
||||
tarball_path,
|
||||
"26.6",
|
||||
apps=[("fileshare", viable_manifest)],
|
||||
compose_overrides={
|
||||
"fileshare": b"services:\n app:\n image: scratch\n privileged: true\n"
|
||||
},
|
||||
)
|
||||
tarball_bytes = tarball_path.read_bytes()
|
||||
sha = hashlib.sha256(tarball_bytes).hexdigest()
|
||||
|
||||
_stub_forgejo_release(monkeypatch, catalog, tag="26.6")
|
||||
_stub_download(
|
||||
monkeypatch,
|
||||
catalog,
|
||||
{
|
||||
"https://forgejo.test.local/t.tar.gz": tarball_bytes,
|
||||
"https://forgejo.test.local/t.tar.gz.sha256": (
|
||||
f"{sha} furtka-apps-26.6.tar.gz\n".encode()
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
with pytest.raises(catalog.CatalogError, match="must not run privileged"):
|
||||
catalog.sync_catalog()
|
||||
assert not catalog.catalog_dir().exists()
|
||||
|
||||
|
||||
def test_sync_catalog_allows_privileged_app_that_is_not_internet_viable(
|
||||
catalog, monkeypatch, tmp_path
|
||||
):
|
||||
"""privileged: true is only disqualifying for internet.viable apps —
|
||||
home-assistant's real catalog entry runs privileged for USB/Bluetooth
|
||||
access and is simply not marked viable."""
|
||||
import hashlib
|
||||
|
||||
tarball_path = tmp_path / "tarball.tar.gz"
|
||||
_make_catalog_tarball(
|
||||
tarball_path,
|
||||
"26.6",
|
||||
apps=[("fileshare", _manifest())],
|
||||
compose_overrides={
|
||||
"fileshare": b"services:\n app:\n image: scratch\n privileged: true\n"
|
||||
},
|
||||
)
|
||||
tarball_bytes = tarball_path.read_bytes()
|
||||
sha = hashlib.sha256(tarball_bytes).hexdigest()
|
||||
|
||||
_stub_forgejo_release(monkeypatch, catalog, tag="26.6")
|
||||
_stub_download(
|
||||
monkeypatch,
|
||||
catalog,
|
||||
{
|
||||
"https://forgejo.test.local/t.tar.gz": tarball_bytes,
|
||||
"https://forgejo.test.local/t.tar.gz.sha256": (
|
||||
f"{sha} furtka-apps-26.6.tar.gz\n".encode()
|
||||
),
|
||||
},
|
||||
)
|
||||
|
||||
catalog.sync_catalog()
|
||||
assert catalog.catalog_dir().exists()
|
||||
|
||||
|
||||
def test_sync_catalog_preserves_existing_catalog_on_failure(catalog, monkeypatch, tmp_path):
|
||||
"""A failed sync must leave the previous live catalog intact so boxes
|
||||
keep working until the next successful sync."""
|
||||
|
|
@ -423,30 +349,3 @@ def test_sync_catalog_failure_writes_error_state(catalog, monkeypatch):
|
|||
state = catalog.read_state()
|
||||
assert state["stage"] == "error"
|
||||
assert "Network is unreachable" in state["error"]
|
||||
|
||||
|
||||
def test_sync_catalog_unexpected_error_lands_as_error_stage(catalog, monkeypatch):
|
||||
"""Disk full / mid-body disconnect used to leave the stage at
|
||||
'downloading' forever because only CatalogError was caught."""
|
||||
_stub_forgejo_release(monkeypatch, catalog, tag="26.6")
|
||||
|
||||
def boom(*a, **kw):
|
||||
raise OSError(28, "No space left on device")
|
||||
|
||||
monkeypatch.setattr(catalog._rc, "download", boom)
|
||||
with pytest.raises(catalog.CatalogError, match="No space left"):
|
||||
catalog.sync_catalog()
|
||||
assert catalog.read_state()["stage"] == "error"
|
||||
|
||||
|
||||
def test_release_download_wraps_socket_errors(tmp_path, monkeypatch):
|
||||
from furtka import _release_common as rc
|
||||
|
||||
def reset(*a, **kw):
|
||||
raise ConnectionResetError("reset by peer")
|
||||
|
||||
monkeypatch.setattr(rc.urllib.request, "urlopen", reset)
|
||||
with pytest.raises(rc.ReleaseError, match="reset by peer"):
|
||||
rc.download("https://x/y", tmp_path / "y")
|
||||
with pytest.raises(rc.ReleaseError, match="reset by peer"):
|
||||
rc.forgejo_api("x", "a/b", "/releases")
|
||||
|
|
|
|||
|
|
@ -63,36 +63,6 @@ def test_app_list_json_with_one_app(tmp_path, monkeypatch, capsys):
|
|||
assert m["settings"][0]["name"] == "SMB_USER"
|
||||
assert m["settings"][0]["required"] is True
|
||||
assert m["settings"][0]["default"] == "furtka"
|
||||
assert m["internet"] == {"viable": False, "port": None}
|
||||
|
||||
|
||||
def test_gateway_connect_bg_dispatches_to_run_connect(tmp_path, monkeypatch):
|
||||
"""CLI `gateway connect-bg <url> <token> <name>` must call
|
||||
gateway.run_connect(url, token, name) — the entry point the HTTP API
|
||||
fires via systemd-run for POST /api/gateway/connect."""
|
||||
_set_env(monkeypatch, tmp_path)
|
||||
from furtka import gateway
|
||||
|
||||
called = []
|
||||
monkeypatch.setattr(
|
||||
gateway, "run_connect", lambda url, token, name: called.append((url, token, name))
|
||||
)
|
||||
rc = main(["gateway", "connect-bg", "https://gw.example.com", "reg-token", "my-box"])
|
||||
assert rc == 0
|
||||
assert called == [("https://gw.example.com", "reg-token", "my-box")]
|
||||
|
||||
|
||||
def test_gateway_connect_bg_returns_1_on_failure(tmp_path, monkeypatch, capsys):
|
||||
_set_env(monkeypatch, tmp_path)
|
||||
from furtka import gateway
|
||||
|
||||
def boom(url, token, name):
|
||||
raise RuntimeError("gateway unreachable")
|
||||
|
||||
monkeypatch.setattr(gateway, "run_connect", boom)
|
||||
rc = main(["gateway", "connect-bg", "https://gw.example.com", "reg-token", "my-box"])
|
||||
assert rc == 1
|
||||
assert "gateway connect-bg failed" in capsys.readouterr().err
|
||||
|
||||
|
||||
def test_reconcile_dry_run_empty(tmp_path, monkeypatch, capsys):
|
||||
|
|
|
|||
|
|
@ -1,63 +1,47 @@
|
|||
import json
|
||||
|
||||
import drives
|
||||
import pytest
|
||||
from drives import (
|
||||
MIN_DISK_GB,
|
||||
_boot_device_from_cmdline,
|
||||
classify_drive,
|
||||
format_size,
|
||||
get_drive_type_label,
|
||||
get_drive_type_score,
|
||||
get_size_score,
|
||||
parse_lsblk_json,
|
||||
parse_lsblk_output,
|
||||
parse_size_gb,
|
||||
score_device,
|
||||
)
|
||||
|
||||
GB = 1024**3
|
||||
|
||||
def test_parse_size_gb_terabytes():
|
||||
assert parse_size_gb("1T") == 1024.0
|
||||
|
||||
|
||||
def _lsblk(*entries):
|
||||
"""Build lsblk -J output. Each entry: (name, size_gb, type, extra-dict)."""
|
||||
devs = []
|
||||
for name, size_gb, dev_type, *extra in entries:
|
||||
d = {
|
||||
"name": name,
|
||||
"size": int(size_gb * GB),
|
||||
"type": dev_type,
|
||||
"ro": False,
|
||||
"rm": False,
|
||||
"tran": "sata",
|
||||
"rota": True,
|
||||
}
|
||||
if extra:
|
||||
d.update(extra[0])
|
||||
devs.append(d)
|
||||
return json.dumps({"blockdevices": devs})
|
||||
def test_parse_size_gb_gigabytes():
|
||||
assert parse_size_gb("500G") == 500.0
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _smart_passed(monkeypatch):
|
||||
monkeypatch.setattr(drives, "_smart_status", lambda _: "passed")
|
||||
def test_parse_size_gb_megabytes():
|
||||
assert parse_size_gb("2048M") == 2.0
|
||||
|
||||
|
||||
def _names(devices):
|
||||
return [d["name"] for d in devices]
|
||||
def test_parse_size_gb_european_comma_decimal():
|
||||
assert parse_size_gb("1,5T") == 1.5 * 1024
|
||||
|
||||
|
||||
def test_classify_uses_transport_and_rotation():
|
||||
assert classify_drive("nvme0n1", tran="nvme", rota=False) == "NVMe"
|
||||
assert classify_drive("sda", tran="sata", rota=False) == "SSD"
|
||||
assert classify_drive("sda", tran="sata", rota=True) == "HDD"
|
||||
assert classify_drive("mmcblk0", tran="", rota=False) == "eMMC"
|
||||
assert classify_drive("sdb", tran="usb", rota=False) == "USB"
|
||||
assert classify_drive("sdc", tran="", rota=True, removable=True) == "USB"
|
||||
# SD cards in a built-in reader are removable mmc — still eMMC/mmc class.
|
||||
assert classify_drive("mmcblk1", tran="", rota=False, removable=True) == "eMMC"
|
||||
def test_parse_size_gb_empty_returns_none():
|
||||
assert parse_size_gb("") is None
|
||||
|
||||
|
||||
def test_type_scores_rank_internal_over_usb():
|
||||
assert get_drive_type_score("NVMe") > get_drive_type_score("SSD")
|
||||
assert get_drive_type_score("SSD") > get_drive_type_score("HDD")
|
||||
assert get_drive_type_score("HDD") > get_drive_type_score("USB")
|
||||
def test_parse_size_gb_unknown_unit_returns_none():
|
||||
assert parse_size_gb("500K") is None
|
||||
|
||||
|
||||
def test_drive_type_score_nvme():
|
||||
assert get_drive_type_score("/dev/nvme0n1") == 15
|
||||
|
||||
|
||||
def test_drive_type_score_ssd():
|
||||
assert get_drive_type_score("/dev/ssd0") == 10
|
||||
|
||||
|
||||
def test_drive_type_score_hdd_fallback():
|
||||
assert get_drive_type_score("/dev/sda") == 5
|
||||
|
||||
|
||||
def test_size_score_bands():
|
||||
|
|
@ -67,145 +51,67 @@ def test_size_score_bands():
|
|||
assert get_size_score(1024) == 10
|
||||
|
||||
|
||||
def test_format_size():
|
||||
assert format_size(500 * GB) == "500 GB"
|
||||
assert format_size(1024 * GB) == "1 TB"
|
||||
assert format_size(int(1.5 * 1024 * GB)) == "1.5 TB"
|
||||
assert format_size(int(7.5 * GB)) == "7.5 GB"
|
||||
def test_score_device_sums_type_and_size(monkeypatch):
|
||||
import drives
|
||||
|
||||
monkeypatch.setattr(drives, "get_drive_health", lambda _: 10)
|
||||
assert score_device("/dev/nvme0n1", 1024) == 15 + 10 + 10
|
||||
assert score_device("/dev/sda", 64) == 5 + 10 + 5
|
||||
|
||||
|
||||
def test_drops_loop_rom_zram_and_emmc_boot_areas():
|
||||
out = _lsblk(
|
||||
("loop0", 2.5, "loop"),
|
||||
("sr0", 1, "rom"),
|
||||
("zram0", 4, "disk"),
|
||||
("mmcblk0boot0", 0.004, "disk"),
|
||||
("mmcblk0boot1", 0.004, "disk"),
|
||||
("mmcblk0rpmb", 0.004, "disk"),
|
||||
("mmcblk0", 64, "disk", {"tran": "", "rota": False}),
|
||||
)
|
||||
assert _names(parse_lsblk_json(out)) == ["/dev/mmcblk0"]
|
||||
def test_parse_lsblk_drops_loop_and_rom(monkeypatch):
|
||||
import drives
|
||||
|
||||
monkeypatch.setattr(drives, "_smart_status", lambda _: "passed")
|
||||
output = "loop0 2.5G loop\nsr0 1024M rom\nsda 500G disk\nnvme0n1 1T disk\n"
|
||||
devices = parse_lsblk_output(output)
|
||||
names = [d["name"] for d in devices]
|
||||
assert names == ["/dev/nvme0n1", "/dev/sda"]
|
||||
|
||||
|
||||
def test_drops_empty_card_reader_slots_and_read_only_disks():
|
||||
out = _lsblk(
|
||||
("sdc", 0, "disk", {"rm": True, "tran": "usb"}),
|
||||
("sdd", 500, "disk", {"ro": True}),
|
||||
("sda", 500, "disk"),
|
||||
)
|
||||
assert _names(parse_lsblk_json(out)) == ["/dev/sda"]
|
||||
def test_parse_lsblk_attaches_human_labels(monkeypatch):
|
||||
import drives
|
||||
|
||||
monkeypatch.setattr(drives, "_smart_status", lambda _: "passed")
|
||||
output = "nvme0n1 1T disk\n"
|
||||
[dev] = parse_lsblk_output(output)
|
||||
assert dev["type_label"] == "NVMe"
|
||||
assert dev["health_label"] == "Healthy"
|
||||
|
||||
|
||||
def test_ssd_beats_bigger_hdd():
|
||||
# Regression: sdX SSDs used to be labelled HDD, so the 2 TB spinning disk
|
||||
# won the recommendation over the 256 GB SSD.
|
||||
out = _lsblk(
|
||||
("sda", 2048, "disk", {"rota": True}),
|
||||
("sdb", 256, "disk", {"rota": False}),
|
||||
)
|
||||
devices = parse_lsblk_json(out)
|
||||
assert _names(devices) == ["/dev/sdb", "/dev/sda"]
|
||||
assert [d["type_label"] for d in devices] == ["SSD", "HDD"]
|
||||
def test_parse_lsblk_surfaces_smart_warning(monkeypatch):
|
||||
import drives
|
||||
|
||||
|
||||
def test_usb_disk_ranked_after_internal():
|
||||
out = _lsblk(
|
||||
("sda", 32, "disk", {"tran": "usb", "rota": False, "rm": True}),
|
||||
("mmcblk0", 32, "disk", {"tran": "", "rota": False}),
|
||||
)
|
||||
devices = parse_lsblk_json(out)
|
||||
assert _names(devices) == ["/dev/mmcblk0", "/dev/sda"]
|
||||
assert devices[1]["warning"]
|
||||
|
||||
|
||||
def test_too_small_disk_listed_but_unusable_and_last():
|
||||
out = _lsblk(
|
||||
("sda", MIN_DISK_GB - 1, "disk", {"rota": False}),
|
||||
("sdb", 500, "disk"),
|
||||
)
|
||||
devices = parse_lsblk_json(out)
|
||||
assert _names(devices) == ["/dev/sdb", "/dev/sda"]
|
||||
assert devices[0]["usable"] is True
|
||||
assert devices[1]["usable"] is False
|
||||
assert str(MIN_DISK_GB) in devices[1]["reason"]
|
||||
|
||||
|
||||
def test_bios_warns_about_disks_over_2tb():
|
||||
out = _lsblk(("sda", 4096, "disk"))
|
||||
[bios] = parse_lsblk_json(out, uefi=False)
|
||||
[efi] = parse_lsblk_json(out, uefi=True)
|
||||
assert "2 TB" in bios["warning"]
|
||||
assert efi["warning"] == ""
|
||||
|
||||
|
||||
def test_surfaces_smart_warning(monkeypatch):
|
||||
monkeypatch.setattr(drives, "_smart_status", lambda _: "failed")
|
||||
[dev] = parse_lsblk_json(_lsblk(("sda", 500, "disk")))
|
||||
[dev] = parse_lsblk_output("sda 500G disk\n")
|
||||
assert dev["health_label"] == "SMART warning"
|
||||
|
||||
|
||||
def test_accepts_old_util_linux_string_flags():
|
||||
out = json.dumps(
|
||||
{
|
||||
"blockdevices": [
|
||||
{
|
||||
"name": "sda",
|
||||
"size": str(500 * GB),
|
||||
"type": "disk",
|
||||
"ro": "0",
|
||||
"rm": "0",
|
||||
"tran": "sata",
|
||||
"rota": "0",
|
||||
},
|
||||
]
|
||||
}
|
||||
)
|
||||
[dev] = parse_lsblk_json(out)
|
||||
assert dev["type_label"] == "SSD"
|
||||
def test_drive_type_label_nvme_ssd_hdd():
|
||||
assert get_drive_type_label("/dev/nvme0n1") == "NVMe"
|
||||
assert get_drive_type_label("/dev/ssd0") == "SSD"
|
||||
assert get_drive_type_label("/dev/sda") == "HDD"
|
||||
|
||||
|
||||
def test_handles_empty_and_garbage_output():
|
||||
assert parse_lsblk_json("") == []
|
||||
assert parse_lsblk_json("not json") == []
|
||||
def test_parse_lsblk_handles_empty_output():
|
||||
assert parse_lsblk_output("") == []
|
||||
|
||||
|
||||
def test_drops_boot_usb():
|
||||
out = _lsblk(
|
||||
("sda", 500, "disk"),
|
||||
("sdb", 16, "disk", {"tran": "usb"}),
|
||||
("nvme0n1", 1024, "disk", {"tran": "nvme", "rota": False}),
|
||||
)
|
||||
assert _names(parse_lsblk_json(out, boot_disk="sdb")) == ["/dev/nvme0n1", "/dev/sda"]
|
||||
def test_parse_lsblk_drops_boot_usb(monkeypatch):
|
||||
import drives
|
||||
|
||||
monkeypatch.setattr(drives, "_smart_status", lambda _: "passed")
|
||||
output = "sda 500G disk\nsdb 16G disk\nnvme0n1 1T disk\n"
|
||||
devices = parse_lsblk_output(output, boot_disk="sdb")
|
||||
names = [d["name"] for d in devices]
|
||||
assert "/dev/sdb" not in names
|
||||
assert names == ["/dev/nvme0n1", "/dev/sda"]
|
||||
|
||||
|
||||
def test_boot_device_from_cmdline(monkeypatch):
|
||||
calls = []
|
||||
def test_parse_lsblk_no_boot_disk_keeps_all(monkeypatch):
|
||||
import drives
|
||||
|
||||
class R:
|
||||
returncode = 0
|
||||
stdout = "/dev/sdb1\n"
|
||||
|
||||
monkeypatch.setattr(drives, "_run", lambda cmd, **_: calls.append(cmd) or R())
|
||||
cmdline = "BOOT_IMAGE=/vmlinuz archisosearchuuid=2026-08-25-10-00-00-00 quiet"
|
||||
assert _boot_device_from_cmdline(cmdline) == "/dev/sdb1"
|
||||
assert calls[-1] == ["blkid", "-U", "2026-08-25-10-00-00-00"]
|
||||
assert _boot_device_from_cmdline("archisolabel=FURTKA_2620") == "/dev/sdb1"
|
||||
assert calls[-1] == ["blkid", "-L", "FURTKA_2620"]
|
||||
assert _boot_device_from_cmdline("archisodevice=/dev/sr0") == "/dev/sr0"
|
||||
assert _boot_device_from_cmdline("quiet splash") is None
|
||||
|
||||
|
||||
def test_boot_disk_whole_disk_iso(monkeypatch):
|
||||
# dd-written stick: ISO filesystem on the whole disk, PKNAME empty.
|
||||
class R:
|
||||
def __init__(self, out):
|
||||
self.returncode = 0
|
||||
self.stdout = out
|
||||
|
||||
def fake_run(cmd, **_):
|
||||
if cmd[0] == "findmnt":
|
||||
return R("/dev/sdb\n")
|
||||
return R("\n")
|
||||
|
||||
monkeypatch.setattr(drives, "_run", fake_run)
|
||||
assert drives._boot_disk_name() == "sdb"
|
||||
monkeypatch.setattr(drives, "_smart_status", lambda _: "passed")
|
||||
output = "sda 500G disk\nsdb 16G disk\n"
|
||||
names = [d["name"] for d in parse_lsblk_output(output, boot_disk=None)]
|
||||
assert set(names) == {"/dev/sda", "/dev/sdb"}
|
||||
|
|
|
|||
|
|
@ -1,350 +0,0 @@
|
|||
"""Tests for furtka.gateway — the box-side register/rotate/deregister client.
|
||||
|
||||
Same shape as test_updater.py's network tests: monkeypatch
|
||||
urllib.request.urlopen directly rather than standing up a real server.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import urllib.error
|
||||
|
||||
import pytest
|
||||
|
||||
from furtka import gateway
|
||||
|
||||
|
||||
class _FakeResp:
|
||||
def __init__(self, body: dict):
|
||||
self._body = json.dumps(body).encode()
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *a):
|
||||
return False
|
||||
|
||||
def read(self):
|
||||
return self._body
|
||||
|
||||
|
||||
WG = {
|
||||
"private_key": "cHJpdmF0ZS1rZXk=",
|
||||
"address": "10.8.0.2/24",
|
||||
"server_public_key": "c2VydmVyLXB1YmxpYy1rZXk=",
|
||||
"endpoint": "gateway.example.com:51820",
|
||||
"allowed_ips": "10.8.0.0/24",
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def gw(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("FURTKA_GATEWAY_CONFIG", str(tmp_path / "gateway.json"))
|
||||
monkeypatch.setenv("FURTKA_GATEWAY_CONNECT_STATE", str(tmp_path / "gateway-connect-state.json"))
|
||||
monkeypatch.setenv("FURTKA_GATEWAY_CONNECT_LOCK", str(tmp_path / "gateway-connect.lock"))
|
||||
import importlib
|
||||
|
||||
from furtka import paths as p
|
||||
|
||||
importlib.reload(p)
|
||||
importlib.reload(gateway)
|
||||
return gateway
|
||||
|
||||
|
||||
def test_load_config_returns_none_when_never_registered(gw):
|
||||
assert gw.load_config() is None
|
||||
|
||||
|
||||
def test_register_saves_config(gw, monkeypatch):
|
||||
calls = []
|
||||
|
||||
def fake_urlopen(req, timeout):
|
||||
calls.append((req.full_url, json.loads(req.data)))
|
||||
return _FakeResp({"box_id": "abc123", "box_token": "abc123.secret", "wg": WG})
|
||||
|
||||
monkeypatch.setattr("urllib.request.urlopen", fake_urlopen)
|
||||
|
||||
config = gw.register("https://gw.example.com/", "reg-token", "my-box")
|
||||
|
||||
assert config["gateway_url"] == "https://gw.example.com" # trailing slash stripped
|
||||
assert config["box_id"] == "abc123"
|
||||
assert config["box_token"] == "abc123.secret"
|
||||
assert config["wg"] == WG
|
||||
assert gw.load_config() == config
|
||||
|
||||
url, body = calls[0]
|
||||
assert url == "https://gw.example.com/v1/boxes/register"
|
||||
assert body == {"registration_token": "reg-token", "box_name": "my-box"}
|
||||
|
||||
|
||||
def test_register_config_file_is_0600(gw, monkeypatch, tmp_path):
|
||||
monkeypatch.setattr(
|
||||
"urllib.request.urlopen",
|
||||
lambda req, timeout: _FakeResp({"box_id": "abc", "box_token": "abc.x", "wg": WG}),
|
||||
)
|
||||
gw.register("https://gw.example.com", "tok", "box")
|
||||
from furtka.paths import gateway_config_file
|
||||
|
||||
assert oct(gateway_config_file().stat().st_mode)[-3:] == "600"
|
||||
|
||||
|
||||
def test_register_raises_gateway_error_on_http_error(gw, monkeypatch):
|
||||
def raising(req, timeout):
|
||||
raise urllib.error.HTTPError(req.full_url, 401, "invalid registration token", {}, None)
|
||||
|
||||
monkeypatch.setattr("urllib.request.urlopen", raising)
|
||||
|
||||
with pytest.raises(gateway.GatewayError, match="HTTP 401"):
|
||||
gw.register("https://gw.example.com", "bad-token", "my-box")
|
||||
assert gw.load_config() is None
|
||||
|
||||
|
||||
def test_rotate_token_updates_stored_config(gw, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"urllib.request.urlopen",
|
||||
lambda req, timeout: _FakeResp({"box_id": "abc", "box_token": "abc.old", "wg": WG}),
|
||||
)
|
||||
gw.register("https://gw.example.com", "tok", "box")
|
||||
|
||||
def fake_rotate(req, timeout):
|
||||
assert req.headers.get("Authorization") == "Bearer abc.old"
|
||||
assert req.full_url == "https://gw.example.com/v1/boxes/abc/rotate-token"
|
||||
return _FakeResp({"box_token": "abc.new"})
|
||||
|
||||
monkeypatch.setattr("urllib.request.urlopen", fake_rotate)
|
||||
|
||||
new_token = gw.rotate_token()
|
||||
|
||||
assert new_token == "abc.new"
|
||||
assert gw.load_config()["box_token"] == "abc.new"
|
||||
|
||||
|
||||
def test_rotate_token_without_prior_registration_raises(gw):
|
||||
with pytest.raises(gateway.GatewayError, match="not connected"):
|
||||
gw.rotate_token()
|
||||
|
||||
|
||||
def test_deregister_calls_gateway_and_clears_config(gw, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"urllib.request.urlopen",
|
||||
lambda req, timeout: _FakeResp({"box_id": "abc", "box_token": "abc.x", "wg": WG}),
|
||||
)
|
||||
gw.register("https://gw.example.com", "tok", "box")
|
||||
|
||||
calls = []
|
||||
|
||||
def fake_deregister(req, timeout):
|
||||
calls.append(req.full_url)
|
||||
return _FakeResp({"status": "ok"})
|
||||
|
||||
monkeypatch.setattr("urllib.request.urlopen", fake_deregister)
|
||||
|
||||
gw.deregister()
|
||||
|
||||
assert calls == ["https://gw.example.com/v1/boxes/abc/deregister"]
|
||||
assert gw.load_config() is None
|
||||
|
||||
|
||||
def test_deregister_when_never_registered_is_a_noop(gw, monkeypatch):
|
||||
calls = []
|
||||
monkeypatch.setattr("urllib.request.urlopen", lambda req, timeout: calls.append(1))
|
||||
gw.deregister()
|
||||
assert calls == []
|
||||
|
||||
|
||||
def test_publish_route_requires_connection(gw):
|
||||
with pytest.raises(gateway.GatewayError, match="not connected"):
|
||||
gw.publish_route("vaultwarden", "vault.example.com", 8081)
|
||||
|
||||
|
||||
def test_publish_route_posts_to_routes_endpoint(gw, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"urllib.request.urlopen",
|
||||
lambda req, timeout: _FakeResp({"box_id": "abc", "box_token": "abc.x", "wg": WG}),
|
||||
)
|
||||
gw.register("https://gw.example.com", "tok", "box")
|
||||
|
||||
def fake_publish(req, timeout):
|
||||
assert req.full_url == "https://gw.example.com/v1/routes"
|
||||
assert req.headers.get("Authorization") == "Bearer abc.x"
|
||||
assert json.loads(req.data) == {
|
||||
"app_name": "vaultwarden",
|
||||
"subdomain": "vault.example.com",
|
||||
"port": 8081,
|
||||
}
|
||||
return _FakeResp({"route_id": "r1", "public_url": "https://vault.example.com/"})
|
||||
|
||||
monkeypatch.setattr("urllib.request.urlopen", fake_publish)
|
||||
|
||||
result = gw.publish_route("vaultwarden", "vault.example.com", 8081)
|
||||
|
||||
assert result == {"route_id": "r1", "public_url": "https://vault.example.com/"}
|
||||
|
||||
|
||||
def test_unpublish_route_requires_connection(gw):
|
||||
with pytest.raises(gateway.GatewayError, match="not connected"):
|
||||
gw.unpublish_route("r1")
|
||||
|
||||
|
||||
def test_unpublish_route_calls_delete_endpoint(gw, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"urllib.request.urlopen",
|
||||
lambda req, timeout: _FakeResp({"box_id": "abc", "box_token": "abc.x", "wg": WG}),
|
||||
)
|
||||
gw.register("https://gw.example.com", "tok", "box")
|
||||
|
||||
calls = []
|
||||
|
||||
def fake_delete(req, timeout):
|
||||
calls.append((req.full_url, req.get_method(), req.headers.get("Authorization")))
|
||||
return _FakeResp({"status": "ok"})
|
||||
|
||||
monkeypatch.setattr("urllib.request.urlopen", fake_delete)
|
||||
|
||||
gw.unpublish_route("r1")
|
||||
|
||||
assert calls == [("https://gw.example.com/v1/routes/r1", "DELETE", "Bearer abc.x")]
|
||||
|
||||
|
||||
def test_write_and_read_state_round_trip(gw):
|
||||
gw.write_state("registering")
|
||||
s = gw.read_state()
|
||||
assert s["stage"] == "registering"
|
||||
assert "updated_at" in s
|
||||
|
||||
|
||||
def test_read_state_missing_file_returns_empty_dict(gw):
|
||||
assert gw.read_state() == {}
|
||||
|
||||
|
||||
def test_acquire_lock_contention(gw):
|
||||
first = gw.acquire_lock()
|
||||
try:
|
||||
with pytest.raises(gateway.GatewayError, match="already in progress"):
|
||||
gw.acquire_lock()
|
||||
finally:
|
||||
first.close()
|
||||
|
||||
|
||||
def test_run_connect_happy_path(gw, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"urllib.request.urlopen",
|
||||
lambda req, timeout: _FakeResp({"box_id": "abc", "box_token": "abc.x", "wg": WG}),
|
||||
)
|
||||
tunnel_calls = []
|
||||
monkeypatch.setattr(
|
||||
gw.wireguard,
|
||||
"set_tunnel_enabled",
|
||||
lambda enabled, wg=None: tunnel_calls.append((enabled, wg)),
|
||||
)
|
||||
|
||||
gw.run_connect("https://gw.example.com", "tok", "my-box")
|
||||
|
||||
assert tunnel_calls == [(True, WG)]
|
||||
assert gw.read_state()["stage"] == "done"
|
||||
assert gw.load_config()["box_id"] == "abc"
|
||||
|
||||
|
||||
def test_run_connect_registration_failure_writes_error_state(gw, monkeypatch):
|
||||
def raising(req, timeout):
|
||||
raise urllib.error.HTTPError(req.full_url, 401, "invalid registration token", {}, None)
|
||||
|
||||
monkeypatch.setattr("urllib.request.urlopen", raising)
|
||||
|
||||
gw.run_connect("https://gw.example.com", "bad-tok", "my-box")
|
||||
|
||||
state = gw.read_state()
|
||||
assert state["stage"] == "error"
|
||||
assert "401" in state["error"]
|
||||
assert gw.load_config() is None
|
||||
|
||||
|
||||
def test_run_connect_tunnel_failure_writes_error_state(gw, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"urllib.request.urlopen",
|
||||
lambda req, timeout: _FakeResp({"box_id": "abc", "box_token": "abc.x", "wg": WG}),
|
||||
)
|
||||
|
||||
def failing_tunnel(enabled, wg=None):
|
||||
raise gw.wireguard.WireguardError("systemctl failed: bad config")
|
||||
|
||||
monkeypatch.setattr(gw.wireguard, "set_tunnel_enabled", failing_tunnel)
|
||||
|
||||
gw.run_connect("https://gw.example.com", "tok", "my-box")
|
||||
|
||||
state = gw.read_state()
|
||||
assert state["stage"] == "error"
|
||||
assert "bad config" in state["error"]
|
||||
# Registration itself succeeded — config is still saved even though the
|
||||
# tunnel failed to come up, so a retry doesn't need to re-register.
|
||||
assert gw.load_config()["box_id"] == "abc"
|
||||
|
||||
|
||||
def test_run_connect_retry_after_tunnel_failure_reuses_registration(gw, monkeypatch):
|
||||
register_calls = []
|
||||
|
||||
def urlopen(req, timeout):
|
||||
register_calls.append(req.full_url)
|
||||
return _FakeResp({"box_id": "abc", "box_token": "abc.x", "wg": WG})
|
||||
|
||||
monkeypatch.setattr("urllib.request.urlopen", urlopen)
|
||||
|
||||
def failing_tunnel(enabled, wg=None):
|
||||
raise gw.wireguard.WireguardError("systemctl failed: unit missing")
|
||||
|
||||
monkeypatch.setattr(gw.wireguard, "set_tunnel_enabled", failing_tunnel)
|
||||
gw.run_connect("https://gw.example.com", "tok", "my-box")
|
||||
assert gw.read_state()["stage"] == "error"
|
||||
|
||||
tunnel_calls = []
|
||||
monkeypatch.setattr(
|
||||
gw.wireguard,
|
||||
"set_tunnel_enabled",
|
||||
lambda enabled, wg=None: tunnel_calls.append((enabled, wg)),
|
||||
)
|
||||
gw.run_connect("https://gw.example.com/", "tok", "my-box")
|
||||
|
||||
# Registered exactly once; the retry only brought the tunnel up.
|
||||
assert register_calls == ["https://gw.example.com/v1/boxes/register"]
|
||||
assert tunnel_calls == [(True, WG)]
|
||||
assert gw.read_state()["stage"] == "done"
|
||||
assert gw.load_config()["box_id"] == "abc"
|
||||
|
||||
|
||||
def test_run_connect_refuses_a_different_gateway_while_registered(gw, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"urllib.request.urlopen",
|
||||
lambda req, timeout: _FakeResp({"box_id": "abc", "box_token": "abc.x", "wg": WG}),
|
||||
)
|
||||
gw.register("https://gw.example.com", "tok", "box")
|
||||
|
||||
def must_not_call(req, timeout):
|
||||
raise AssertionError("must not register with a second gateway")
|
||||
|
||||
monkeypatch.setattr("urllib.request.urlopen", must_not_call)
|
||||
monkeypatch.setattr(gw.wireguard, "set_tunnel_enabled", lambda enabled, wg=None: None)
|
||||
|
||||
gw.run_connect("https://other.example.com", "tok", "box")
|
||||
|
||||
state = gw.read_state()
|
||||
assert state["stage"] == "error"
|
||||
assert "disconnect first" in state["error"]
|
||||
assert gw.load_config()["gateway_url"] == "https://gw.example.com"
|
||||
|
||||
|
||||
def test_deregister_failure_keeps_local_config_for_retry(gw, monkeypatch):
|
||||
monkeypatch.setattr(
|
||||
"urllib.request.urlopen",
|
||||
lambda req, timeout: _FakeResp({"box_id": "abc", "box_token": "abc.x", "wg": WG}),
|
||||
)
|
||||
gw.register("https://gw.example.com", "tok", "box")
|
||||
|
||||
def raising(req, timeout):
|
||||
raise urllib.error.URLError("connection refused")
|
||||
|
||||
monkeypatch.setattr("urllib.request.urlopen", raising)
|
||||
|
||||
with pytest.raises(gateway.GatewayError):
|
||||
gw.deregister()
|
||||
# Local config must survive so the caller can retry later.
|
||||
assert gw.load_config() is not None
|
||||
|
|
@ -113,7 +113,7 @@ def test_set_force_enable_writes_both_snippets_and_reloads(tmp_path):
|
|||
|
||||
result = https.set_force_https(True, reload_caddy=fake_reload, **p)
|
||||
assert result is True
|
||||
assert p["snippet"].read_text() == https._redirect_snippet_content("testbox")
|
||||
assert p["snippet"].read_text() == https.REDIRECT_CONTENT
|
||||
written = p["https_snippet"].read_text()
|
||||
assert "testbox.local, testbox" in written
|
||||
assert "tls internal" in written
|
||||
|
|
@ -135,7 +135,7 @@ def test_set_force_disable_removes_both_snippets(tmp_path):
|
|||
p = _paths(tmp_path)
|
||||
p["snippet_dir"].mkdir()
|
||||
p["https_snippet_dir"].mkdir()
|
||||
p["snippet"].write_text(https._redirect_snippet_content("testbox"))
|
||||
p["snippet"].write_text(https.REDIRECT_CONTENT)
|
||||
p["https_snippet"].write_text("furtka.local { tls internal }\n")
|
||||
|
||||
result = https.set_force_https(False, reload_caddy=lambda: None, **p)
|
||||
|
|
@ -199,16 +199,10 @@ def test_systemctl_missing_raises_and_rolls_back(tmp_path):
|
|||
assert not p["https_snippet"].exists()
|
||||
|
||||
|
||||
def test_redirect_snippet_only_covers_cert_names_and_is_temporary():
|
||||
# Lock the exact directives. A regression here silently stops the
|
||||
def test_redirect_snippet_content_is_caddy_redir_directive():
|
||||
# Lock the exact directive. A regression here silently stops the
|
||||
# redirect from taking effect even though the file-swap looks fine.
|
||||
# Only the names the tls-internal block has a cert for are redirected
|
||||
# (an IP would hit a failing TLS handshake), and 302 so switching HTTPS
|
||||
# off isn't stuck in browser caches like the old 301 was.
|
||||
assert https._redirect_snippet_content("mybox") == (
|
||||
"@furtka_https_host host mybox.local mybox\n"
|
||||
"redir @furtka_https_host https://{host}{uri} 302\n"
|
||||
)
|
||||
assert https.REDIRECT_CONTENT.strip() == "redir https://{host}{uri} permanent"
|
||||
|
||||
|
||||
def test_https_snippet_content_has_tls_internal_and_routes(tmp_path):
|
||||
|
|
|
|||
|
|
@ -478,35 +478,3 @@ def test_parse_hook_output_furtka_json_rejects_bad_payload(runner):
|
|||
def test_parse_hook_output_furtka_json_invalid_json(runner):
|
||||
with pytest.raises(runner.InstallRunnerError, match="invalid FURTKA_JSON"):
|
||||
runner._parse_hook_output("FURTKA_JSON: {not json}\n")
|
||||
|
||||
|
||||
def test_clear_stale_state_resets_abandoned_install(runner):
|
||||
import time
|
||||
|
||||
runner.write_state("pulling_image", app="fileshare")
|
||||
# Fresh state: could still be the runner starting up — leave it alone.
|
||||
assert runner.clear_stale_state() is False
|
||||
assert runner.read_state()["stage"] == "pulling_image"
|
||||
# Two minutes later with nobody holding the lock: interrupted.
|
||||
assert runner.clear_stale_state(now=time.time() + 120) is True
|
||||
state = runner.read_state()
|
||||
assert state["stage"] == "error"
|
||||
assert state["app"] == "fileshare"
|
||||
assert "interrupted" in state["error"]
|
||||
|
||||
|
||||
def test_clear_stale_state_keeps_running_install(runner):
|
||||
import time
|
||||
|
||||
runner.write_state("pulling_image", app="fileshare")
|
||||
fh = runner.acquire_lock()
|
||||
try:
|
||||
assert runner.clear_stale_state(now=time.time() + 3600) is False
|
||||
assert runner.read_state()["stage"] == "pulling_image"
|
||||
finally:
|
||||
fh.close()
|
||||
|
||||
|
||||
def test_read_state_tolerates_non_object(runner):
|
||||
runner.state_path().write_text("[1, 2]")
|
||||
assert runner.read_state() == {}
|
||||
|
|
|
|||
|
|
@ -462,58 +462,3 @@ def test_install_plan_skips_already_installed(tmp_path, fake_dirs, monkeypatch):
|
|||
)
|
||||
installer.install_plan(plan)
|
||||
assert calls == ["a"]
|
||||
|
||||
|
||||
# --- hardening: app names, validate-before-write, .env quoting --------------
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bad", ["/", ".", "..", "../catalog", "a/b", "", "UPPER"])
|
||||
def test_remove_refuses_non_app_names(fake_dirs, bad):
|
||||
apps, _ = fake_dirs
|
||||
(apps / "fileshare").mkdir()
|
||||
with pytest.raises(installer.InstallError, match="not a valid app name"):
|
||||
installer.remove(bad)
|
||||
assert (apps / "fileshare").exists()
|
||||
assert apps.exists()
|
||||
|
||||
|
||||
def test_update_env_refuses_non_app_names(fake_dirs):
|
||||
with pytest.raises(installer.InstallError, match="not a valid app name"):
|
||||
installer.update_env("..", {"X": "1"})
|
||||
|
||||
|
||||
def test_rejected_path_setting_never_reaches_env(tmp_path, fake_dirs):
|
||||
media = tmp_path / "media"
|
||||
media.mkdir()
|
||||
src = _write_app_source(tmp_path, "jellyfin", PATH_MANIFEST)
|
||||
installer.install_from(src, settings={"MEDIA_PATH": str(media)})
|
||||
env = apps_dir() / "jellyfin" / ".env"
|
||||
with pytest.raises(installer.InstallError, match="system path"):
|
||||
installer.update_env("jellyfin", {"MEDIA_PATH": "/etc"})
|
||||
assert "/etc" not in env.read_text()
|
||||
assert f"MEDIA_PATH={media}" in env.read_text()
|
||||
|
||||
|
||||
def test_newline_in_setting_is_rejected(tmp_path, fake_dirs):
|
||||
m = dict(VALID_MANIFEST, settings=[{"name": "PW", "label": "PW", "type": "password"}])
|
||||
src = _write_app_source(tmp_path, "fileshare", m)
|
||||
with pytest.raises(installer.InstallError, match="line breaks"):
|
||||
installer.install_from(src, settings={"PW": "abc\nCOMPOSE_PROJECT_NAME=x"})
|
||||
env = apps_dir() / "fileshare" / ".env"
|
||||
assert not env.exists() or "COMPOSE_PROJECT_NAME" not in env.read_text()
|
||||
|
||||
|
||||
def test_dollar_values_are_single_quoted_and_round_trip(tmp_path):
|
||||
env = tmp_path / ".env"
|
||||
values = {"PW": "pa$word", "B": "has space", "C": "it's $5", "D": "plain"}
|
||||
installer.write_env(env, values)
|
||||
text = env.read_text()
|
||||
assert "PW='pa$word'" in text
|
||||
assert "D=plain" in text
|
||||
assert installer.read_env_values(env) == values
|
||||
|
||||
|
||||
def test_manifest_name_must_be_app_name(tmp_path, fake_dirs):
|
||||
src = _write_app_source(tmp_path, "evil", dict(VALID_MANIFEST, name="../evil"))
|
||||
with pytest.raises(installer.InstallError, match="lowercase"):
|
||||
installer.install_from(src)
|
||||
|
|
|
|||
|
|
@ -292,57 +292,3 @@ def test_requires_rejects_empty_hook_string(tmp_path):
|
|||
path = _write_app(tmp_path, "z2m", payload)
|
||||
with pytest.raises(ManifestError, match="non-empty string"):
|
||||
load_manifest(path)
|
||||
|
||||
|
||||
def test_internet_optional_defaults_non_viable(tmp_path):
|
||||
path = _write_app(tmp_path, "fileshare", VALID_MANIFEST)
|
||||
m = load_manifest(path)
|
||||
assert m.internet.viable is False
|
||||
assert m.internet.port is None
|
||||
|
||||
|
||||
def test_internet_viable_parsed(tmp_path):
|
||||
payload = dict(VALID_MANIFEST, internet={"viable": True, "port": 445})
|
||||
path = _write_app(tmp_path, "fileshare", payload)
|
||||
m = load_manifest(path)
|
||||
assert m.internet.viable is True
|
||||
assert m.internet.port == 445
|
||||
|
||||
|
||||
def test_internet_non_viable_ignores_port(tmp_path):
|
||||
# A non-viable app doesn't need a port at all — and if one is present
|
||||
# anyway (e.g. a stale field left behind), it's simply ignored rather
|
||||
# than validated, since it has no effect either way.
|
||||
payload = dict(VALID_MANIFEST, internet={"viable": False, "port": 9999})
|
||||
path = _write_app(tmp_path, "fileshare", payload)
|
||||
m = load_manifest(path)
|
||||
assert m.internet.viable is False
|
||||
assert m.internet.port is None
|
||||
|
||||
|
||||
def test_internet_viable_requires_port(tmp_path):
|
||||
payload = dict(VALID_MANIFEST, internet={"viable": True})
|
||||
path = _write_app(tmp_path, "fileshare", payload)
|
||||
with pytest.raises(ManifestError, match="internet.port must be an integer"):
|
||||
load_manifest(path)
|
||||
|
||||
|
||||
def test_internet_port_must_be_declared(tmp_path):
|
||||
payload = dict(VALID_MANIFEST, internet={"viable": True, "port": 9999})
|
||||
path = _write_app(tmp_path, "fileshare", payload)
|
||||
with pytest.raises(ManifestError, match="must be one of the declared ports"):
|
||||
load_manifest(path)
|
||||
|
||||
|
||||
def test_internet_non_object_rejected(tmp_path):
|
||||
payload = dict(VALID_MANIFEST, internet=True)
|
||||
path = _write_app(tmp_path, "fileshare", payload)
|
||||
with pytest.raises(ManifestError, match="internet must be an object"):
|
||||
load_manifest(path)
|
||||
|
||||
|
||||
def test_internet_port_must_be_int_not_bool(tmp_path):
|
||||
payload = dict(VALID_MANIFEST, internet={"viable": True, "port": True})
|
||||
path = _write_app(tmp_path, "fileshare", payload)
|
||||
with pytest.raises(ManifestError, match="internet.port must be an integer"):
|
||||
load_manifest(path)
|
||||
|
|
|
|||
|
|
@ -463,107 +463,3 @@ def test_check_update_raises_when_no_releases_published(updater, monkeypatch):
|
|||
monkeypatch.setattr(updater, "_forgejo_api", lambda path: [])
|
||||
with pytest.raises(updater.UpdateError, match="no releases"):
|
||||
updater.check_update()
|
||||
|
||||
|
||||
def test_apply_update_rolls_back_on_oserror_and_restores_caddyfile(tmp_path, updater, monkeypatch):
|
||||
"""A non-UpdateError after the symlink flip (disk full writing the
|
||||
Caddyfile) used to leave the new version live with no rollback."""
|
||||
versions = updater.versions_dir()
|
||||
versions.mkdir(parents=True)
|
||||
(versions / "26.0-alpha").mkdir()
|
||||
current = updater.current_symlink()
|
||||
current.symlink_to(versions / "26.0-alpha")
|
||||
caddyfile = tmp_path / "etc_caddy" / "Caddyfile"
|
||||
caddyfile.parent.mkdir()
|
||||
caddyfile.write_text("# old routes\n")
|
||||
|
||||
tar = tmp_path / "t.tar.gz"
|
||||
_make_tarball(tar, "26.1-alpha")
|
||||
|
||||
def full_disk(_source):
|
||||
caddyfile.write_text("# half-written new routes\n")
|
||||
raise OSError(28, "No space left on device")
|
||||
|
||||
monkeypatch.setattr(updater, "_refresh_caddyfile", full_disk)
|
||||
monkeypatch.setattr(updater, "_run", lambda cmd: None)
|
||||
import subprocess
|
||||
|
||||
monkeypatch.setattr(subprocess, "run", lambda *a, **kw: None)
|
||||
|
||||
with pytest.raises(updater.UpdateError, match="rolled back"):
|
||||
updater.apply_update(tar, "26.1-alpha")
|
||||
assert current.resolve() == (versions / "26.0-alpha").resolve()
|
||||
assert caddyfile.read_text() == "# old routes\n"
|
||||
assert updater.read_state()["stage"] == "rolled_back"
|
||||
|
||||
|
||||
def test_swap_symlink_replaces_existing_link(tmp_path, updater):
|
||||
a, b = tmp_path / "a", tmp_path / "b"
|
||||
a.mkdir()
|
||||
b.mkdir()
|
||||
link = tmp_path / "current"
|
||||
link.symlink_to(a)
|
||||
updater._swap_symlink(link, b)
|
||||
assert link.resolve() == b.resolve()
|
||||
assert not (tmp_path / "current.new").exists()
|
||||
|
||||
|
||||
def test_run_update_writes_error_stage_on_download_failure(updater, monkeypatch):
|
||||
class _Check:
|
||||
update_available = True
|
||||
latest = "26.1-alpha"
|
||||
current = "26.0-alpha"
|
||||
tarball_url = "http://x/t.tar.gz"
|
||||
sha256_url = "http://x/t.sha256"
|
||||
|
||||
def fake_check():
|
||||
return _Check()
|
||||
|
||||
monkeypatch.setattr(updater, "check_update", fake_check)
|
||||
|
||||
def boom(url, dest):
|
||||
raise OSError(28, "No space left on device")
|
||||
|
||||
monkeypatch.setattr(updater, "_download", boom)
|
||||
with pytest.raises(updater.UpdateError, match="No space left"):
|
||||
updater.run_update()
|
||||
state = updater.read_state()
|
||||
assert state["stage"] == "error"
|
||||
assert "No space left" in state["reason"]
|
||||
|
||||
|
||||
def test_health_check_survives_read_timeout(updater, monkeypatch):
|
||||
def slow(url, timeout):
|
||||
raise TimeoutError("timed out")
|
||||
|
||||
monkeypatch.setattr("urllib.request.urlopen", slow)
|
||||
monkeypatch.setattr(updater.time, "sleep", lambda _s: None)
|
||||
assert updater._health_check("http://127.0.0.1:7000/api/apps", deadline_s=0.05) is False
|
||||
|
||||
|
||||
def test_refresh_caddyfile_migrates_legacy_301_redirect(updater, tmp_path):
|
||||
from furtka import https
|
||||
|
||||
snippet_dir = tmp_path / "etc_caddy" / "furtka.d"
|
||||
snippet_dir.mkdir(parents=True)
|
||||
(tmp_path / "etc_caddy" / "furtka-https.d").mkdir()
|
||||
(tmp_path / "etc_caddy" / "furtka-https.d" / "https.caddyfile").write_text("x\n")
|
||||
redirect = snippet_dir / "redirect.caddyfile"
|
||||
redirect.write_text(https.LEGACY_REDIRECT_CONTENT)
|
||||
src = tmp_path / "Caddyfile.src"
|
||||
src.write_text("# caddy\n")
|
||||
updater._refresh_caddyfile(src)
|
||||
assert redirect.read_text() == https._redirect_snippet_content("testbox")
|
||||
|
||||
|
||||
def test_refresh_caddyfile_leaves_custom_redirect_alone(updater, tmp_path):
|
||||
snippet_dir = tmp_path / "etc_caddy" / "furtka.d"
|
||||
snippet_dir.mkdir(parents=True)
|
||||
(tmp_path / "etc_caddy" / "furtka-https.d").mkdir()
|
||||
(tmp_path / "etc_caddy" / "furtka-https.d" / "https.caddyfile").write_text("x\n")
|
||||
redirect = snippet_dir / "redirect.caddyfile"
|
||||
redirect.write_text("# hand-edited\n")
|
||||
src = tmp_path / "Caddyfile.src"
|
||||
src.write_text("# caddy\n")
|
||||
updater._refresh_caddyfile(src)
|
||||
assert redirect.read_text() == "# hand-edited\n"
|
||||
|
|
|
|||
|
|
@ -1,204 +0,0 @@
|
|||
"""Tests for furtka.wireguard — tunnel-config write/remove + systemctl toggle.
|
||||
|
||||
Same shape as test_https.py: stub the systemctl call so we assert the conf
|
||||
file is written/removed and that a reload failure rolls the conf file back
|
||||
to its pre-call state.
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from furtka import wireguard
|
||||
|
||||
WG = {
|
||||
"private_key": "cHJpdmF0ZS1rZXk=",
|
||||
"address": "10.8.0.2/24",
|
||||
"server_public_key": "c2VydmVyLXB1YmxpYy1rZXk=",
|
||||
"endpoint": "gateway.example.com:51820",
|
||||
"allowed_ips": "10.8.0.0/24",
|
||||
}
|
||||
|
||||
|
||||
def test_conf_content_shape():
|
||||
content = wireguard._conf_content(WG)
|
||||
assert "[Interface]" in content
|
||||
assert "PrivateKey = cHJpdmF0ZS1rZXk=" in content
|
||||
assert "Address = 10.8.0.2/24" in content
|
||||
assert "[Peer]" in content
|
||||
assert "PublicKey = c2VydmVyLXB1YmxpYy1rZXk=" in content
|
||||
assert "Endpoint = gateway.example.com:51820" in content
|
||||
assert "AllowedIPs = 10.8.0.0/24" in content
|
||||
assert "PersistentKeepalive = 25" in content
|
||||
|
||||
|
||||
def test_conf_content_omits_preshared_key_when_absent():
|
||||
# WG has no "preshared_key" key at all — the v14-gateway shape.
|
||||
content = wireguard._conf_content(WG)
|
||||
assert "PresharedKey" not in content
|
||||
|
||||
|
||||
def test_conf_content_includes_preshared_key_when_present():
|
||||
# v15-gateway shape (see furtka-gateway's wgeasy_v15.py) — the server
|
||||
# enforces this even if the client's own conf omits it, so dropping it
|
||||
# here would break the handshake silently.
|
||||
wg = {**WG, "preshared_key": "cHJlc2hhcmVkLWtleQ=="}
|
||||
content = wireguard._conf_content(wg)
|
||||
assert "PresharedKey = cHJlc2hhcmVkLWtleQ==" in content
|
||||
# Must sit between PublicKey and Endpoint, inside [Peer].
|
||||
peer_section = content.split("[Peer]\n", 1)[1]
|
||||
assert (
|
||||
peer_section.index("PublicKey")
|
||||
< peer_section.index("PresharedKey")
|
||||
< peer_section.index("Endpoint")
|
||||
)
|
||||
|
||||
|
||||
def test_enable_requires_wg_config(tmp_path):
|
||||
with pytest.raises(ValueError, match="wg config is required"):
|
||||
wireguard.set_tunnel_enabled(True, conf_path=tmp_path / "furtka-gw.conf")
|
||||
|
||||
|
||||
def test_enable_surfaces_clean_error_on_unreadable_conf_dir(tmp_path, monkeypatch):
|
||||
# Simulated rather than via a 0o000 directory: CI runs as root, which
|
||||
# ignores directory permissions.
|
||||
def denied(self, *a, **kw):
|
||||
raise PermissionError(13, "Permission denied", str(self))
|
||||
|
||||
monkeypatch.setattr(Path, "mkdir", denied)
|
||||
|
||||
def must_not_reload(action):
|
||||
raise AssertionError("systemctl must not run when the conf can't be written")
|
||||
|
||||
conf_path = tmp_path / "restricted" / "furtka-gw.conf"
|
||||
with pytest.raises(wireguard.WireguardError, match="could not access"):
|
||||
wireguard.set_tunnel_enabled(True, wg=WG, conf_path=conf_path, reload=must_not_reload)
|
||||
|
||||
|
||||
def test_default_conf_path_uses_env_override(monkeypatch, tmp_path):
|
||||
monkeypatch.setenv("FURTKA_WIREGUARD_CONF", str(tmp_path / "custom.conf"))
|
||||
assert wireguard.default_conf_path() == tmp_path / "custom.conf"
|
||||
|
||||
|
||||
def test_default_conf_path_default_when_unset(monkeypatch):
|
||||
monkeypatch.delenv("FURTKA_WIREGUARD_CONF", raising=False)
|
||||
assert wireguard.default_conf_path() == wireguard.DEFAULT_CONF_PATH
|
||||
|
||||
|
||||
def test_enable_writes_conf_and_calls_reload(tmp_path):
|
||||
conf_path = tmp_path / "furtka-gw.conf"
|
||||
calls = []
|
||||
|
||||
def fake_reload(action):
|
||||
calls.append(action)
|
||||
|
||||
result = wireguard.set_tunnel_enabled(True, wg=WG, conf_path=conf_path, reload=fake_reload)
|
||||
|
||||
assert result is True
|
||||
assert calls == ["enable"]
|
||||
content = conf_path.read_text()
|
||||
assert "PrivateKey = cHJpdmF0ZS1rZXk=" in content
|
||||
assert oct(conf_path.stat().st_mode)[-3:] == "600"
|
||||
|
||||
|
||||
def test_disable_removes_conf_and_calls_reload(tmp_path):
|
||||
conf_path = tmp_path / "furtka-gw.conf"
|
||||
conf_path.write_text(wireguard._conf_content(WG))
|
||||
calls = []
|
||||
|
||||
result = wireguard.set_tunnel_enabled(
|
||||
False, conf_path=conf_path, reload=lambda action: calls.append(action)
|
||||
)
|
||||
|
||||
assert result is False
|
||||
assert calls == ["disable"]
|
||||
assert not conf_path.exists()
|
||||
|
||||
|
||||
def test_disable_is_idempotent_when_already_off(tmp_path):
|
||||
conf_path = tmp_path / "furtka-gw.conf"
|
||||
result = wireguard.set_tunnel_enabled(False, conf_path=conf_path, reload=lambda action: None)
|
||||
assert result is False
|
||||
assert not conf_path.exists()
|
||||
|
||||
|
||||
def test_reload_failure_rolls_back_enable(tmp_path):
|
||||
conf_path = tmp_path / "furtka-gw.conf"
|
||||
|
||||
def failing_reload(action):
|
||||
raise subprocess.CalledProcessError(1, ["systemctl"], stderr="bad config")
|
||||
|
||||
with pytest.raises(wireguard.WireguardError, match="systemctl failed: bad config"):
|
||||
wireguard.set_tunnel_enabled(True, wg=WG, conf_path=conf_path, reload=failing_reload)
|
||||
# No conf existed before this call, so none should exist after rollback.
|
||||
assert not conf_path.exists()
|
||||
|
||||
|
||||
def test_reload_failure_rolls_back_disable(tmp_path):
|
||||
conf_path = tmp_path / "furtka-gw.conf"
|
||||
original = wireguard._conf_content(WG)
|
||||
conf_path.write_text(original)
|
||||
|
||||
def failing_reload(action):
|
||||
raise subprocess.CalledProcessError(1, ["systemctl"], stderr="bad config")
|
||||
|
||||
with pytest.raises(wireguard.WireguardError):
|
||||
wireguard.set_tunnel_enabled(False, conf_path=conf_path, reload=failing_reload)
|
||||
assert conf_path.read_text() == original
|
||||
|
||||
|
||||
def test_systemctl_missing_raises_and_rolls_back(tmp_path):
|
||||
conf_path = tmp_path / "furtka-gw.conf"
|
||||
|
||||
def missing_systemctl(action):
|
||||
raise FileNotFoundError(2, "No such file", "systemctl")
|
||||
|
||||
with pytest.raises(wireguard.WireguardError, match="systemctl not available"):
|
||||
wireguard.set_tunnel_enabled(True, wg=WG, conf_path=conf_path, reload=missing_systemctl)
|
||||
assert not conf_path.exists()
|
||||
|
||||
|
||||
def test_status_not_configured(tmp_path):
|
||||
s = wireguard.status(conf_path=tmp_path / "does-not-exist.conf")
|
||||
assert s == {"configured": False, "latest_handshake": None}
|
||||
|
||||
|
||||
def test_status_survives_unreadable_conf_path(tmp_path, monkeypatch):
|
||||
"""Regression: an inaccessible parent directory raises PermissionError
|
||||
even for a path that doesn't exist yet — confirmed by actually hitting
|
||||
this against a real box's /etc/wireguard/ as a non-root user, which
|
||||
crashed the whole /api/gateway/status request with a raw traceback.
|
||||
A read-only status check must degrade to "not configured", never 500.
|
||||
"""
|
||||
|
||||
# Simulated rather than via a 0o000 directory: CI runs as root, which
|
||||
# ignores directory permissions.
|
||||
def denied(self):
|
||||
raise PermissionError(13, "Permission denied", str(self))
|
||||
|
||||
monkeypatch.setattr(Path, "is_file", denied)
|
||||
|
||||
s = wireguard.status(conf_path=tmp_path / "restricted" / "furtka-gw.conf")
|
||||
assert s == {"configured": False, "latest_handshake": None}
|
||||
|
||||
|
||||
def test_status_configured_reports_handshake(tmp_path):
|
||||
conf_path = tmp_path / "furtka-gw.conf"
|
||||
conf_path.write_text(wireguard._conf_content(WG))
|
||||
|
||||
s = wireguard.status(conf_path=conf_path, wg_show=lambda: "1234567890")
|
||||
|
||||
assert s == {"configured": True, "latest_handshake": "1234567890"}
|
||||
|
||||
|
||||
def test_status_configured_but_wg_tools_missing(tmp_path):
|
||||
conf_path = tmp_path / "furtka-gw.conf"
|
||||
conf_path.write_text(wireguard._conf_content(WG))
|
||||
|
||||
def missing_wg():
|
||||
raise FileNotFoundError(2, "No such file", "wg")
|
||||
|
||||
s = wireguard.status(conf_path=conf_path, wg_show=missing_wg)
|
||||
|
||||
assert s == {"configured": True, "latest_handshake": None}
|
||||
|
|
@ -8,8 +8,6 @@ import os
|
|||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import traceback
|
||||
from datetime import UTC
|
||||
from pathlib import Path
|
||||
|
||||
|
|
@ -78,35 +76,6 @@ settings = {
|
|||
HOSTNAME_RE = re.compile(r"^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$")
|
||||
USERNAME_RE = re.compile(r"^[a-z_][a-z0-9_-]{0,31}$")
|
||||
|
||||
# Accounts that already exist on the installed system (base + the packages
|
||||
# we install). Picking one of these either fails user creation mid-install
|
||||
# (root) or makes the admin collide with a service account (caddy, docker…).
|
||||
RESERVED_USERNAMES = frozenset(
|
||||
{
|
||||
"root",
|
||||
"bin",
|
||||
"daemon",
|
||||
"mail",
|
||||
"ftp",
|
||||
"http",
|
||||
"nobody",
|
||||
"dbus",
|
||||
"git",
|
||||
"uuidd",
|
||||
"avahi",
|
||||
"caddy",
|
||||
"docker",
|
||||
"polkitd",
|
||||
"rtkit",
|
||||
"systemd-coredump",
|
||||
"systemd-journal-remote",
|
||||
"systemd-network",
|
||||
"systemd-oom",
|
||||
"systemd-resolve",
|
||||
"systemd-timesync",
|
||||
}
|
||||
)
|
||||
|
||||
# Ordered phase markers for the install progress bar. Each tuple is
|
||||
# (substring to search for in the archinstall log, progress percent when
|
||||
# reached, user-facing label). Pick the furthest phase whose marker is
|
||||
|
|
@ -139,13 +108,7 @@ PROGRESS_ERROR_HINTS = [
|
|||
]
|
||||
|
||||
|
||||
def parse_install_progress(log, exit_code=None):
|
||||
"""Progress dict from the install log.
|
||||
|
||||
`exit_code` is archinstall's return code once the process has ended
|
||||
(None while running or unknown). A non-zero exit is an error even when
|
||||
the log has no Traceback — OOM kills and signals print nothing.
|
||||
"""
|
||||
def parse_install_progress(log):
|
||||
percent = 2
|
||||
phase = "Starting up…"
|
||||
for marker, pct, label in PROGRESS_PHASES:
|
||||
|
|
@ -155,7 +118,7 @@ def parse_install_progress(log, exit_code=None):
|
|||
|
||||
if percent >= 100:
|
||||
status = "done"
|
||||
elif any(m in log for m in PROGRESS_ERROR_MARKERS) or exit_code not in (None, 0):
|
||||
elif any(m in log for m in PROGRESS_ERROR_MARKERS):
|
||||
status = "error"
|
||||
phase = "Installation failed — open Show details below"
|
||||
for marker, hint in PROGRESS_ERROR_HINTS:
|
||||
|
|
@ -164,39 +127,24 @@ def parse_install_progress(log, exit_code=None):
|
|||
break
|
||||
else:
|
||||
status = "running"
|
||||
if percent == 18:
|
||||
# archinstall waits for NTP time sync with no timeout. Only a hint:
|
||||
# it usually clears on its own within a minute.
|
||||
phase = (
|
||||
"Syncing time and packages — if this takes more than a few "
|
||||
"minutes, check that the network cable is plugged in"
|
||||
)
|
||||
|
||||
return {"percent": percent, "phase": phase, "status": status}
|
||||
|
||||
|
||||
def validate_step1(form):
|
||||
errors = []
|
||||
# Lowercase instead of rejecting "Furtka" / "Daniel" — Linux needs
|
||||
# lowercase, people type names the way they write them.
|
||||
values = {
|
||||
"hostname": form.get("hostname", "").strip().lower(),
|
||||
"username": form.get("username", "").strip().lower(),
|
||||
"hostname": form.get("hostname", "").strip(),
|
||||
"username": form.get("username", "").strip(),
|
||||
"password": form.get("password", ""),
|
||||
"language": form.get("language", ""),
|
||||
}
|
||||
password2 = form.get("password2", "")
|
||||
|
||||
if not HOSTNAME_RE.match(values["hostname"]):
|
||||
errors.append(
|
||||
"The server name can only use letters, digits and hyphens (no spaces, max 63)."
|
||||
)
|
||||
errors.append("Hostname must be lowercase letters, digits, hyphens (max 63 chars).")
|
||||
if not USERNAME_RE.match(values["username"]):
|
||||
errors.append(
|
||||
"The username must start with a letter and can only use letters, digits, - and _."
|
||||
)
|
||||
elif values["username"] in RESERVED_USERNAMES:
|
||||
errors.append(f"“{values['username']}” is reserved by the system — please pick another.")
|
||||
errors.append("Username must start with a letter or underscore, lowercase only.")
|
||||
if len(values["password"]) < 8:
|
||||
errors.append("Password must be at least 8 characters.")
|
||||
if values["password"] != password2:
|
||||
|
|
@ -490,16 +438,6 @@ def _post_install_commands(hostname, admin_username, admin_password):
|
|||
# Initial status.json so Caddy doesn't 404 before furtka-status fires.
|
||||
_write_file_cmd("/var/lib/furtka/status.json", _read_asset("www/status.json")),
|
||||
nss_sed,
|
||||
# The installed system inherits the live ISO's networkd config
|
||||
# (DHCP on every Ethernet + Wi-Fi link) but not its wait-online
|
||||
# drop-in, so a board with a second, unplugged NIC stalled boot for
|
||||
# up to 2 minutes before network-online.target. Any one link is
|
||||
# enough for a home server.
|
||||
_write_file_cmd(
|
||||
"/etc/systemd/system/systemd-networkd-wait-online.service.d/any-interface.conf",
|
||||
"[Service]\nExecStart=\n"
|
||||
"ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --any\n",
|
||||
),
|
||||
# Resource manager bootstrap: extract tarball → versions/<ver>/,
|
||||
# symlink current, install wrapper, systemctl-link unit files.
|
||||
*_resource_manager_commands(),
|
||||
|
|
@ -515,20 +453,10 @@ def _post_install_commands(hostname, admin_username, admin_password):
|
|||
]
|
||||
|
||||
|
||||
def _detect_bootloader(efi_dir=Path("/sys/firmware/efi")):
|
||||
def _detect_bootloader():
|
||||
# systemd-boot is UEFI-only; on BIOS/legacy it trips HardwareIncompatibilityError
|
||||
# inside archinstall. /sys/firmware/efi exists iff we were booted via UEFI.
|
||||
if not efi_dir.exists():
|
||||
return "Grub"
|
||||
# 64-bit CPU behind 32-bit UEFI (Atom Bay Trail / Cherry Trail mini-PCs
|
||||
# and tablets): Arch ships no ia32 systemd-boot, and archinstall's GRUB
|
||||
# path hardcodes --target=x86_64-efi. Its Limine path installs both
|
||||
# BOOTIA32.EFI and BOOTX64.EFI and picks the entry by firmware bitness.
|
||||
try:
|
||||
bitness = (efi_dir / "fw_platform_size").read_text().strip()
|
||||
except OSError:
|
||||
bitness = "64"
|
||||
return "Limine" if bitness == "32" else "Systemd-boot"
|
||||
return "Systemd-boot" if Path("/sys/firmware/efi").exists() else "Grub"
|
||||
|
||||
|
||||
def build_archinstall_config(s):
|
||||
|
|
@ -559,9 +487,6 @@ def build_archinstall_config(s):
|
|||
"caddy",
|
||||
"avahi",
|
||||
"nss-mdns",
|
||||
# furtka-gateway tunnel — furtka/wireguard.py drives
|
||||
# wg-quick@furtka-gw.service, which ships in this package.
|
||||
"wireguard-tools",
|
||||
# Resource manager runtime — pure-stdlib Python, no pip needed
|
||||
# because we expose the package via PYTHONPATH in /usr/local/bin/furtka.
|
||||
"python",
|
||||
|
|
@ -645,16 +570,6 @@ def spawn_archinstall(config_path, creds_path, log_path):
|
|||
)
|
||||
|
||||
|
||||
@app.before_request
|
||||
def _stay_on_progress_while_installing():
|
||||
# While archinstall runs, the wizard pages would let a second browser
|
||||
# (or Back) edit settings that no longer apply — show the progress.
|
||||
running = _install_proc is not None and _install_proc.poll() is None
|
||||
if running and request.endpoint in ("install_step_1", "install_step_2", "install_overview"):
|
||||
return redirect(url_for("install_log_view"))
|
||||
return None
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def home():
|
||||
return redirect(url_for("install_step_1"))
|
||||
|
|
@ -679,89 +594,32 @@ def install_step_1():
|
|||
)
|
||||
|
||||
|
||||
# Size/type of the disk picked in step 2, for the confirm page (re-probing
|
||||
# would re-run smartctl on every disk).
|
||||
_selected_drive: dict = {}
|
||||
|
||||
|
||||
@app.route("/install/step2", methods=["GET", "POST"])
|
||||
def install_step_2():
|
||||
drives = list_scored_devices()
|
||||
error = ""
|
||||
if request.method == "POST":
|
||||
boot_drive = request.form.get("boot_drive", "").strip()
|
||||
# Only accept a disk we actually offered — never a free-form path.
|
||||
picked = next((d for d in drives if d["name"] == boot_drive and d["usable"]), None)
|
||||
if picked:
|
||||
if boot_drive:
|
||||
settings["boot_drive"] = boot_drive
|
||||
_selected_drive.clear()
|
||||
_selected_drive.update(picked)
|
||||
return redirect(url_for("install_overview"))
|
||||
error = "Please pick one of the disks below."
|
||||
return render_template(
|
||||
"install/step2.html",
|
||||
drives=drives,
|
||||
drives=list_scored_devices(),
|
||||
selected=settings.get("boot_drive", ""),
|
||||
error=error,
|
||||
)
|
||||
|
||||
|
||||
@app.route("/install/overview")
|
||||
def install_overview():
|
||||
if not settings["boot_drive"] or not settings["username"]:
|
||||
return redirect(url_for("install_step_1"))
|
||||
masked = {**settings, "password": "•" * 8 if settings["password"] else ""}
|
||||
drive = _selected_drive if _selected_drive.get("name") == settings["boot_drive"] else None
|
||||
language = LANGUAGES.get(settings["language"], {}).get("label", settings["language"])
|
||||
return render_template(
|
||||
"install/overview.html", settings=masked, drive=drive, language_label=language
|
||||
)
|
||||
|
||||
|
||||
# The running archinstall process, so a second click (double-submit, Back +
|
||||
# Install again, a second browser) can't start another install on the same
|
||||
# disk, and so the progress page can see an exit without a Traceback.
|
||||
_install_proc = None
|
||||
_install_lock = threading.Lock()
|
||||
|
||||
|
||||
def _install_exit_code():
|
||||
return None if _install_proc is None else _install_proc.poll()
|
||||
|
||||
|
||||
def _read_install_log():
|
||||
log = INSTALL_LOG.read_text(errors="replace") if INSTALL_LOG.exists() else ""
|
||||
code = _install_exit_code()
|
||||
if code not in (None, 0):
|
||||
log += f"\n\narchinstall stopped unexpectedly (exit code {code}).\n"
|
||||
return log, code
|
||||
return render_template("install/overview.html", settings=masked)
|
||||
|
||||
|
||||
@app.route("/install/run", methods=["POST"])
|
||||
def install_run():
|
||||
if not settings["boot_drive"] or not settings["username"] or not settings["password"]:
|
||||
return redirect(url_for("install_step_1"))
|
||||
with _install_lock:
|
||||
if _install_proc is not None and _install_proc.poll() is None:
|
||||
return redirect(url_for("install_log_view"))
|
||||
return _start_install()
|
||||
|
||||
|
||||
def _start_install():
|
||||
global _install_proc
|
||||
STATE_DIR.mkdir(parents=True, exist_ok=True)
|
||||
config_path, creds_path = write_install_files(settings, STATE_DIR)
|
||||
INSTALL_LOG.write_bytes(b"")
|
||||
try:
|
||||
config_path, creds_path = write_install_files(settings, STATE_DIR)
|
||||
except Exception:
|
||||
# archinstall's disk probe raises on disks it can't parse (broken
|
||||
# GPT, odd card readers). Put the traceback where the progress page
|
||||
# finds it instead of a bare "Internal Server Error".
|
||||
with INSTALL_LOG.open("a") as fh:
|
||||
fh.write(
|
||||
f"Could not read the layout of {settings['boot_drive']}.\n" + traceback.format_exc()
|
||||
)
|
||||
return redirect(url_for("install_log_view"))
|
||||
if os.environ.get("FURTKA_DRY_RUN") == "1":
|
||||
INSTALL_LOG.write_text(
|
||||
f"DRY RUN: would exec archinstall --config {config_path} "
|
||||
|
|
@ -773,33 +631,33 @@ def _start_install():
|
|||
# while those hold the partitions open (first hardware bench, 26.19).
|
||||
with INSTALL_LOG.open("a") as fh:
|
||||
fh.write("\n".join(release_disk(settings["boot_drive"])) + "\n\n")
|
||||
_install_proc = spawn_archinstall(config_path, creds_path, INSTALL_LOG)
|
||||
spawn_archinstall(config_path, creds_path, INSTALL_LOG)
|
||||
return redirect(url_for("install_log_view"))
|
||||
|
||||
|
||||
@app.route("/install/log")
|
||||
def install_log_view():
|
||||
log, code = _read_install_log()
|
||||
log = INSTALL_LOG.read_text() if INSTALL_LOG.exists() else ""
|
||||
return render_template(
|
||||
"install/log.html",
|
||||
log=log,
|
||||
progress=parse_install_progress(log, code),
|
||||
progress=parse_install_progress(log),
|
||||
hostname=settings["hostname"],
|
||||
)
|
||||
|
||||
|
||||
@app.route("/install/log.json")
|
||||
def install_log_json():
|
||||
log, code = _read_install_log()
|
||||
return jsonify(log=log, progress=parse_install_progress(log, code))
|
||||
log = INSTALL_LOG.read_text() if INSTALL_LOG.exists() else ""
|
||||
return jsonify(log=log, progress=parse_install_progress(log))
|
||||
|
||||
|
||||
@app.route("/install/reboot", methods=["POST"])
|
||||
def install_reboot():
|
||||
# Only allow rebooting once the install has actually finished — we don't
|
||||
# want a panicked click during install to reboot mid-pacstrap.
|
||||
log, code = _read_install_log()
|
||||
if parse_install_progress(log, code)["status"] != "done":
|
||||
log = INSTALL_LOG.read_text() if INSTALL_LOG.exists() else ""
|
||||
if parse_install_progress(log)["status"] != "done":
|
||||
return redirect(url_for("install_log_view"))
|
||||
# Delay reboot a few seconds so the browser can finish fetching CSS / assets
|
||||
# for the rebooting page before the Flask server (and network) go away.
|
||||
|
|
|
|||
|
|
@ -1,90 +1,56 @@
|
|||
import json
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
# Smallest disk we offer as an install target. The base system plus Docker
|
||||
# needs ~6 GB; the rest is headroom for images and app data.
|
||||
MIN_DISK_GB = 16
|
||||
|
||||
# MBR (what archinstall lays out on BIOS boxes) can't address past 2 TiB.
|
||||
MBR_LIMIT_GB = 2048
|
||||
|
||||
# Block devices lsblk reports as TYPE=disk that are never install targets:
|
||||
# compressed RAM swap and the eMMC hardware boot / RPMB areas (4 MB, usually
|
||||
# read-only) that show up next to mmcblk0 on every eMMC mini-PC and laptop.
|
||||
_PSEUDO_DISK_RE = re.compile(r"^(zram\d+|mmcblk\d+boot\d+|mmcblk\d+rpmb)$")
|
||||
|
||||
_SUBPROCESS_TIMEOUT = 15
|
||||
|
||||
|
||||
def _run(cmd, timeout=_SUBPROCESS_TIMEOUT):
|
||||
"""subprocess.run with a timeout; None when the tool is missing or hangs."""
|
||||
try:
|
||||
return subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
|
||||
except (FileNotFoundError, subprocess.TimeoutExpired):
|
||||
return None
|
||||
|
||||
|
||||
def _parent_disk(device):
|
||||
result = _run(["lsblk", "-no", "PKNAME", device])
|
||||
if result is None or result.returncode != 0:
|
||||
return None
|
||||
lines = [line.strip() for line in result.stdout.splitlines() if line.strip()]
|
||||
return lines[0] if lines else None
|
||||
|
||||
|
||||
def _boot_device_from_cmdline(cmdline):
|
||||
"""Resolve the boot partition from archiso's kernel args, or None."""
|
||||
args = dict(arg.split("=", 1) for arg in cmdline.split() if "=" in arg)
|
||||
if args.get("archisodevice", "").startswith("/dev/"):
|
||||
return args["archisodevice"]
|
||||
if args.get("archisosearchuuid"):
|
||||
cmd = ["blkid", "-U", args["archisosearchuuid"]]
|
||||
elif args.get("archisolabel"):
|
||||
cmd = ["blkid", "-L", args["archisolabel"]]
|
||||
else:
|
||||
return None
|
||||
result = _run(cmd)
|
||||
if result is None or result.returncode != 0:
|
||||
return None
|
||||
return result.stdout.strip() or None
|
||||
|
||||
|
||||
def _boot_disk_name():
|
||||
"""Return the parent disk name of the live-ISO boot media (e.g. "sdb"), or None.
|
||||
|
||||
On bare metal booted from USB this is the stick we booted from — we want
|
||||
to filter it out so the user can't accidentally pick it as the install
|
||||
target. Primary source is the mount behind /run/archiso/bootmnt; when
|
||||
that's gone (copytoram unmounts it) fall back to the UUID/label archiso
|
||||
put on the kernel command line.
|
||||
On a normal box `/run/archiso/bootmnt` does not exist and we return None,
|
||||
leaving the device list untouched. On bare metal booted from USB this is
|
||||
the stick we booted from — we want to filter it out so the user can't
|
||||
accidentally pick it as the install target.
|
||||
"""
|
||||
partition = None
|
||||
result = _run(["findmnt", "-no", "SOURCE", "/run/archiso/bootmnt"])
|
||||
if result is not None and result.returncode == 0:
|
||||
partition = result.stdout.strip() or None
|
||||
if partition is None:
|
||||
try:
|
||||
partition = _boot_device_from_cmdline(Path("/proc/cmdline").read_text())
|
||||
except OSError:
|
||||
partition = None
|
||||
if partition is None:
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["findmnt", "-no", "SOURCE", "/run/archiso/bootmnt"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
# A stick written with dd has the ISO filesystem on the whole disk, where
|
||||
# PKNAME is empty — the device itself is then the disk.
|
||||
return _parent_disk(partition) or Path(partition).name
|
||||
if result.returncode != 0:
|
||||
return None
|
||||
partition = result.stdout.strip()
|
||||
if not partition:
|
||||
return None
|
||||
try:
|
||||
parent = subprocess.run(
|
||||
["lsblk", "-no", "PKNAME", partition],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
except FileNotFoundError:
|
||||
return None
|
||||
if parent.returncode != 0:
|
||||
return None
|
||||
name = parent.stdout.strip().splitlines()[0] if parent.stdout.strip() else ""
|
||||
return name or None
|
||||
|
||||
|
||||
def _smart_status(device):
|
||||
result = _run(["smartctl", "-H", device])
|
||||
if result is None:
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["smartctl", "-H", device],
|
||||
capture_output=True,
|
||||
)
|
||||
output = result.stdout.decode()
|
||||
if "PASSED" in output:
|
||||
return "passed"
|
||||
elif "FAILED" in output:
|
||||
return "failed"
|
||||
return "unknown"
|
||||
except Exception as e:
|
||||
print(f"Error checking SMART status for {device}: {e}")
|
||||
return "unknown"
|
||||
if "PASSED" in result.stdout:
|
||||
return "passed"
|
||||
if "FAILED" in result.stdout:
|
||||
return "failed"
|
||||
return "unknown"
|
||||
|
||||
|
||||
_HEALTH_SCORE = {"passed": 10, "failed": 0, "unknown": 5}
|
||||
|
|
@ -94,33 +60,40 @@ _HEALTH_LABEL = {
|
|||
"unknown": "Status unknown",
|
||||
}
|
||||
|
||||
_TYPE_SCORE = {"NVMe": 15, "SSD": 10, "eMMC": 8, "HDD": 5, "USB": 0}
|
||||
|
||||
|
||||
def get_drive_health(device):
|
||||
return _HEALTH_SCORE[_smart_status(device)]
|
||||
|
||||
|
||||
def classify_drive(name, tran="", rota=None, removable=False):
|
||||
"""Human label for a disk: NVMe, SSD, eMMC, HDD or USB.
|
||||
def get_drive_type_score(device):
|
||||
name = device.lower()
|
||||
if "nvme" in name:
|
||||
return 15
|
||||
if "ssd" in name:
|
||||
return 10
|
||||
return 5
|
||||
|
||||
Uses lsblk's transport and rotational flags — the kernel name alone
|
||||
can't tell an SSD from a spinning disk (both are sdX).
|
||||
"""
|
||||
tran = (tran or "").lower()
|
||||
if tran == "usb" or (removable and not name.startswith("mmcblk")):
|
||||
return "USB"
|
||||
if tran == "nvme" or name.startswith("nvme"):
|
||||
|
||||
def get_drive_type_label(device):
|
||||
name = device.lower()
|
||||
if "nvme" in name:
|
||||
return "NVMe"
|
||||
if tran == "mmc" or name.startswith("mmcblk"):
|
||||
return "eMMC"
|
||||
if rota is False:
|
||||
if "ssd" in name:
|
||||
return "SSD"
|
||||
return "HDD"
|
||||
|
||||
|
||||
def get_drive_type_score(type_label):
|
||||
return _TYPE_SCORE.get(type_label, 5)
|
||||
def parse_size_gb(size_str):
|
||||
size_str = size_str.strip().upper().replace(",", ".")
|
||||
if not size_str:
|
||||
return None
|
||||
if size_str.endswith("T"):
|
||||
return float(size_str[:-1]) * 1024
|
||||
if size_str.endswith("G"):
|
||||
return float(size_str[:-1])
|
||||
if size_str.endswith("M"):
|
||||
return float(size_str[:-1]) / 1024
|
||||
return None
|
||||
|
||||
|
||||
def get_size_score(size_gb):
|
||||
|
|
@ -133,98 +106,61 @@ def get_size_score(size_gb):
|
|||
return 10
|
||||
|
||||
|
||||
def format_size(size_bytes):
|
||||
gb = size_bytes / 1024**3
|
||||
if gb >= 1024:
|
||||
return f"{gb / 1024:.1f} TB".replace(".0 ", " ")
|
||||
if gb >= 10:
|
||||
return f"{gb:.0f} GB"
|
||||
return f"{gb:.1f} GB"
|
||||
def score_device(device, size_gb):
|
||||
return get_drive_type_score(device) + get_drive_health(device) + get_size_score(size_gb)
|
||||
|
||||
|
||||
def _flag(value):
|
||||
# util-linux ≥2.37 emits JSON booleans; older builds emit "0"/"1".
|
||||
if isinstance(value, bool):
|
||||
return value
|
||||
return str(value).strip() in ("1", "true")
|
||||
def parse_lsblk_output(output, boot_disk=None):
|
||||
"""Parse `lsblk -dn -o NAME,SIZE,TYPE` output into scored device dicts.
|
||||
|
||||
|
||||
def parse_lsblk_json(output, boot_disk=None, uefi=True):
|
||||
"""Parse `lsblk -J -d -b -o NAME,SIZE,TYPE,RO,RM,TRAN,ROTA` into device dicts.
|
||||
|
||||
Keeps only real, writable, non-empty TYPE=disk devices (drops the live
|
||||
ISO's loop/rom, zram, eMMC boot areas, empty card-reader slots) and the
|
||||
USB stick we booted from. Disks too small to install on stay in the list
|
||||
with `usable=False` and a reason so the user sees why they're greyed out.
|
||||
Sorted best-first; unusable disks last.
|
||||
Keeps only TYPE=disk so the live ISO's own squashfs (loop) and the boot
|
||||
CD-ROM (rom) don't show up as install targets. If `boot_disk` is given,
|
||||
that disk is also dropped — it's the USB stick the live ISO booted from
|
||||
on bare metal, where it appears as TYPE=disk and would otherwise be a
|
||||
valid-looking install target.
|
||||
"""
|
||||
try:
|
||||
entries = json.loads(output or "{}").get("blockdevices", [])
|
||||
except json.JSONDecodeError:
|
||||
return []
|
||||
devices = []
|
||||
for e in entries:
|
||||
name = e.get("name") or ""
|
||||
if e.get("type") != "disk" or not name:
|
||||
for line in output.strip().split("\n"):
|
||||
if not line:
|
||||
continue
|
||||
if _PSEUDO_DISK_RE.match(name) or (boot_disk and name == boot_disk):
|
||||
parts = line.split()
|
||||
if len(parts) < 3:
|
||||
continue
|
||||
try:
|
||||
size_bytes = int(e.get("size") or 0)
|
||||
except (TypeError, ValueError):
|
||||
size_bytes = 0
|
||||
if size_bytes <= 0 or _flag(e.get("ro", False)):
|
||||
name, size, dev_type = parts[0], parts[1], parts[2]
|
||||
if dev_type != "disk":
|
||||
continue
|
||||
if boot_disk and name == boot_disk:
|
||||
continue
|
||||
size_gb = size_bytes / 1024**3
|
||||
type_label = classify_drive(
|
||||
name,
|
||||
tran=e.get("tran") or "",
|
||||
rota=_flag(e.get("rota")) if e.get("rota") is not None else None,
|
||||
removable=_flag(e.get("rm", False)),
|
||||
)
|
||||
device = f"/dev/{name}"
|
||||
usable = size_gb >= MIN_DISK_GB
|
||||
status = _smart_status(device) if usable else "unknown"
|
||||
warning = ""
|
||||
if not uefi and size_gb > MBR_LIMIT_GB:
|
||||
warning = (
|
||||
"This computer starts in legacy (BIOS) mode, which can only use "
|
||||
"the first 2 TB of this disk. Switch the firmware to UEFI to use all of it."
|
||||
)
|
||||
elif type_label == "USB":
|
||||
warning = (
|
||||
"This is a USB drive — it works, but an internal disk is faster and more reliable."
|
||||
)
|
||||
size_gb = parse_size_gb(size)
|
||||
status = _smart_status(device)
|
||||
score = get_drive_type_score(device) + _HEALTH_SCORE[status] + get_size_score(size_gb)
|
||||
devices.append(
|
||||
{
|
||||
"name": device,
|
||||
"size": format_size(size_bytes),
|
||||
"size_gb": size_gb,
|
||||
"type_label": type_label,
|
||||
"size": size,
|
||||
"type_label": get_drive_type_label(device),
|
||||
"health_label": _HEALTH_LABEL[status],
|
||||
"score": get_drive_type_score(type_label)
|
||||
+ _HEALTH_SCORE[status]
|
||||
+ get_size_score(size_gb),
|
||||
"usable": usable,
|
||||
"reason": "" if usable else f"Too small — Furtka needs at least {MIN_DISK_GB} GB",
|
||||
"warning": warning,
|
||||
"score": score,
|
||||
}
|
||||
)
|
||||
devices.sort(key=lambda d: (d["usable"], d["score"]), reverse=True)
|
||||
devices.sort(key=lambda d: d["score"], reverse=True)
|
||||
return devices
|
||||
|
||||
|
||||
def list_scored_devices():
|
||||
"""Return [{name, size, score, usable, ...}, ...] for all physical disks, best first."""
|
||||
result = _run(["lsblk", "-J", "-d", "-b", "-o", "NAME,SIZE,TYPE,RO,RM,TRAN,ROTA"])
|
||||
if result is None or result.returncode != 0:
|
||||
print(f"Error listing devices: {result.stderr if result else 'lsblk unavailable'}")
|
||||
"""Return [{name, size, score}, ...] for all physical disks, highest score first."""
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["lsblk", "-dn", "-o", "NAME,SIZE,TYPE"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error listing devices: {e}")
|
||||
return []
|
||||
return parse_lsblk_json(
|
||||
result.stdout,
|
||||
boot_disk=_boot_disk_name(),
|
||||
uefi=Path("/sys/firmware/efi").exists(),
|
||||
)
|
||||
return parse_lsblk_output(result.stdout, boot_disk=_boot_disk_name())
|
||||
|
||||
|
||||
def main():
|
||||
|
|
@ -232,11 +168,11 @@ def main():
|
|||
if not devices:
|
||||
print("No storage devices found.")
|
||||
return
|
||||
print(f"\n{'Device':<20} {'Size':<10} {'Type':<6} {'Score'}")
|
||||
print("-" * 46)
|
||||
print(f"\n{'Device':<20} {'Size':<10} {'Score'}")
|
||||
print("-" * 40)
|
||||
for d in devices:
|
||||
note = "" if d["usable"] else f" ({d['reason']})"
|
||||
print(f"{d['name']:<20} {d['size']:<10} {d['type_label']:<6} {d['score']}{note}")
|
||||
print(f"{d['name']:<20} {d['size']:<10} {d['score']}")
|
||||
print(f"\nBest drive for boot: {devices[0]['name']} (score {devices[0]['score']})")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><style>svg{color:#c03a28}@media (prefers-color-scheme:dark){svg{color:#ff6b56}}</style><path fill="currentColor" fill-rule="evenodd" d="M5 60V27a27 27 0 0 1 54 0v33Z M19.5 60V26A10 10 0 0 1 29.5 16H46v10H32a2.5 2.5 0 0 0-2.5 2.5V32H46v10H29.5v18Z"/></svg>
|
||||
|
Before Width: | Height: | Size: 316 B |
|
|
@ -190,17 +190,9 @@ select:focus {
|
|||
background: var(--bg-card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
flex-wrap: wrap;
|
||||
cursor: pointer;
|
||||
transition: border-color 120ms, background 120ms;
|
||||
}
|
||||
.drive-disabled { cursor: not-allowed; opacity: 0.6; }
|
||||
.drive-disabled:hover { border-color: var(--border); }
|
||||
.drive .drive-note {
|
||||
flex-basis: 100%;
|
||||
font-size: 0.82rem;
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.drive:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
|
||||
.drive input[type="radio"] {
|
||||
accent-color: var(--accent);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{% block title %}Furtka Installer{% endblock %}</title>
|
||||
<link rel="icon" type="image/svg+xml" href="{{ url_for('static', filename='favicon.svg') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
{% block head_extra %}{% endblock %}
|
||||
</head>
|
||||
|
|
@ -12,8 +11,12 @@
|
|||
<header class="site-header">
|
||||
<div class="container">
|
||||
<a href="{{ url_for('install_step_1') }}" class="site-title" aria-label="Furtka Installer — restart">
|
||||
<svg class="gate-mark" width="24" height="24" viewBox="0 0 64 64" aria-hidden="true">
|
||||
<path fill="currentColor" fill-rule="evenodd" d="M5 60V27a27 27 0 0 1 54 0v33Z M19.5 60V26A10 10 0 0 1 29.5 16H46v10H32a2.5 2.5 0 0 0-2.5 2.5V32H46v10H29.5v18Z"/>
|
||||
<svg class="gate-mark" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<path d="M4 20 V12 A9 9 0 0 1 20 12 V20"/>
|
||||
<line x1="12" y1="5" x2="12" y2="20"/>
|
||||
<line x1="3" y1="20" x2="21" y2="20"/>
|
||||
<line x1="15" y1="12" x2="15" y2="14.5"/>
|
||||
</svg>
|
||||
<span class="wordmark">Furtka<span class="sep">·</span>Installer</span>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -18,23 +18,10 @@
|
|||
</h1>
|
||||
<p class="lede" id="install-lede">
|
||||
{% if progress.status == "done" %}Installation finished. Two more steps and Furtka is running from its own disk.
|
||||
{% elif progress.status == "error" %}{{ progress.phase }}.
|
||||
{% else %}This takes 5–20 minutes, depending on your internet speed. Don't power off the machine — it's fine to close this page and come back.{% endif %}
|
||||
{% elif progress.status == "error" %}Something went wrong. Open the details below and share them so we can help.
|
||||
{% else %}This takes a few minutes. Don't close this page or power off the machine.{% endif %}
|
||||
</p>
|
||||
|
||||
{% if progress.status == "error" %}
|
||||
<p>Your settings are kept, so you can simply try again. If it fails the same way twice,
|
||||
open <em>Show details</em> below — the last lines of the log say what went wrong.</p>
|
||||
<form method="post" action="{{ url_for('install_run') }}"
|
||||
onsubmit="this.querySelector('button').disabled = true;">
|
||||
<div class="actions">
|
||||
<button type="submit" class="btn btn-primary">Try again</button>
|
||||
<a href="{{ url_for('install_step_2') }}" class="btn btn-link">Pick a different disk</a>
|
||||
<a href="{{ url_for('install_step_1') }}" class="btn btn-link">Change settings</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% if progress.status == "done" %}
|
||||
{# The USB-stick step has to be read *before* the click: the machine reboots
|
||||
3 s after it, and most BIOSes boot the stick before the disk — so the
|
||||
|
|
@ -56,7 +43,7 @@ open <em>Show details</em> below — the last lines of the log say what went wro
|
|||
<div class="progress" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="{{ progress.percent }}">
|
||||
<div id="progress-bar" class="progress-bar{% if progress.status == 'error' %} progress-bar-error{% endif %}{% if progress.status == 'done' %} progress-bar-done{% endif %}" style="width: {{ progress.percent }}%;"></div>
|
||||
</div>
|
||||
<p class="progress-phase" aria-live="polite"><span id="progress-phase">{{ progress.phase }}</span> · <span id="progress-percent">{{ progress.percent }}</span>%</p>
|
||||
<p class="progress-phase"><span id="progress-phase">{{ progress.phase }}</span> · <span id="progress-percent">{{ progress.percent }}</span>%</p>
|
||||
|
||||
<details class="log-details">
|
||||
<summary>Show details</summary>
|
||||
|
|
@ -72,7 +59,17 @@ open <em>Show details</em> below — the last lines of the log say what went wro
|
|||
var phaseEl = document.getElementById('progress-phase');
|
||||
var percentEl = document.getElementById('progress-percent');
|
||||
var logEl = document.getElementById('install-log');
|
||||
var failures = 0;
|
||||
var headingEl = document.getElementById('install-heading');
|
||||
var ledeEl = document.getElementById('install-lede');
|
||||
|
||||
var HEADINGS = {
|
||||
done: 'Furtka is ready',
|
||||
error: 'Installation hit a snag',
|
||||
};
|
||||
var LEDES = {
|
||||
done: 'Installation finished. Remove the USB / eject the installer image, then reboot.',
|
||||
error: 'Something went wrong. Open the details below and share them so we can help.',
|
||||
};
|
||||
|
||||
function tick() {
|
||||
fetch('{{ url_for("install_log_json") }}', { cache: 'no-store' })
|
||||
|
|
@ -80,7 +77,6 @@ open <em>Show details</em> below — the last lines of the log say what went wro
|
|||
.then(function (data) {
|
||||
var p = data.progress;
|
||||
bar.style.width = p.percent + '%';
|
||||
bar.parentNode.setAttribute('aria-valuenow', p.percent);
|
||||
phaseEl.textContent = p.phase;
|
||||
percentEl.textContent = p.percent;
|
||||
if (logEl.textContent !== data.log) {
|
||||
|
|
@ -88,23 +84,21 @@ open <em>Show details</em> below — the last lines of the log say what went wro
|
|||
logEl.textContent = data.log || '(waiting for install to start)';
|
||||
if (atBottom) logEl.scrollTop = logEl.scrollHeight;
|
||||
}
|
||||
if (p.status === 'done' || p.status === 'error') {
|
||||
// Reload so the server-rendered Done / error state (with
|
||||
// its Reboot or Try-again buttons) replaces the
|
||||
// running-state markup.
|
||||
if (p.status === 'done') {
|
||||
// Reload so the server-rendered Done state (with the
|
||||
// Reboot button) replaces the running-state markup.
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
failures = 0;
|
||||
setTimeout(tick, 3000);
|
||||
})
|
||||
.catch(function () {
|
||||
failures += 1;
|
||||
if (failures >= 2) {
|
||||
phaseEl.textContent = 'Lost connection to the installer — retrying…';
|
||||
if (p.status === 'error') {
|
||||
bar.classList.add('progress-bar-error');
|
||||
headingEl.textContent = HEADINGS.error;
|
||||
ledeEl.textContent = LEDES.error;
|
||||
return;
|
||||
}
|
||||
setTimeout(tick, 3000);
|
||||
});
|
||||
})
|
||||
.catch(function () { setTimeout(tick, 3000); });
|
||||
}
|
||||
setTimeout(tick, 3000);
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -5,27 +5,27 @@
|
|||
|
||||
{% block content %}
|
||||
<h1>Confirm install</h1>
|
||||
<p class="lede">Check the settings below. Continuing will <strong>erase <code>{{ settings.boot_drive }}</code></strong> and install Furtka on it.</p>
|
||||
<p class="lede">Review the settings below. Continuing will <strong>wipe <code>{{ settings.boot_drive }}</code></strong> and install Furtka.</p>
|
||||
|
||||
<div class="alert alert-warn" role="alert">
|
||||
Everything currently on this disk will be deleted and can't be recovered.
|
||||
<div class="alert alert-warn">
|
||||
This is destructive. All existing data on the selected boot drive will be lost.
|
||||
</div>
|
||||
|
||||
<div class="summary">
|
||||
<table>
|
||||
<tr><td>Server name</td><td>{{ settings.hostname }} <span class="hint">(http://{{ settings.hostname }}.local)</span></td></tr>
|
||||
<tr><td>Username</td><td>{{ settings.username }}</td></tr>
|
||||
<tr><td>Password</td><td>{{ settings.password }}</td></tr>
|
||||
<tr><td>Language</td><td>{{ language_label }}</td></tr>
|
||||
<tr><td>Disk</td><td>{{ settings.boot_drive }}{% if drive %} — {{ drive.size }} {{ drive.type_label }}{% endif %}</td></tr>
|
||||
{% for k, v in settings.items() %}
|
||||
<tr>
|
||||
<td>{{ k.replace('_', ' ') }}</td>
|
||||
<td>{{ v }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<form method="post" action="{{ url_for('install_run') }}"
|
||||
onsubmit="this.querySelector('button').disabled = true; this.querySelector('button').textContent = 'Starting…';">
|
||||
<form method="post" action="{{ url_for('install_run') }}">
|
||||
<div class="actions">
|
||||
<button type="submit" class="btn btn-danger">Erase disk and install</button>
|
||||
<a href="{{ url_for('install_step_2') }}" class="btn btn-link">← Back</a>
|
||||
<button type="submit" class="btn btn-danger">Install — wipe drive and proceed</button>
|
||||
<a href="{{ url_for('install_step_1') }}" class="btn btn-link">← Start over</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,5 @@
|
|||
<p class="muted">If the installer does come back anyway, your BIOS is set to boot from USB before the disk. Press the one-time boot menu key at startup (often <kbd>F11</kbd>, <kbd>F12</kbd>, or <kbd>Esc</kbd> — it flashes briefly on screen) and pick the internal disk, or change the boot order in BIOS settings.</p>
|
||||
<p>When the machine comes back up (~1 minute), open Furtka in your browser:</p>
|
||||
<p><a href="http://{{ hostname }}.local" class="btn btn-primary">http://{{ hostname }}.local</a></p>
|
||||
<p class="muted">If that address doesn't open (some Android phones and older Windows PCs can't look up <code>.local</code> names),
|
||||
use the IP address instead: it's shown on the machine's screen, or look for a device called
|
||||
<strong>{{ hostname }}</strong> in your router's list of connected devices. The address may differ from the one the installer used.</p>
|
||||
<p class="muted">If that doesn't resolve, your network may not support mDNS — use the IP address shown on the machine's console instead.</p>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@
|
|||
{% block step_indicator %}<span class="step-indicator">Step 1 of 3</span>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Name & account</h1>
|
||||
<h1>Account & hostname</h1>
|
||||
<p class="lede">Set the server name and your administrator account.</p>
|
||||
|
||||
{% if errors %}
|
||||
<div class="alert alert-error" role="alert">
|
||||
<div class="alert alert-error">
|
||||
<strong>Please fix the following:</strong>
|
||||
<ul>
|
||||
{% for e in errors %}<li>{{ e }}</li>{% endfor %}
|
||||
|
|
@ -18,19 +18,19 @@
|
|||
|
||||
<form method="post" action="{{ url_for('install_step_1') }}">
|
||||
<div class="field">
|
||||
<label for="hostname">Server name</label>
|
||||
<input type="text" id="hostname" name="hostname" required value="{{ values.hostname }}" autocomplete="off" autocapitalize="off" spellcheck="false" aria-describedby="hostname-hint" />
|
||||
<span class="hint" id="hostname-hint">You'll open your server at <strong>http://<span id="hostname-preview">{{ values.hostname or "furtka" }}</span>.local</strong>. Letters, numbers and dashes only.</span>
|
||||
<label for="hostname">Hostname</label>
|
||||
<input type="text" id="hostname" name="hostname" required value="{{ values.hostname }}" autocomplete="off" />
|
||||
<span class="hint">The name your server shows up as on your home network. Lowercase letters, numbers, and dashes only.</span>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="username">Admin username</label>
|
||||
<input type="text" id="username" name="username" required value="{{ values.username }}" autocomplete="username" autocapitalize="off" spellcheck="false" aria-describedby="username-hint" />
|
||||
<span class="hint" id="username-hint">Your login name on the server. You'll use this to sign in after installation.</span>
|
||||
<input type="text" id="username" name="username" required value="{{ values.username }}" autocomplete="username" />
|
||||
<span class="hint">Your login name on the server. You'll use this to sign in after installation.</span>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="password">Password</label>
|
||||
<input type="password" id="password" name="password" required minlength="8" autocomplete="new-password" aria-describedby="password-hint" />
|
||||
<span class="hint" id="password-hint">At least 8 characters. This one password is used for the web login and for the server itself (SSH / console), so pick a good one.</span>
|
||||
<input type="password" id="password" name="password" required autocomplete="new-password" />
|
||||
<span class="hint">At least 8 characters.</span>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="password2">Confirm password</label>
|
||||
|
|
@ -38,25 +38,15 @@
|
|||
</div>
|
||||
<div class="field">
|
||||
<label for="language">Language</label>
|
||||
<select id="language" name="language" aria-describedby="language-hint">
|
||||
<select id="language" name="language">
|
||||
{% for code, lang in languages.items() %}
|
||||
<option value="{{ code }}" {% if code == values.language %}selected{% endif %}>{{ lang.label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<span class="hint" id="language-hint">Language and keyboard layout of the installed server. The Furtka pages themselves are in English for now.</span>
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<button type="submit" class="btn btn-primary">Next — pick a disk</button>
|
||||
<button type="submit" class="btn btn-primary">Next — pick boot drive</button>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
(function () {
|
||||
var input = document.getElementById('hostname');
|
||||
var preview = document.getElementById('hostname-preview');
|
||||
input.addEventListener('input', function () {
|
||||
preview.textContent = input.value.trim().toLowerCase() || 'furtka';
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,53 +1,39 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Step 2 — Disk · Furtka Installer{% endblock %}
|
||||
{% block title %}Step 2 — Boot drive · Furtka Installer{% endblock %}
|
||||
{% block step_indicator %}<span class="step-indicator">Step 2 of 3</span>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Pick a disk</h1>
|
||||
<p class="lede">Choose the disk Furtka will be installed on. <strong>Everything on it will be erased.</strong> We pre-select the one that looks fastest and healthiest.</p>
|
||||
<h1>Boot drive</h1>
|
||||
<p class="lede">Pick the disk Furtka will install onto. We pre-select the drive that looks fastest and healthiest.</p>
|
||||
|
||||
{% set usable = drives | selectattr("usable") | list %}
|
||||
{% set pick = selected if (selected and usable | selectattr("name", "equalto", selected) | list) else (usable[0].name if usable else "") %}
|
||||
|
||||
{% if error %}
|
||||
<div class="alert alert-error" role="alert">{{ error }}</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not usable %}
|
||||
<div class="alert alert-error" role="alert">
|
||||
{% if drives %}
|
||||
None of the disks in this computer is big enough for Furtka (it needs at least 16 GB).
|
||||
{% else %}
|
||||
No disk found to install onto. Check that the disk is connected, and in the BIOS/UEFI settings
|
||||
that the SATA mode is "AHCI" rather than "RAID" or "Intel RST" — Linux can't see disks in RAID mode.
|
||||
{% endif %}
|
||||
{% if not drives %}
|
||||
<div class="alert alert-error">
|
||||
No physical disks detected. The live ISO can't see any install targets — check your BIOS / SATA controller.
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form method="post" action="{{ url_for('install_step_2') }}">
|
||||
<div class="drive-list">
|
||||
{% for d in drives %}
|
||||
<label class="drive{% if not d.usable %} drive-disabled{% endif %}">
|
||||
<label class="drive">
|
||||
<input type="radio" name="boot_drive" value="{{ d.name }}"
|
||||
{% if not d.usable %}disabled{% elif d.name == pick %}checked{% endif %} />
|
||||
{% if (selected and d.name == selected) or (not selected and loop.first) %}checked{% endif %} />
|
||||
<span class="name">{{ d.name }}</span>
|
||||
{% if not selected and d.usable and loop.first %}
|
||||
{% if not selected and loop.first %}
|
||||
<span class="badge-recommended">Recommended</span>
|
||||
{% endif %}
|
||||
<span class="meta">
|
||||
<span class="chip">{{ d.size }}</span>
|
||||
<span class="chip">{{ d.type_label }}</span>
|
||||
{% if d.usable %}<span class="chip">{{ d.health_label }}</span>{% endif %}
|
||||
<span class="chip">{{ d.health_label }}</span>
|
||||
</span>
|
||||
{% if d.reason %}<span class="drive-note">{{ d.reason }}</span>{% endif %}
|
||||
{% if d.warning %}<span class="drive-note">{{ d.warning }}</span>{% endif %}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div class="actions">
|
||||
<button type="submit" class="btn btn-primary" {% if not usable %}disabled{% endif %}>Next — review</button>
|
||||
<button type="submit" class="btn btn-primary" {% if not drives %}disabled{% endif %}>Next — review</button>
|
||||
<a href="{{ url_for('install_step_1') }}" class="btn btn-link">← Back</a>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -42,15 +42,6 @@ This rsyncs `website/` to `/srv/furtka-site/` on the VM over SSH and runs
|
|||
`hugo --minify` into `/var/www/furtka.org`. Same end state as the CI path,
|
||||
just with an SSH hop.
|
||||
|
||||
### Poll counter
|
||||
|
||||
`/api/poll/` is a tiny stdlib Python service (`ops/poll/pollsvc.py`,
|
||||
SQLite, systemd `DynamicUser`) behind nginx on `127.0.0.1:8090`. Install or
|
||||
update it on the VM with `sudo ops/poll/setup-poll.sh`; the nginx location
|
||||
and rate limit come from `ops/nginx/` via `setup-vm.sh`. Devices are told
|
||||
apart by a salted hash of IP + user agent — no cookie — and a repeat vote
|
||||
from the same device changes the choice instead of adding one.
|
||||
|
||||
### First-time VM setup
|
||||
|
||||
Only needed once, when provisioning a fresh forge-runner VM:
|
||||
|
|
@ -67,18 +58,11 @@ hugo.toml Hugo config (multilingual: en default, de)
|
|||
content/ Markdown pages
|
||||
_index.md Home (EN)
|
||||
_index.de.md Home (DE)
|
||||
logo.md / .de.md Logo poll (/logo/, /de/logo/) — layout `poll`, votes via /api/poll/
|
||||
layouts/ Custom inline theme — no external theme or framework
|
||||
_default/ baseof, single, list
|
||||
partials/ head, header, footer, gate SVG, lang switcher, mark-m / mark-r (poll)
|
||||
poll/single.html Logo poll page; strings come from the content front matter
|
||||
partials/ head, header, footer, gate SVG, lang switcher
|
||||
index.html Home-only layout with editorial hero
|
||||
assets/css/main.css Stylesheet (fingerprinted + minified on build)
|
||||
assets/js/poll.js Vote script for /logo/ — plain fetch, no cookies, no storage
|
||||
data/logo/{m,r}.json Generated: mark SVGs, lockups, 16 px icons, console banner per proposal
|
||||
static/img/logo/ Generated: tiles, splash and social card per proposal
|
||||
tools/logo-assets.py Generator for the two lines above (cairosvg + Pillow + fontTools);
|
||||
run on the dev box, commit the output. Font: tools/FONT-PROVENANCE.md
|
||||
static/favicon.svg Gate mark in crimson
|
||||
deploy.sh Manual rsync + remote Hugo build (over SSH, for off-CI pushes)
|
||||
deploy-ci.sh Local rsync + Hugo build — runs on forge-runner-01 from CI
|
||||
|
|
|
|||
|
|
@ -356,214 +356,6 @@ main.container {
|
|||
.cta--primary { animation: none; }
|
||||
}
|
||||
|
||||
.cta-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.9rem 1.1rem;
|
||||
}
|
||||
.cta--ghost {
|
||||
color: var(--fg);
|
||||
border: 1px solid var(--border);
|
||||
background: var(--card-bg);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
.cta--ghost:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
/* ── How it works (home) ─────────────────────────────────── */
|
||||
|
||||
.how-steps {
|
||||
list-style: none;
|
||||
counter-reset: how;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
|
||||
gap: 1rem;
|
||||
}
|
||||
.how-step {
|
||||
counter-increment: how;
|
||||
position: relative;
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--card-border);
|
||||
border-radius: 1rem;
|
||||
padding: 1.4rem 1.5rem 1.5rem;
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
.how-step::before {
|
||||
content: counter(how, decimal-leading-zero);
|
||||
display: block;
|
||||
font-family: var(--font-mono);
|
||||
font-weight: 600;
|
||||
font-size: 2.4rem;
|
||||
line-height: 1;
|
||||
letter-spacing: -0.04em;
|
||||
margin-bottom: 0.9rem;
|
||||
background-image: linear-gradient(135deg, var(--accent), var(--fg-muted));
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
.how-step h3 { margin: 0 0 0.35rem; font-size: 1.15rem; letter-spacing: -0.01em; }
|
||||
.how-step p { margin: 0; color: var(--fg-muted); font-size: 0.98rem; line-height: 1.5; }
|
||||
.how-step strong { color: var(--fg); font-weight: 600; }
|
||||
|
||||
/* ── Download band (home, before the closer) ─────────────── */
|
||||
|
||||
.dl-band {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1.25rem 2rem;
|
||||
margin-block: 4.5rem 0;
|
||||
padding: 2rem;
|
||||
border-radius: 1.25rem;
|
||||
border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
|
||||
background:
|
||||
radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
|
||||
var(--card-bg);
|
||||
-webkit-backdrop-filter: blur(10px);
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
.dl-band h2 { margin: 0 0 0.3rem; font-size: 1.5rem; letter-spacing: -0.02em; }
|
||||
.dl-band p { margin: 0; color: var(--fg-muted); max-width: 26rem; }
|
||||
|
||||
/* ── Download page ───────────────────────────────────────── */
|
||||
|
||||
.dl-hero { padding-block: 1rem 1rem; }
|
||||
.dl-hero h1 {
|
||||
font-size: clamp(2.4rem, 7vw, 4rem);
|
||||
line-height: 1;
|
||||
letter-spacing: -0.035em;
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
.dl-hero .lede {
|
||||
font-size: clamp(1.05rem, 1.6vw, 1.2rem);
|
||||
color: var(--fg-muted);
|
||||
max-width: 36rem;
|
||||
margin: 0 0 2rem;
|
||||
}
|
||||
.dl-card {
|
||||
padding: 1.75rem;
|
||||
border-radius: 1.25rem;
|
||||
border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
|
||||
background:
|
||||
radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
|
||||
var(--card-bg);
|
||||
}
|
||||
.dl-card .cta svg { flex: none; }
|
||||
.dl-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem 2rem;
|
||||
margin: 1.5rem 0 0;
|
||||
}
|
||||
.dl-meta div { min-width: 0; }
|
||||
.dl-meta dt {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.14em;
|
||||
text-transform: uppercase;
|
||||
color: var(--fg-muted);
|
||||
}
|
||||
.dl-meta dd { margin: 0.15rem 0 0; overflow-wrap: anywhere; }
|
||||
.mono { font-family: var(--font-mono); font-size: 0.92em; }
|
||||
.dl-host { margin: 1.25rem 0 0; font-size: 0.85rem; color: var(--fg-muted); }
|
||||
.dl-alpha {
|
||||
margin: 1.5rem 0 0;
|
||||
padding: 0.9rem 1.1rem;
|
||||
border-left: 3px solid var(--accent);
|
||||
background: var(--bg-subtle);
|
||||
border-radius: 0 0.6rem 0.6rem 0;
|
||||
font-size: 0.95rem;
|
||||
max-width: 40rem;
|
||||
}
|
||||
.dl-section { margin-top: 3.5rem; }
|
||||
.dl-needs { margin: 0; padding-left: 1.2rem; max-width: 40rem; }
|
||||
.dl-needs li { margin-bottom: 0.55rem; }
|
||||
.dl-needs li::marker { color: var(--accent); }
|
||||
.dl-steps {
|
||||
list-style: none;
|
||||
counter-reset: dl;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
.step-card {
|
||||
counter-increment: dl;
|
||||
display: grid;
|
||||
grid-template-columns: 2.6rem 1fr;
|
||||
gap: 0 1rem;
|
||||
padding: 1.3rem 1.4rem;
|
||||
border: 1px solid var(--card-border);
|
||||
border-radius: 1rem;
|
||||
background: var(--card-bg);
|
||||
}
|
||||
.step-card::before {
|
||||
content: counter(dl);
|
||||
grid-row: span 2;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 2.6rem;
|
||||
height: 2.6rem;
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(135deg, var(--accent), var(--accent-hover));
|
||||
color: #fff;
|
||||
font-weight: 700;
|
||||
}
|
||||
.step-card h2 { margin: 0.35rem 0 0.4rem; font-size: 1.15rem; letter-spacing: -0.01em; }
|
||||
.step-body { min-width: 0; color: var(--fg-muted); }
|
||||
.step-body p { margin: 0 0 0.7rem; }
|
||||
.step-body p:last-child { margin: 0; }
|
||||
.step-body strong { color: var(--fg); font-weight: 600; }
|
||||
.step-body a, .dl-older a, .dl-alpha a { color: var(--accent); }
|
||||
kbd {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 0.85em;
|
||||
padding: 0.05rem 0.4rem;
|
||||
border: 1px solid var(--border);
|
||||
border-bottom-width: 2px;
|
||||
border-radius: 0.3rem;
|
||||
background: var(--bg);
|
||||
color: var(--fg);
|
||||
}
|
||||
.download pre {
|
||||
margin: 0.4rem 0 0;
|
||||
padding: 0.85rem 1rem;
|
||||
border-radius: 0.6rem;
|
||||
background: var(--bg-subtle);
|
||||
border: 1px solid var(--border);
|
||||
overflow-x: auto;
|
||||
font-size: 0.85rem;
|
||||
line-height: 1.55;
|
||||
color: var(--fg);
|
||||
}
|
||||
.download code { font-family: var(--font-mono); }
|
||||
.download :not(pre) > code {
|
||||
padding: 0.05rem 0.3rem;
|
||||
border-radius: 0.3rem;
|
||||
background: var(--bg-subtle);
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.dl-hash code { overflow-wrap: anywhere; white-space: pre-wrap; }
|
||||
.dl-cmds .c { color: var(--fg-muted); }
|
||||
.dl-muted { color: var(--fg-muted); }
|
||||
.dl-older { margin-top: 3rem; }
|
||||
@media (max-width: 30rem) {
|
||||
.dl-card, .dl-band { padding: 1.35rem; }
|
||||
.step-card { grid-template-columns: 1fr; }
|
||||
.step-card::before { grid-row: auto; margin-bottom: 0.6rem; }
|
||||
}
|
||||
|
||||
/* ── Intro paragraph (home, between hero and feature grids) ─ */
|
||||
|
||||
.intro {
|
||||
|
|
@ -647,142 +439,3 @@ kbd {
|
|||
will-change: auto;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Logo poll ───────────────────────────────────────────────── */
|
||||
|
||||
.poll-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
|
||||
gap: 1.5rem;
|
||||
margin-top: 2.5rem;
|
||||
}
|
||||
.poll-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.9rem;
|
||||
padding: 1.4rem;
|
||||
border: 1px solid var(--card-border);
|
||||
border-radius: 1rem;
|
||||
background: var(--card-bg);
|
||||
transition: border-color 160ms, box-shadow 160ms;
|
||||
}
|
||||
.is-yours { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
|
||||
.poll-card h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; }
|
||||
.poll-desc { margin: 0; color: var(--fg-muted); font-size: 0.95rem; }
|
||||
.poll-art { display: grid; place-items: center; padding: 2.2rem 1rem; border-radius: 0.75rem; }
|
||||
.poll-art--m { background: var(--bg-subtle); }
|
||||
.poll-art--r { background: #151515; }
|
||||
.poll-art .pm { height: 9rem; width: auto; }
|
||||
.pm { display: block; }
|
||||
.poll-btn {
|
||||
margin-top: auto;
|
||||
padding: 0.85rem 1.2rem;
|
||||
border: 1px solid var(--accent);
|
||||
border-radius: 0.6rem;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background 140ms, transform 140ms;
|
||||
}
|
||||
.poll-btn:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
|
||||
.poll-btn:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
|
||||
.poll-btn:disabled { cursor: default; opacity: 0.85; }
|
||||
.is-yours .poll-btn { background: transparent; color: var(--accent); }
|
||||
.poll-bar { height: 0.45rem; border-radius: 999px; background: var(--bg-subtle); overflow: hidden; display: none; }
|
||||
.poll-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 500ms ease; }
|
||||
.poll--voted .poll-bar { display: block; }
|
||||
.poll-bar--final { display: block; }
|
||||
.poll-result {
|
||||
margin: 1.5rem 0 0;
|
||||
padding: 1rem 1.2rem;
|
||||
border-left: 3px solid var(--accent);
|
||||
background: var(--bg-subtle);
|
||||
border-radius: 0 0.6rem 0.6rem 0;
|
||||
max-width: 40rem;
|
||||
}
|
||||
.poll-result strong { color: var(--accent); }
|
||||
.poll-count { margin: 0; min-height: 1.4em; font-size: 0.85rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
|
||||
.poll-status { margin: 1.25rem 0 0; min-height: 1.5em; color: var(--fg-muted); }
|
||||
.poll-note { margin-top: 1rem; max-width: var(--measure); font-size: 0.85rem; color: var(--fg-muted); }
|
||||
.poll-note a { color: var(--accent); }
|
||||
|
||||
/* showcase */
|
||||
.show { display: flex; flex-direction: column; gap: 3rem; margin-top: 4rem; }
|
||||
.show-intro { margin: 0; }
|
||||
.show-row { display: flex; flex-direction: column; gap: 0.6rem; }
|
||||
.show-h { margin: 0; font-size: 1.35rem; letter-spacing: -0.01em; }
|
||||
.show-p { margin: 0 0 0.6rem; max-width: var(--measure); color: var(--fg-muted); font-size: 0.95rem; }
|
||||
.show-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1.25rem; }
|
||||
.show-cell {
|
||||
display: flex; flex-direction: column; gap: 0.9rem;
|
||||
padding: 1.1rem; border: 1px solid var(--card-border); border-radius: 0.9rem; background: var(--card-bg);
|
||||
}
|
||||
.show-cell--m { color: var(--accent); }
|
||||
.show-cell--r { color: #af6428; }
|
||||
.show-tag { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-muted); }
|
||||
.sizes { display: flex; align-items: flex-end; gap: 1.1rem; flex-wrap: wrap; }
|
||||
.sizes figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
|
||||
.sizes figcaption { font-family: var(--font-mono); font-size: 0.65rem; color: var(--fg-muted); }
|
||||
.sz { display: block; }
|
||||
.sz .pm { width: auto; }
|
||||
.sz-96 .pm { height: 96px; } .sz-48 .pm { height: 48px; } .sz-32 .pm { height: 32px; } .sz-24 .pm { height: 24px; }
|
||||
.px { image-rendering: pixelated; }
|
||||
.lock { display: grid; place-items: center; padding: 1rem; border-radius: 0.6rem; background: var(--bg-subtle); }
|
||||
.lock-h .pm { height: 3rem; width: auto; max-width: 100%; }
|
||||
.lock-s .pm { height: 7rem; width: auto; max-width: 100%; }
|
||||
.mock { border: 1px solid var(--border); border-radius: 0.7rem; overflow: hidden; background: var(--bg); color: var(--fg); font-size: 0.8rem; }
|
||||
.tabbar { background: var(--bg-subtle); padding: 0.55rem 0.65rem; }
|
||||
.tab { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.3rem 0.65rem; border: 1px solid var(--border); border-radius: 0.4rem; background: var(--bg); color: var(--fg-muted); }
|
||||
.urlbar { padding: 0.45rem 0.75rem; border-top: 1px solid var(--border); font-family: var(--font-mono); font-size: 0.72rem; color: var(--fg-muted); }
|
||||
.uihead { display: flex; align-items: center; gap: 0.5rem; padding: 0.8rem 0.9rem; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
|
||||
.uihead-mark { display: inline-flex; color: inherit; }
|
||||
.show-cell--m .uihead-mark { color: var(--accent); }
|
||||
.show-cell--r .uihead-mark { color: #af6428; }
|
||||
.uihead-mark .pm { height: 1.25rem; width: auto; }
|
||||
.uihead-name { font-weight: 600; letter-spacing: 0.13em; text-transform: uppercase; font-size: 0.72rem; color: var(--fg); }
|
||||
.uihead-nav { margin-left: auto; display: flex; gap: 0.7rem; color: var(--fg-muted); }
|
||||
.uibody { padding: 0.9rem; display: flex; flex-direction: column; gap: 0.45rem; }
|
||||
.uibody i { display: block; height: 0.45rem; border-radius: 3px; background: var(--bg-subtle); }
|
||||
.uibody i.s { width: 45%; }
|
||||
.tiles { display: flex; gap: 1rem; justify-content: center; padding: 1.2rem; border-radius: 0.6rem; background: var(--bg-subtle); }
|
||||
.tiles img { width: 6rem; height: 6rem; }
|
||||
.term {
|
||||
margin: 0; padding: 0.9rem 1rem; border-radius: 0.6rem; overflow-x: auto;
|
||||
background: #100f0c; color: #d8d2c2; font-family: var(--font-mono); font-size: 0.55rem; line-height: 1;
|
||||
-webkit-text-size-adjust: none; text-size-adjust: none;
|
||||
}
|
||||
.term i, .term b { font-style: normal; font-weight: 400; color: inherit; }
|
||||
.show-cell--m .term i { color: #ff6b56; } .show-cell--m .term b { color: #ff6b56; }
|
||||
.show-cell--r .term i { color: #c9803f; } .show-cell--r .term b { color: #c9803f; }
|
||||
.shot { display: block; width: 100%; height: auto; border-radius: 0.6rem; }
|
||||
.grounds { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
|
||||
.ground { display: grid; place-items: center; padding: 1.2rem; border-radius: 0.6rem; border: 1px solid var(--border); }
|
||||
.ground--fg { background: var(--bg-subtle); color: var(--fg); }
|
||||
.ground .pm { height: 3.2rem; width: auto; }
|
||||
.poll-final { margin-top: 3.5rem; display: flex; flex-direction: column; gap: 1rem; }
|
||||
.poll-final-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1.25rem; }
|
||||
.poll-final-card {
|
||||
display: flex; flex-direction: column; gap: 0.8rem; align-items: stretch;
|
||||
padding: 1.1rem; border: 1px solid var(--card-border); border-radius: 0.9rem; background: var(--card-bg);
|
||||
}
|
||||
.poll-final-mark { display: grid; place-items: center; padding: 0.8rem; }
|
||||
.poll-final-mark .pm { height: 3.5rem; width: auto; }
|
||||
.home-poll {
|
||||
display: inline-flex; align-items: center; gap: 0.6rem; margin-top: 1.4rem;
|
||||
padding: 0.55rem 0.95rem; border: 1px solid var(--border); border-radius: 999px;
|
||||
background: var(--card-bg); color: var(--fg); text-decoration: none; font-size: 0.92rem;
|
||||
}
|
||||
.home-poll:hover { border-color: var(--accent); }
|
||||
.home-poll .pm { height: 1.1rem; width: auto; color: var(--accent); }
|
||||
.home-poll .pm + .pm { color: #af6428; }
|
||||
/* Random left/right per visit — data-logo-order is set in head.html before first paint.
|
||||
Every pair container is a grid/flex, so `order` swaps the columns without touching the DOM. */
|
||||
[data-logo-order="rm"] .poll-card[data-choice="m"],
|
||||
[data-logo-order="rm"] .show-cell.show-cell--m,
|
||||
[data-logo-order="rm"] .poll-final-card[data-choice="m"],
|
||||
[data-logo-order="mr"] .poll-card[data-choice="r"],
|
||||
[data-logo-order="mr"] .show-cell.show-cell--r,
|
||||
[data-logo-order="mr"] .poll-final-card[data-choice="r"] { order: 1; }
|
||||
@media (prefers-reduced-motion: reduce) { .poll-bar i, .poll-btn { transition: none; } }
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
// furtka.org logo poll — no cookies, no storage. The server tells us
|
||||
// what this device already chose (salted hash of IP + user agent).
|
||||
(function () {
|
||||
var root = document.querySelector('.poll');
|
||||
if (!root || !window.fetch) return;
|
||||
var api = root.dataset.api;
|
||||
var status = root.querySelector('.poll-status');
|
||||
var t = status.dataset;
|
||||
var buttons = root.querySelectorAll('[data-vote]');
|
||||
var busy = false;
|
||||
|
||||
function pct(n, total) { return total ? Math.round((n / total) * 100) : 0; }
|
||||
function each(sel, fn) { Array.prototype.forEach.call(root.querySelectorAll(sel), fn); }
|
||||
|
||||
function render(d) {
|
||||
var total = d.total || 0;
|
||||
root.classList.toggle('poll--voted', !!d.yours);
|
||||
Object.keys(d.counts).forEach(function (k) {
|
||||
var n = d.counts[k], p = pct(n, total), mine = d.yours === k;
|
||||
each('[data-choice="' + k + '"]', function (card) {
|
||||
card.classList.toggle('is-yours', mine);
|
||||
var bar = card.querySelector('.poll-bar i'); if (bar) bar.style.width = p + '%';
|
||||
var c = card.querySelector('[data-count]'); if (c) c.textContent = d.yours ? p + ' % · ' + n : '';
|
||||
});
|
||||
each('[data-vote="' + k + '"]', function (b) {
|
||||
b.disabled = mine;
|
||||
b.textContent = mine ? t.tVoted : (d.yours ? t.tChange : b.dataset.label);
|
||||
});
|
||||
});
|
||||
status.textContent = d.yours ? t.tTotal.replace('{n}', total) : '';
|
||||
}
|
||||
|
||||
function load() {
|
||||
fetch(api, { headers: { Accept: 'application/json' } })
|
||||
.then(function (r) { if (!r.ok) throw r; return r.json(); })
|
||||
.then(render)
|
||||
.catch(function () { status.textContent = t.tError; });
|
||||
}
|
||||
|
||||
Array.prototype.forEach.call(buttons, function (b) {
|
||||
b.dataset.label = b.textContent;
|
||||
b.addEventListener('click', function () {
|
||||
if (busy) return;
|
||||
busy = true; b.disabled = true;
|
||||
fetch(api, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({ choice: b.dataset.vote })
|
||||
})
|
||||
.then(function (r) { if (!r.ok) throw r; return r.json(); })
|
||||
.then(function (d) { render(d); status.scrollIntoView({ block: 'nearest' }); })
|
||||
.catch(function () { status.textContent = t.tError; b.disabled = false; })
|
||||
.then(function () { busy = false; });
|
||||
});
|
||||
});
|
||||
|
||||
status.textContent = '';
|
||||
load();
|
||||
})();
|
||||
|
|
@ -1,11 +1,7 @@
|
|||
---
|
||||
title: "Furtka"
|
||||
description: "Offenes Heimserver-Betriebssystem — einfach genug für alle."
|
||||
status_text: "in Arbeit"
|
||||
cta_download: "ISO herunterladen"
|
||||
cta_source: "Quellcode"
|
||||
poll_link: "/de/logo/"
|
||||
poll_text: "Abgestimmt — das ist unser neues Logo"
|
||||
status: "<span class=\"mono\">26.20-alpha</span> — in Arbeit"
|
||||
# features_today / features_next müssen index-parallel zu content/_index.md bleiben.
|
||||
intro: |
|
||||
**Furtka** ist ein offenes Heimserver-Betriebssystem.
|
||||
|
|
@ -14,16 +10,6 @@ intro: |
|
|||
Apps, eigenem Namen im Netz, eigenen Daten.
|
||||
|
||||
Das Ziel ist einfach: **dein Vater soll das einrichten können.**
|
||||
steps_label: "So funktioniert's"
|
||||
steps:
|
||||
- title: "Herunterladen"
|
||||
body: "Installer holen und auf einen USB-Stick schreiben."
|
||||
- title: "Installieren"
|
||||
body: "Computer vom Stick starten und dem Assistenten folgen — im Browser auf Handy oder Laptop."
|
||||
- title: "Loslegen"
|
||||
body: "**http://furtka.local** öffnen und Apps mit einem Klick installieren."
|
||||
band_title: "Lust, es auszuprobieren?"
|
||||
band_text: "Kostenlos und quelloffen (AGPL-3.0). Läuft auf 64-Bit-PCs, auch auf alten."
|
||||
features_today_label: "Was heute schon geht"
|
||||
features_today:
|
||||
- "Vom USB-Stick booten und Furtka auf die Festplatte einrichten"
|
||||
|
|
@ -33,15 +19,11 @@ features_today:
|
|||
- "Apps mit einem Klick installieren und entfernen"
|
||||
- "Eine installierte App mit einem Klick aktualisieren (holt das neueste Container-Image)"
|
||||
- "Furtka selbst mit einem Klick aktualisieren — keine Neuinstallation mehr für neue Features"
|
||||
- "Die Bedienseite fragt nach einem Passwort — niemand im WLAN kommt einfach so rein"
|
||||
- "Neue Apps kommen aus einem Online-Katalog, ohne auf ein Furtka-Update zu warten"
|
||||
- "Apps können auf anderen Apps aufbauen — was eine braucht, wird mit installiert"
|
||||
- "Verschlüsselte Verbindung im Heimnetz, in den Einstellungen einschaltbar"
|
||||
features_next_label: "Was als Nächstes kommt"
|
||||
features_next:
|
||||
- "Apps für Fotos, Dateien, Smarthome, Spiele-Streaming und Medien"
|
||||
- "Einfachere Sprache im Einrichtungs-Assistenten"
|
||||
- "Den Server auch von unterwegs erreichen"
|
||||
- "Sichere Verbindung im Heimnetz (ohne Warnmeldung im Browser)"
|
||||
- "Mehrere Server zusammenschalten"
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
---
|
||||
title: "Furtka"
|
||||
description: "Open-source home server OS — simple enough for everyone."
|
||||
status_text: "work in progress"
|
||||
cta_download: "Download ISO"
|
||||
cta_source: "Source code"
|
||||
poll_link: "/logo/"
|
||||
poll_text: "The vote is in — meet our new logo"
|
||||
status: "<span class=\"mono\">26.20-alpha</span> — work in progress"
|
||||
# Keep features_today / features_next index-aligned with content/_index.de.md.
|
||||
intro: |
|
||||
**Furtka** is an open-source home server OS.
|
||||
|
|
@ -14,16 +10,6 @@ intro: |
|
|||
your own name on the network, your own data.
|
||||
|
||||
The goal is simple: **your dad should be able to set this up.**
|
||||
steps_label: "How it works"
|
||||
steps:
|
||||
- title: "Download"
|
||||
body: "Get the installer and write it to a USB stick."
|
||||
- title: "Install"
|
||||
body: "Start the computer from the stick and follow the wizard — in the browser on your phone or laptop."
|
||||
- title: "Use"
|
||||
body: "Open **http://furtka.local** and install apps with one click."
|
||||
band_title: "Ready to try it?"
|
||||
band_text: "Free and open source (AGPL-3.0). Runs on 64-bit PCs, old ones included."
|
||||
features_today_label: "What works today"
|
||||
features_today:
|
||||
- "Boot from USB stick and install Furtka onto the hard drive"
|
||||
|
|
@ -33,15 +19,11 @@ features_today:
|
|||
- "Install and remove apps with one click"
|
||||
- "Update an installed app with one click (pulls the newest container image)"
|
||||
- "Update Furtka itself with one click — no reinstalling for new features"
|
||||
- "The control page asks for a password — nobody on the Wi-Fi can just walk in"
|
||||
- "New apps arrive from an online catalog, without waiting for a Furtka update"
|
||||
- "Apps can build on other apps — what one needs gets installed alongside it"
|
||||
- "Encrypted connection on your home network, switched on in settings"
|
||||
features_next_label: "What's coming next"
|
||||
features_next:
|
||||
- "Apps for photos, files, smart home, game streaming and media"
|
||||
- "Plainer language in the setup wizard"
|
||||
- "Reaching your server from outside the house"
|
||||
- "Secure connection on your home network (no browser warning)"
|
||||
- "Linking several servers together"
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ Diese Website setzt **keine Cookies**, lädt **keine Schriften oder
|
|||
Skripte von Drittanbietern**, bindet **keine Analyse- oder
|
||||
Tracking-Dienste** ein und enthält **keine externen Einbettungen**
|
||||
(YouTube, Maps, Social-Media-Buttons, …). Technisch anfallend sind
|
||||
ausschließlich kurzfristige Server-Zugriffsprotokolle — und, solange die
|
||||
[Logo-Abstimmung](/de/logo/) läuft, ein gesalzener Hash pro Stimme (siehe unten).
|
||||
ausschließlich kurzfristige Server-Zugriffsprotokolle.
|
||||
|
||||
### Verantwortlicher
|
||||
|
||||
|
|
@ -44,22 +43,6 @@ an Betrieb und Sicherheit).
|
|||
Infrastruktur; es gibt keinen externen Auftragsverarbeiter.
|
||||
**Drittlandübermittlung:** keine.
|
||||
|
||||
### Logo-Abstimmung
|
||||
|
||||
Auf der Seite [/de/logo/](/de/logo/) können Sie zwischen zwei
|
||||
Logo-Vorschlägen abstimmen. Damit jedes Gerät ohne Cookie einmal gezählt
|
||||
wird, speichert der Abstimmungsserver einen **gesalzenen SHA-256-Hash aus
|
||||
Ihrer IP-Adresse und Browser-Kennung** zusammen mit Ihrer Wahl und dem
|
||||
Zeitpunkt der Stimmabgabe. Der Hash lässt sich nicht in die Adresse
|
||||
zurückrechnen; das Salt verlässt den Server nicht.
|
||||
|
||||
**Zweck:** Zählung je Gerät einmal.
|
||||
**Rechtsgrundlage:** Art. 6 Abs. 1 lit. f DSGVO — berechtigtes Interesse
|
||||
an einer ehrlichen Auszählung; die Teilnahme ist freiwillig.
|
||||
**Speicherdauer:** bis zum Ende der Abstimmung, danach wird die Datenbank
|
||||
gelöscht.
|
||||
**Empfänger:** keine.
|
||||
|
||||
### Cookies und Tracking
|
||||
|
||||
Keine. Es werden keine Cookies gesetzt, kein LocalStorage oder
|
||||
|
|
@ -92,5 +75,5 @@ Website: <https://www.datenschutz.rlp.de>
|
|||
|
||||
### Stand
|
||||
|
||||
Diese Erklärung ist aktuell gültig und wurde zuletzt am 26.08.2026
|
||||
Diese Erklärung ist aktuell gültig und wurde zuletzt am 18.04.2026
|
||||
aktualisiert.
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ sitemap:
|
|||
This website sets **no cookies**, loads **no third-party fonts or
|
||||
scripts**, embeds **no analytics or tracking services**, and contains
|
||||
**no external embeds** (YouTube, Maps, social buttons, …). The only
|
||||
technical data collected is short-lived server access logs — plus, while
|
||||
the [logo poll](/logo/) is running, one salted hash per vote (see below).
|
||||
technical data collected is short-lived server access logs.
|
||||
|
||||
### Controller
|
||||
|
||||
|
|
@ -44,20 +43,6 @@ and security.
|
|||
external processor is involved.
|
||||
**Transfers outside the EU/EEA:** none.
|
||||
|
||||
### Logo poll
|
||||
|
||||
The page [/logo/](/logo/) lets you vote between two logo proposals. So
|
||||
that each device is counted once without a cookie, the poll server stores
|
||||
a **salted SHA-256 hash of your IP address and browser identification**
|
||||
together with your choice and the time of the vote. The hash cannot be
|
||||
turned back into the address; the salt never leaves the server.
|
||||
|
||||
**Purpose:** counting votes once per device.
|
||||
**Legal basis:** Art. 6(1)(f) GDPR — legitimate interest in an honest
|
||||
tally; voting is voluntary.
|
||||
**Retention:** until the poll is closed, then the database is deleted.
|
||||
**Recipients:** none.
|
||||
|
||||
### Cookies and tracking
|
||||
|
||||
None. No cookies are set, no localStorage or sessionStorage is used, and
|
||||
|
|
@ -90,6 +75,6 @@ Website: <https://www.datenschutz.rlp.de>
|
|||
|
||||
### Last updated
|
||||
|
||||
This statement was last updated on 2026-08-26.
|
||||
This statement was last updated on 2026-04-18.
|
||||
|
||||
The German version of this privacy statement is the legally binding one.
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
---
|
||||
title: "Furtka herunterladen"
|
||||
description: "Der Furtka-Installer als ISO-Datei: auf einen USB-Stick schreiben, den Computer davon starten und den Heimserver im Browser einrichten."
|
||||
translationKey: "download"
|
||||
url: /de/download/
|
||||
type: download
|
||||
button: "ISO herunterladen"
|
||||
released: "Veröffentlicht"
|
||||
size_label: "Größe"
|
||||
alpha: "Furtka ist **Alpha-Software**: Dinge ändern sich und manches geht kaputt. Installiere es auf einem Computer, dessen Festplatte du nicht brauchst, und sichere alles Wichtige."
|
||||
host_note: "Die Datei kommt von unserem Forgejo-Server (forgejo.sourcegate.online)."
|
||||
need_label: "Was du brauchst"
|
||||
needs:
|
||||
- "Einen **64-Bit-PC** (x86-64) — ein alter Laptop oder Desktop reicht. UEFI- und ältere BIOS-Rechner funktionieren beide."
|
||||
- "Eine Festplatte mit **mindestens 16 GB** für Furtka. **Sie wird komplett gelöscht.**"
|
||||
- "Einen **USB-Stick** mit mindestens 2 GB (wird ebenfalls gelöscht)."
|
||||
- "Ein **Netzwerkkabel** mit Internetzugang — der Installer lädt Pakete herunter, und WLAN wird nicht automatisch eingerichtet."
|
||||
- "Ein **zweites Gerät mit Browser** (Handy oder Laptop) im selben Netzwerk."
|
||||
steps_label: "So installierst du Furtka"
|
||||
steps:
|
||||
- title: "ISO auf einen USB-Stick schreiben"
|
||||
body: |
|
||||
Nimm [balenaEtcher](https://etcher.balena.io/) (Windows, macOS, Linux) oder [Rufus](https://rufus.ie/) unter Windows — wenn Rufus fragt, wähle den **DD-Abbild-Modus**. Unter Linux geht auch `dd` (ersetze `/dev/sdX` durch deinen Stick — lieber zweimal prüfen):
|
||||
|
||||
```
|
||||
sudo dd if={iso} of=/dev/sdX bs=4M status=progress oflag=sync
|
||||
```
|
||||
- title: "Computer vom Stick starten"
|
||||
body: "Stick und Netzwerkkabel einstecken, Computer einschalten und die Taste fürs Bootmenü drücken (oft <kbd>F11</kbd>, <kbd>F12</kbd> oder <kbd>Esc</kbd> — sie wird kurz am Bildschirm angezeigt). Den USB-Stick auswählen. Startet der Computer nicht davon, schalte **Secure Boot** in den Firmware-Einstellungen aus."
|
||||
- title: "Installer von einem anderen Gerät öffnen"
|
||||
body: "Nach kurzer Zeit zeigt der Bildschirm eine Adresse an — meist **http://proksi.local:5000**, dazu die IP-Adresse als Ausweichweg. Öffne sie im Browser auf Handy oder Laptop."
|
||||
- title: "Durch den Assistenten klicken"
|
||||
body: "Drei Seiten: ein Name für deinen Server mit Benutzername und Passwort, die Festplatte und eine letzte Kontrolle. Danach lädt der Installer alles herunter und richtet es ein."
|
||||
- title: "Stick raus, neu starten, fertig"
|
||||
body: "Wenn der Assistent es sagt, den USB-Stick abziehen und neu starten. Dein Server ist dann unter **http://<name>.local** erreichbar — zum Beispiel http://furtka.local."
|
||||
verify_label: "Download prüfen (optional)"
|
||||
verify_intro: "Vergleiche die Prüfsumme der heruntergeladenen Datei mit dieser:"
|
||||
verify_missing: "Für die ISO dieses Releases ist noch keine Prüfsumme veröffentlicht — künftige Releases bringen eine mit."
|
||||
older: "Alle Releases und Änderungen"
|
||||
---
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
---
|
||||
title: "Download Furtka"
|
||||
description: "The Furtka installer as an ISO file: write it to a USB stick, start your computer from it, and set up your home server in the browser."
|
||||
translationKey: "download"
|
||||
url: /download/
|
||||
type: download
|
||||
button: "Download ISO"
|
||||
released: "Released"
|
||||
size_label: "Size"
|
||||
alpha: "Furtka is **alpha software**: things change and some will break. Install it on a computer whose disk you don't need, and keep a backup of anything important."
|
||||
host_note: "The file is served from our Forgejo server (forgejo.sourcegate.online)."
|
||||
need_label: "What you need"
|
||||
needs:
|
||||
- "A **64-bit PC** (x86-64) — an old laptop or desktop is fine. Both UEFI and older BIOS computers work."
|
||||
- "A disk of **at least 16 GB** for Furtka. **It will be erased completely.**"
|
||||
- "A **USB stick** with at least 2 GB (also erased)."
|
||||
- "A **network cable** with internet access — the installer downloads packages, and Wi-Fi isn't set up automatically."
|
||||
- "A **second device with a browser** (phone or laptop) on the same network."
|
||||
steps_label: "How to install"
|
||||
steps:
|
||||
- title: "Write the ISO to a USB stick"
|
||||
body: |
|
||||
Use [balenaEtcher](https://etcher.balena.io/) (Windows, macOS, Linux) or [Rufus](https://rufus.ie/) on Windows — if Rufus asks, pick **DD image mode**. On Linux you can also use `dd` (replace `/dev/sdX` with your stick — double-check it):
|
||||
|
||||
```
|
||||
sudo dd if={iso} of=/dev/sdX bs=4M status=progress oflag=sync
|
||||
```
|
||||
- title: "Start the computer from the stick"
|
||||
body: "Plug in the stick and the network cable, switch the computer on and press the one-time boot menu key (often <kbd>F11</kbd>, <kbd>F12</kbd> or <kbd>Esc</kbd> — it flashes briefly on screen). Pick the USB stick. If the computer refuses to start from it, switch off **Secure Boot** in the firmware settings."
|
||||
- title: "Open the installer from another device"
|
||||
body: "After a short while the screen shows an address — usually **http://proksi.local:5000**, plus the IP address as a fallback. Open it in a browser on your phone or laptop."
|
||||
- title: "Click through the wizard"
|
||||
body: "Three pages: a name for your server with your username and password, the disk to install on, and a last check. Then the installer downloads and sets everything up."
|
||||
- title: "Pull the stick, restart, done"
|
||||
body: "When the wizard says so, remove the USB stick and restart. Your server comes up at **http://<name>.local** — for example http://furtka.local."
|
||||
verify_label: "Check the download (optional)"
|
||||
verify_intro: "Compare the checksum of the file you downloaded with this one:"
|
||||
verify_missing: "This release has no published checksum for the ISO yet — future releases include one."
|
||||
older: "All releases and changelogs"
|
||||
---
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
---
|
||||
title: "Unser neues Logo"
|
||||
description: "Zwei Vorschläge für das Furtka-Zeichen, und ihr habt gewählt. So ist die Abstimmung ausgegangen — und so sähe jedes Zeichen überall aus, wo es funktionieren müsste."
|
||||
closed: true
|
||||
result: "Die Abstimmung ist beendet — **M hat mit 29 von 42 Stimmen gewonnen** (R: 13). Danke an alle, die abgestimmt haben! M ist jetzt das Furtka-Logo."
|
||||
final:
|
||||
m: 29
|
||||
r: 13
|
||||
translationKey: "logo"
|
||||
layout: single
|
||||
type: poll
|
||||
poll: logo
|
||||
image: /img/logo/vote-card.png
|
||||
sitemap:
|
||||
priority: 0.5
|
||||
m:
|
||||
short: "M"
|
||||
title: "M — das f im Tor"
|
||||
text: "Ein kleines f, aus einem Rundbogentor ausgestanzt. Der Stamm ist der Torpfosten, die zwei Balken sind die Querriegel."
|
||||
r:
|
||||
short: "R"
|
||||
title: "R — Fenster, Rad und F"
|
||||
text: "Ein Bogenfenster mit einem Speichenrad dahinter; in der oberen rechten Scheibe wird die Speiche zum F."
|
||||
show:
|
||||
intro: "Beide Zeichen überall dort, wo sie hätten funktionieren müssen."
|
||||
sizes: "Groß und klein"
|
||||
sizes_text: "Vom Poster bis zum 16-Pixel-Symbol im Browser-Tab. Unter 32 Pixeln wechseln beide auf eine vereinfachte Zeichnung — M verliert nichts, R behält Fenster, Kreuz und Nabe."
|
||||
name: "Mit dem Namen"
|
||||
name_text: "Nebeneinander und gestapelt. Die Wortmarke ist bei beiden dieselbe, also entscheidet nur das Zeichen."
|
||||
browser: "Im Browser"
|
||||
browser_text: "Das Tab-Symbol in echter Größe und die Kopfzeile von furtka.org."
|
||||
nav1: "Doku"
|
||||
nav2: "Blog"
|
||||
phone: "Auf dem Handy"
|
||||
phone_text: "Startbildschirm-Symbol — eckig wie auf Android, rund wie manche Launcher es beschneiden."
|
||||
box: "Auf dem Server"
|
||||
box_text: "Der Text-Willkommensbildschirm, den der Server am Monitor zeigt, und der Startbildschirm beim Booten."
|
||||
shared: "Geteilt"
|
||||
shared_text: "Die Vorschaukarte, die erscheint, wenn jemand einen Link zu furtka.org postet."
|
||||
colour: "In Farbe"
|
||||
colour_text: "Auf hell, auf dunkel, auf der eigenen Farbe und in normaler Textfarbe — jedes Zeichen ist eine Form und nimmt die Farbe an, die es umgibt."
|
||||
final: "Genug gesehen?"
|
||||
labels:
|
||||
vote: "Dieses hier"
|
||||
voted: "Deine Wahl"
|
||||
change: "Zu diesem wechseln"
|
||||
total: "Bisher {n} Stimmen. Danke!"
|
||||
error: "Die Abstimmung ist gerade nicht erreichbar — bitte gleich noch einmal versuchen."
|
||||
nojs: "Zum Abstimmen wird JavaScript benötigt."
|
||||
note: "Keine Cookies, kein Konto. Damit jedes Gerät einmal zählt, speichert der Server einen gesalzenen Hash aus IP-Adresse und Browser — nicht die Adresse selbst. Details in der <a href=\"/de/datenschutz/\">Datenschutzerklärung</a>."
|
||||
---
|
||||
|
||||
*Furtka* ist polnisch für die kleine Gartenpforte — die Tür im Zaun, durch
|
||||
die man hineinkommt, ohne das große Tor aufzumachen. Beide Zeichen spielen
|
||||
damit: das eine zeichnet den Buchstaben ins Tor, das andere schaut durchs
|
||||
Tor auf ein Rad. Unten stehen beide mit dem Endergebnis — und jedes Zeichen
|
||||
überall dort, wo es hätte funktionieren müssen, vom Poster bis zum winzigen
|
||||
Symbol im Browser-Tab.
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
---
|
||||
title: "Our new logo"
|
||||
description: "Two proposals for the Furtka mark, and you picked one. Here is how the vote ended — and each mark everywhere it would have had to work."
|
||||
closed: true
|
||||
result: "The vote is closed — **M won with 29 of 42 votes** (R: 13). Thank you to everyone who voted! M is now the Furtka logo."
|
||||
final:
|
||||
m: 29
|
||||
r: 13
|
||||
translationKey: "logo"
|
||||
url: /logo/
|
||||
layout: single
|
||||
type: poll
|
||||
poll: logo
|
||||
image: /img/logo/vote-card.png
|
||||
sitemap:
|
||||
priority: 0.5
|
||||
m:
|
||||
short: "M"
|
||||
title: "M — the f in the gate"
|
||||
text: "A lowercase f cut out of an arched gate. The stem is the gate post, the two rails are the crossbars."
|
||||
r:
|
||||
short: "R"
|
||||
title: "R — window, wheel and F"
|
||||
text: "An arched window with a wheel of spokes behind it; in the top-right pane the spoke becomes an F."
|
||||
show:
|
||||
intro: "Both marks everywhere they would have had to work."
|
||||
sizes: "Big and small"
|
||||
sizes_text: "From a poster to the 16-pixel icon in a browser tab. Below 32 pixels both marks switch to a simplified drawing — M drops nothing, R keeps the window, the cross and the hub."
|
||||
name: "With the name"
|
||||
name_text: "Side by side and stacked. The wordmark is the same for both, so only the mark decides."
|
||||
browser: "In the browser"
|
||||
browser_text: "The tab icon at its real size, and the site header of furtka.org."
|
||||
nav1: "Docs"
|
||||
nav2: "Blog"
|
||||
phone: "On the phone"
|
||||
phone_text: "Home-screen icon — square as on Android, round as some launchers cut it."
|
||||
box: "On the box"
|
||||
box_text: "The text-mode welcome screen your server shows on a monitor, and the boot splash."
|
||||
shared: "Shared"
|
||||
shared_text: "The preview card that appears when someone posts a link to furtka.org."
|
||||
colour: "In colour"
|
||||
colour_text: "On light, on dark, on its own colour, and in plain text colour — each mark is one shape and takes whatever colour is around it."
|
||||
final: "Seen enough?"
|
||||
labels:
|
||||
vote: "This one"
|
||||
voted: "Your pick"
|
||||
change: "Switch to this one"
|
||||
total: "{n} votes so far. Thank you!"
|
||||
error: "Couldn't reach the poll right now — please try again in a moment."
|
||||
nojs: "Voting needs JavaScript."
|
||||
note: "No cookies, no account. To count each device once, the server keeps a salted hash of your IP address and browser — not the address itself. Details in the <a href=\"/privacy/\">privacy notice</a>."
|
||||
---
|
||||
|
||||
*Furtka* is Polish for a small garden gate — the little door in the fence
|
||||
that lets you in without opening the whole thing. Both marks play with that:
|
||||
one draws the letter into the gate, the other looks through the gate at a
|
||||
wheel. Below are both, with the final count — and each mark everywhere it
|
||||
would have had to work, from a poster to the tiny icon in a browser tab.
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"display": "<svg class=\"pm\" viewBox=\"0 0 64 64\" aria-hidden=\"true\" focusable=\"false\"><defs><linearGradient id=\"gmd\" x1=\".15\" y1=\"0\" x2=\".7\" y2=\"1\"><stop offset=\"0\" stop-color=\"#d95a45\"/><stop offset=\".55\" stop-color=\"#c03a28\"/><stop offset=\"1\" stop-color=\"#8a2618\"/></linearGradient><clipPath id=\"cmd\" clip-rule=\"evenodd\"><path d=\"M6 60V28a26 26 0 0 1 52 0v32Z M20.0 60V26.5A10.5 10.5 0 0 1 30.5 16H45.0v8.6H32.5a3.5 3.5 0 0 0-3.5 3.5V32h16v8.6H29.0V60Z\"/></clipPath></defs><path fill=\"url(#gmd)\" fill-rule=\"evenodd\" d=\"M6 60V28a26 26 0 0 1 52 0v32Z M20.0 60V26.5A10.5 10.5 0 0 1 30.5 16H45.0v8.6H32.5a3.5 3.5 0 0 0-3.5 3.5V32h16v8.6H29.0V60Z\"/><g clip-path=\"url(#cmd)\"><path fill=\"#fff\" opacity=\".14\" d=\"M6 28a26 26 0 0 1 52 0v4.5a26 26 0 0 0-52 0Z\"/></g></svg>",
|
||||
"flat": "<svg class=\"pm\" viewBox=\"0 0 64 64\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M6 60V28a26 26 0 0 1 52 0v32Z M20.0 60V26.5A10.5 10.5 0 0 1 30.5 16H45.0v8.6H32.5a3.5 3.5 0 0 0-3.5 3.5V32h16v8.6H29.0V60Z\"/></svg>",
|
||||
"min": "<svg class=\"pm\" viewBox=\"0 0 64 64\" aria-hidden=\"true\" focusable=\"false\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M5 60V27a27 27 0 0 1 54 0v33Z M19.5 60V26A10 10 0 0 1 29.5 16H46v10H32a2.5 2.5 0 0 0-2.5 2.5V32H46v10H29.5v18Z\"/></svg>",
|
||||
"lockup_h": "<svg class=\"pm\" viewBox=\"0 -4 232.44 64.00\" aria-hidden=\"true\" focusable=\"false\"><g transform=\"scale(1.0000) translate(-6 -2)\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M6 60V28a26 26 0 0 1 52 0v32Z M20.0 60V26.5A10.5 10.5 0 0 1 30.5 16H45.0v8.6H32.5a3.5 3.5 0 0 0-3.5 3.5V32h16v8.6H29.0V60Z\"/></g><g fill=\"currentColor\"><path transform=\"translate(68.24 58.00) scale(0.05354 -0.05354)\" d=\"M115 0V494H30V600H115V637Q115 687 132.5 724.0Q150 761 192.0 781.5Q234 802 305 802Q333 802 358 799V695Q344 698 324 698Q287 698 273.5 682.0Q260 666 260 632V600H358V494H260V0Z\"/><path transform=\"translate(87.21 58.00) scale(0.05354 -0.05354)\" d=\"M271 -15Q169 -15 119.0 48.5Q69 112 69 218V600H218V244Q218 179 241.5 143.0Q265 107 316 107Q379 107 413.0 156.0Q447 205 447 276V600H596V0H462V90H438Q423 44 382.5 14.5Q342 -15 271 -15Z\"/><path transform=\"translate(121.45 58.00) scale(0.05354 -0.05354)\" d=\"M76 0V600H211V492H235Q241 521 257.0 547.0Q273 573 307.0 589.5Q341 606 399 606H428V471H387Q301 471 263.0 427.0Q225 383 225 294V0Z\"/><path transform=\"translate(144.17 58.00) scale(0.05354 -0.05354)\" d=\"M162 0Q139 27 125.5 65.0Q112 103 112 179V494H30V600H114V750H259V600H358V494H260V196Q260 116 278.0 74.5Q296 33 321 6V0Z\"/><path transform=\"translate(163.14 58.00) scale(0.05354 -0.05354)\" d=\"M78 0V800H226V366H274L449 600H608V594L397 320L632 6V0H457L274 254H226V0Z\"/><path transform=\"translate(195.88 58.00) scale(0.05354 -0.05354)\" d=\"M280 -13Q198 -13 144.0 27.5Q90 68 63.5 138.5Q37 209 37 301Q37 395 64.0 465.0Q91 535 145.0 574.0Q199 613 280 613Q344 613 384.5 587.5Q425 562 445 522H469V600H606V0H469V78H445Q425 41 385.0 14.0Q345 -13 280 -13ZM317 95Q381 95 419.5 151.0Q458 207 458 300Q458 394 419.5 449.5Q381 505 317 505Q257 505 223.5 453.0Q190 401 190 300Q190 199 223.5 147.0Q257 95 317 95Z\"/></g></svg>",
|
||||
"lockup_s": "<svg class=\"pm\" viewBox=\"0 0 164.20 125.89\" aria-hidden=\"true\" focusable=\"false\"><g transform=\"translate(56.10 0) scale(1.0000) translate(-6 -2)\"><path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M6 60V28a26 26 0 0 1 52 0v32Z M20.0 60V26.5A10.5 10.5 0 0 1 30.5 16H45.0v8.6H32.5a3.5 3.5 0 0 0-3.5 3.5V32h16v8.6H29.0V60Z\"/></g><g fill=\"currentColor\"><path transform=\"translate(0.00 111.76) scale(0.05354 -0.05354)\" d=\"M115 0V494H30V600H115V637Q115 687 132.5 724.0Q150 761 192.0 781.5Q234 802 305 802Q333 802 358 799V695Q344 698 324 698Q287 698 273.5 682.0Q260 666 260 632V600H358V494H260V0Z\"/><path transform=\"translate(18.97 111.76) scale(0.05354 -0.05354)\" d=\"M271 -15Q169 -15 119.0 48.5Q69 112 69 218V600H218V244Q218 179 241.5 143.0Q265 107 316 107Q379 107 413.0 156.0Q447 205 447 276V600H596V0H462V90H438Q423 44 382.5 14.5Q342 -15 271 -15Z\"/><path transform=\"translate(53.21 111.76) scale(0.05354 -0.05354)\" d=\"M76 0V600H211V492H235Q241 521 257.0 547.0Q273 573 307.0 589.5Q341 606 399 606H428V471H387Q301 471 263.0 427.0Q225 383 225 294V0Z\"/><path transform=\"translate(75.93 111.76) scale(0.05354 -0.05354)\" d=\"M162 0Q139 27 125.5 65.0Q112 103 112 179V494H30V600H114V750H259V600H358V494H260V196Q260 116 278.0 74.5Q296 33 321 6V0Z\"/><path transform=\"translate(94.90 111.76) scale(0.05354 -0.05354)\" d=\"M78 0V800H226V366H274L449 600H608V594L397 320L632 6V0H457L274 254H226V0Z\"/><path transform=\"translate(127.64 111.76) scale(0.05354 -0.05354)\" d=\"M280 -13Q198 -13 144.0 27.5Q90 68 63.5 138.5Q37 209 37 301Q37 395 64.0 465.0Q91 535 145.0 574.0Q199 613 280 613Q344 613 384.5 587.5Q425 562 445 522H469V600H606V0H469V78H445Q425 41 385.0 14.0Q345 -13 280 -13ZM317 95Q381 95 419.5 151.0Q458 207 458 300Q458 394 419.5 449.5Q381 505 317 505Q257 505 223.5 453.0Q190 401 190 300Q190 199 223.5 147.0Q257 95 317 95Z\"/></g></svg>",
|
||||
"tab16": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABJklEQVR42sWRvUoDURCFv9msf1hoZyFCGmEjWks2iIkSi9gIIZ2FQWx9BX0Gn0GsrUwjCSmMaB1ICBEsxMJGK8F13bHYmFzWJQQi+HX3zsyZc88VIlyvry7YCf8YZQ9huXfdUeRyEu8s03h4MfvFPFTd1K5FcA4yTzyvIrK/edO6+iVQTa9sWxJUgAmG4wXKztZtu94XqGWT0+JNdUCWGI3H9znfKVS6HzaAeDMlUGNY7hUOc41W05yquc6pwAmQnH2zi8CFFZaCvNHn69dnMTocRYU8gN3buGjUnnN33SeAetpxEdkYDGkG/QkvdBwKKJbxH4Gx5Qj0YLDWcKCSMBzEk220y0A5JoM+FmMy1EE9kyqgrMVlMJKAqpaA2Az+7An/LzA232GMWfyHzvuOAAAAAElFTkSuQmCC",
|
||||
"full16": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABJUlEQVR42sWRz0oCYRTFf3dmkDbSbqCwTQQzPUGkgRriE6TQrnqGwKB1u54jwjbtIxzB0hdIC7fppjb92SQ1t0WMfZlOgUFnd7977uGc8wlj0Mh4yYFK0UaWABDt2ujZ2sXN0yhXzKFawnb7fgVlD0iOcB9BDrKXnUOB8JtAtYTt9vxjYIM4qFSzzc5mJGJF727fr/x4/BGnXE8v735x0Mh4yVeVnmH7NlRr6z7VDsonvEXkYNWvIeSAB03YqXxw9ewADFSKlpFZQ9leb7XPY3zM8hIWgFMHwBI89HN7t9Cp0YJ62ttXZMc4nDfK8AEcAFUS5ndEtlWlgLA4vgtmhgKTkGte583Z6GAIiykR6yBI+0fAyvgOfiGAMjexg7+K8P8CU+Md2cpUHzmzh4cAAAAASUVORK5CYII=",
|
||||
"banner": " ▄▄▄▄▄▄▄▄\n ▄████████████▄\n ▄██████████████████\n ▄█████████▀▀▀▀▀▀▀████▄\n ▄██████▀ █████▄\n ██████▀ ██████\n ██████ █████████████\n ██████ ▀▀▀▀▀▀▀██████\n ██████ ██████\n ██████ ▄▄▄▄▄▄▄██████\n ██████ █████████████\n ██████ █████████████\n ██████ █████████████\n ██████ █████████████\n",
|
||||
"color": "#c03a28",
|
||||
"ink": "#0d0d0f"
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"display": "<svg class=\"pm\" viewBox=\"0 0 104 114\" aria-hidden=\"true\" focusable=\"false\"><defs><clipPath id=\"crd\" clip-rule=\"evenodd\"><path clip-rule=\"evenodd\" d=\"M2 112V42A40 40 0 0 1 42 2H62A40 40 0 0 1 102 42V112Z M63 65a11 11 0 1 0-22 0a11 11 0 1 0 22 0Z\"/></clipPath><linearGradient id=\"grd\" gradientUnits=\"userSpaceOnUse\" x1=\"0\" y1=\"2\" x2=\"0\" y2=\"112\"><stop offset=\"0\" stop-color=\"#c9803f\"/><stop offset=\".6\" stop-color=\"#af6428\"/><stop offset=\"1\" stop-color=\"#9a561f\"/></linearGradient></defs><g fill=\"none\" stroke=\"url(#grd)\" stroke-width=\"8\" stroke-linejoin=\"round\"><path d=\"M6 108V42A36 36 0 0 1 42 6H62A36 36 0 0 1 98 42V108Z\"/><path d=\"M52 8V106 M8 65H96 M52 65L4 31.1 M52 65L4 98.9 M52 65L100 98.9\" clip-path=\"url(#crd)\"/><path d=\"M52 22H79M52 37H69\" stroke-linecap=\"round\"/><circle cx=\"52\" cy=\"65\" r=\"15\"/></g></svg>",
|
||||
"flat": "<svg class=\"pm\" viewBox=\"0 0 104 114\" aria-hidden=\"true\" focusable=\"false\"><defs><clipPath id=\"c\" clip-rule=\"evenodd\"><path clip-rule=\"evenodd\" d=\"M2 112V42A40 40 0 0 1 42 2H62A40 40 0 0 1 102 42V112Z M63 65a11 11 0 1 0-22 0a11 11 0 1 0 22 0Z\"/></clipPath></defs><g fill=\"none\" stroke=\"currentColor\" stroke-width=\"8\" stroke-linejoin=\"round\"><path d=\"M6 108V42A36 36 0 0 1 42 6H62A36 36 0 0 1 98 42V108Z\"/><path d=\"M52 8V106 M8 65H96 M52 65L4 31.1 M52 65L4 98.9 M52 65L100 98.9\" clip-path=\"url(#c)\"/><path d=\"M52 22H79M52 37H69\" stroke-linecap=\"round\"/><circle cx=\"52\" cy=\"65\" r=\"15\"/></g></svg>",
|
||||
"min": "<svg class=\"pm\" viewBox=\"0 0 104 114\" aria-hidden=\"true\" focusable=\"false\"><g fill=\"none\" stroke=\"currentColor\" stroke-width=\"11\" stroke-linejoin=\"round\"><path d=\"M6 108V42A36 36 0 0 1 42 6H62A36 36 0 0 1 98 42V108Z\"/><path d=\"M52 8V106M8 65H96\"/><path d=\"M52 23H78M52 39H68\" stroke-linecap=\"round\"/></g><circle cx=\"52\" cy=\"65\" r=\"19\" fill=\"currentColor\"/></svg>",
|
||||
"lockup_h": "<svg class=\"pm\" viewBox=\"0 -4 233.17 64.00\" aria-hidden=\"true\" focusable=\"false\"><g transform=\"scale(0.5273) translate(-2 -2)\"><defs><clipPath id=\"c\" clip-rule=\"evenodd\"><path clip-rule=\"evenodd\" d=\"M2 112V42A40 40 0 0 1 42 2H62A40 40 0 0 1 102 42V112Z M63 65a11 11 0 1 0-22 0a11 11 0 1 0 22 0Z\"/></clipPath></defs><g fill=\"none\" stroke=\"currentColor\" stroke-width=\"8\" stroke-linejoin=\"round\"><path d=\"M6 108V42A36 36 0 0 1 42 6H62A36 36 0 0 1 98 42V108Z\"/><path d=\"M52 8V106 M8 65H96 M52 65L4 31.1 M52 65L4 98.9 M52 65L100 98.9\" clip-path=\"url(#c)\"/><path d=\"M52 22H79M52 37H69\" stroke-linecap=\"round\"/><circle cx=\"52\" cy=\"65\" r=\"15\"/></g></g><g fill=\"currentColor\"><path transform=\"translate(68.97 58.00) scale(0.05354 -0.05354)\" d=\"M115 0V494H30V600H115V637Q115 687 132.5 724.0Q150 761 192.0 781.5Q234 802 305 802Q333 802 358 799V695Q344 698 324 698Q287 698 273.5 682.0Q260 666 260 632V600H358V494H260V0Z\"/><path transform=\"translate(87.94 58.00) scale(0.05354 -0.05354)\" d=\"M271 -15Q169 -15 119.0 48.5Q69 112 69 218V600H218V244Q218 179 241.5 143.0Q265 107 316 107Q379 107 413.0 156.0Q447 205 447 276V600H596V0H462V90H438Q423 44 382.5 14.5Q342 -15 271 -15Z\"/><path transform=\"translate(122.17 58.00) scale(0.05354 -0.05354)\" d=\"M76 0V600H211V492H235Q241 521 257.0 547.0Q273 573 307.0 589.5Q341 606 399 606H428V471H387Q301 471 263.0 427.0Q225 383 225 294V0Z\"/><path transform=\"translate(144.90 58.00) scale(0.05354 -0.05354)\" d=\"M162 0Q139 27 125.5 65.0Q112 103 112 179V494H30V600H114V750H259V600H358V494H260V196Q260 116 278.0 74.5Q296 33 321 6V0Z\"/><path transform=\"translate(163.87 58.00) scale(0.05354 -0.05354)\" d=\"M78 0V800H226V366H274L449 600H608V594L397 320L632 6V0H457L274 254H226V0Z\"/><path transform=\"translate(196.60 58.00) scale(0.05354 -0.05354)\" d=\"M280 -13Q198 -13 144.0 27.5Q90 68 63.5 138.5Q37 209 37 301Q37 395 64.0 465.0Q91 535 145.0 574.0Q199 613 280 613Q344 613 384.5 587.5Q425 562 445 522H469V600H606V0H469V78H445Q425 41 385.0 14.0Q345 -13 280 -13ZM317 95Q381 95 419.5 151.0Q458 207 458 300Q458 394 419.5 449.5Q381 505 317 505Q257 505 223.5 453.0Q190 401 190 300Q190 199 223.5 147.0Q257 95 317 95Z\"/></g></svg>",
|
||||
"lockup_s": "<svg class=\"pm\" viewBox=\"0 0 164.20 125.89\" aria-hidden=\"true\" focusable=\"false\"><g transform=\"translate(55.74 0) scale(0.5273) translate(-2 -2)\"><defs><clipPath id=\"c\" clip-rule=\"evenodd\"><path clip-rule=\"evenodd\" d=\"M2 112V42A40 40 0 0 1 42 2H62A40 40 0 0 1 102 42V112Z M63 65a11 11 0 1 0-22 0a11 11 0 1 0 22 0Z\"/></clipPath></defs><g fill=\"none\" stroke=\"currentColor\" stroke-width=\"8\" stroke-linejoin=\"round\"><path d=\"M6 108V42A36 36 0 0 1 42 6H62A36 36 0 0 1 98 42V108Z\"/><path d=\"M52 8V106 M8 65H96 M52 65L4 31.1 M52 65L4 98.9 M52 65L100 98.9\" clip-path=\"url(#c)\"/><path d=\"M52 22H79M52 37H69\" stroke-linecap=\"round\"/><circle cx=\"52\" cy=\"65\" r=\"15\"/></g></g><g fill=\"currentColor\"><path transform=\"translate(0.00 111.76) scale(0.05354 -0.05354)\" d=\"M115 0V494H30V600H115V637Q115 687 132.5 724.0Q150 761 192.0 781.5Q234 802 305 802Q333 802 358 799V695Q344 698 324 698Q287 698 273.5 682.0Q260 666 260 632V600H358V494H260V0Z\"/><path transform=\"translate(18.97 111.76) scale(0.05354 -0.05354)\" d=\"M271 -15Q169 -15 119.0 48.5Q69 112 69 218V600H218V244Q218 179 241.5 143.0Q265 107 316 107Q379 107 413.0 156.0Q447 205 447 276V600H596V0H462V90H438Q423 44 382.5 14.5Q342 -15 271 -15Z\"/><path transform=\"translate(53.21 111.76) scale(0.05354 -0.05354)\" d=\"M76 0V600H211V492H235Q241 521 257.0 547.0Q273 573 307.0 589.5Q341 606 399 606H428V471H387Q301 471 263.0 427.0Q225 383 225 294V0Z\"/><path transform=\"translate(75.93 111.76) scale(0.05354 -0.05354)\" d=\"M162 0Q139 27 125.5 65.0Q112 103 112 179V494H30V600H114V750H259V600H358V494H260V196Q260 116 278.0 74.5Q296 33 321 6V0Z\"/><path transform=\"translate(94.90 111.76) scale(0.05354 -0.05354)\" d=\"M78 0V800H226V366H274L449 600H608V594L397 320L632 6V0H457L274 254H226V0Z\"/><path transform=\"translate(127.64 111.76) scale(0.05354 -0.05354)\" d=\"M280 -13Q198 -13 144.0 27.5Q90 68 63.5 138.5Q37 209 37 301Q37 395 64.0 465.0Q91 535 145.0 574.0Q199 613 280 613Q344 613 384.5 587.5Q425 562 445 522H469V600H606V0H469V78H445Q425 41 385.0 14.0Q345 -13 280 -13ZM317 95Q381 95 419.5 151.0Q458 207 458 300Q458 394 419.5 449.5Q381 505 317 505Q257 505 223.5 453.0Q190 401 190 300Q190 199 223.5 147.0Q257 95 317 95Z\"/></g></svg>",
|
||||
"tab16": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAQCAYAAADJViUEAAAB4klEQVR42o2TPWhTYRSGn/Pdm7Qd/NnqpoPYqIvVguAP7SwUmlRrhw5qrx1dHF0c7OoiFElTOyhOpjFrJ6uIgihSKKYloiBCwSJ00bTJva9DbtubEKHveM77nPN+Bz4joYUgk3PGLYl+oCfR+gt8FJrLFVbLO0UDmL9xrPuQ3/3cIGuwLrQko8dhQxF6ZXI10CDQK3jR3dOYuPKouuUADqe68gYjwP3tTe9otrA6jngicRBRk6Jvkp4iKxtc3aqlZgDs5dSp84qi94iH2bnK3Z1IxckTgTM3S6veGXwQ3AEGXKToOlCv400nXV7kfgBImjazXD3tHcgWKhe2w8YDoCFj3JnUB1Ydm1v5nYQjz44DmNk9SQt+PZwCGJuv/gK+msg4sBSm7SQoMCPqjW/6zAsZ2qzXZtg7cw3o8umgUtCXNyyIR02EHn9uFr4vtfusFGQWDU5j9raZl1RkGrGkCYSsjKPenKeLghU/jplGOtd0mmdtGwSG0Y8UxqU0gB+P/pmdrZzZjT158g2mSwn4da7wZXC3fzvzGYHr9GbfC7OCUkwWUy4a7eTrCA/n1zYs4nEM54fzaxv7hvcrKwWZReAsUGw5kunI3sew9TZuFPjkA8vAAHCtZaoMQWjY5f8sXv4HrfW+WZX2x04AAAAASUVORK5CYII=",
|
||||
"full16": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAQCAYAAADJViUEAAAChUlEQVR42nWTT4jUZRjHP993fr/ZSSSKoFu4UDC/TQNLErrUVQndSaigw2o0oyRG7KkgFAKxS9TFIpp1W4I6eHCmdutSHcwgoaK10FndFkwIRNSD5u7On9/77TA7y4T1PT087/u8z/f7fd5HDKH58paHnHT3AtuwNg7yhtvgX9LEM7s+uvTXIB8GQaNaftWF3gLWdqMzwrPAVuFZxA9BeqrXC5ca1Wz/oEYAjVq2D/OeCOOVqQtnAOZeeuz+7obuTQhvS14BIHrE8qTFoT31i5/p5MHNG9NOfkVmb+XEwuzg1VMT2QMqcl1SE+j2+XseqWW7vqFd3JQUO/HNiEuBpDWsX6GUwyo2p2X+7uRh7oWZ81cBmtXs2HKpsyNER7CWovL5Rq38+qA4KRaSNbvGLb84Enpj6wbKP2E9mgQFsH9Emoxm5lQ1e6aU9w6s5Ms7giDEMLV7+sLnAq+zilpFjKy7Xam3vk1D3CpZ7UJ6OYT4LvBHVP5Oszr2Af+BZG2Oo83a2Bu5QdG/Wq6EGHaOn2h9//VrWx7uLPcWm7XsKqgN4OhRwbU1XdwLbOvrCSWItNPiEkAnp2Mh9c/bQ/f7nQW/Veqt/QY1atmk7GfTbvurL2rln2Ontx3II5x+rt56X+DmK9nHAGpWx45iPyglhyPdadDmQs6hPPFOrIOI47a+FP4Q/Gck31dwcgTpWuhTZTTSOy+FO2maPr77k4U5uve8BUC3dHjPVOubEP0EaClQ+B14BCCJuCx4GnmiUl84yf9gfPribeBAo1b+zvCp8Y2koLAYo88B9/3706+UjK4rWZloVLNVhlYM61whaDGB/CzSk8Dzw53c35l5o1130ZBvQTz7D8VtHXvXpMGjAAAAAElFTkSuQmCC",
|
||||
"banner": " ▄▄▄▄▄▄▄▄▄▄▄▄\n ▄▄████▀▀████▀▀████▄▄\n ▄██▀▀ ██ ▀▀██▄\n ██▀ ██████████ ▀██\n ███ ██ ▀██\n ████▄ ███████ ██\n ██▀▀██▄▄ ██ ██\n ██ ▀▀██▄▄██████▄ ██\n ██ ▀██▀▀ ▀▀██ ██\n ███████████ ███████████\n ██ ▀██▄ ▄██▀ ██\n ██ ▄██████████████▄ ██\n ██ ▄▄██▀▀ ▀██▀ ▀▀██▄▄ ██\n ████▀▀ ██ ▀▀████\n ██▀ ██ ▀██\n ██▄▄▄▄▄▄▄▄▄▄████▄▄▄▄▄▄▄▄▄▄██\n ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀",
|
||||
"color": "#af6428",
|
||||
"ink": "#151515"
|
||||
}
|
||||
|
|
@ -11,13 +11,6 @@ HERE="$(cd "$(dirname "$0")" && pwd)"
|
|||
SRCROOT="${FURTKA_SRCROOT:-/srv/furtka-site}"
|
||||
WEBROOT="${FURTKA_WEBROOT:-/var/www/furtka.org}"
|
||||
|
||||
# The runner job runs as root inside the container; hand the trees back
|
||||
# to the VM user no matter how this script ends, so the manual deploy.sh
|
||||
# path keeps working even after a failed build.
|
||||
if [ "$(id -u)" = 0 ]; then
|
||||
trap 'chown -R "${FURTKA_OWNER:-1000:1000}" "$SRCROOT" "$WEBROOT"' EXIT
|
||||
fi
|
||||
|
||||
echo "==> rsync website/ → $SRCROOT"
|
||||
rsync -az --delete \
|
||||
--exclude='.hugo_build.lock' \
|
||||
|
|
|
|||
|
|
@ -6,13 +6,8 @@ enableRobotsTXT = true
|
|||
|
||||
[params]
|
||||
description = "Open-source home server OS — simple enough for everyone."
|
||||
version = "26.21-alpha"
|
||||
version = "26.20-alpha"
|
||||
contactEmail = "hallo@furtka.org"
|
||||
# Forgejo repo the download page reads its latest release (ISO asset,
|
||||
# size, date, checksum) from at build time. `version` above is only the
|
||||
# fallback when that lookup fails.
|
||||
forgejoURL = "https://forgejo.sourcegate.online"
|
||||
repoPath = "daniel/furtka"
|
||||
|
||||
[markup.goldmark.renderer]
|
||||
unsafe = true
|
||||
|
|
@ -37,12 +32,5 @@ enableRobotsTXT = true
|
|||
[build]
|
||||
writeStats = true
|
||||
|
||||
# The release lookup must be fresh on every build — Hugo's default keeps
|
||||
# remote resources cached forever, which would pin the download page to
|
||||
# whatever release existed on the first build.
|
||||
[caches]
|
||||
[caches.getresource]
|
||||
maxAge = 0
|
||||
|
||||
[minify]
|
||||
minifyOutput = true
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
{{ define "main" }}
|
||||
{{- $r := partialCached "release.html" . "release" -}}
|
||||
{{- $file := path.Base $r.url -}}
|
||||
<article class="download">
|
||||
<header class="dl-hero">
|
||||
<p class="status-chip"><span class="mono">{{ $r.version }}</span></p>
|
||||
<h1>{{ .Title }}</h1>
|
||||
<p class="lede">{{ .Description }}</p>
|
||||
|
||||
<div class="dl-card">
|
||||
<a class="cta cta--primary" href="{{ $r.url }}" download>
|
||||
<svg aria-hidden="true" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v12"/><path d="m7 10 5 5 5-5"/><path d="M5 21h14"/></svg>
|
||||
{{ .Params.button }}
|
||||
</a>
|
||||
<dl class="dl-meta">
|
||||
<div><dt>ISO</dt><dd class="mono">{{ $file }}</dd></div>
|
||||
{{ with $r.size }}<div><dt>{{ $.Params.size_label }}</dt><dd>{{ lang.FormatNumber 1 (div (float .) 1e9) }} GB</dd></div>{{ end }}
|
||||
{{ with $r.date }}<div><dt>{{ $.Params.released }}</dt><dd>{{ time.Format ":date_long" . }}</dd></div>{{ end }}
|
||||
</dl>
|
||||
<p class="dl-host">{{ .Params.host_note }}</p>
|
||||
</div>
|
||||
|
||||
<p class="dl-alpha">{{ .Params.alpha | markdownify }}</p>
|
||||
</header>
|
||||
|
||||
<section class="dl-section">
|
||||
<p class="section-eyebrow">{{ .Params.need_label }}</p>
|
||||
<ul class="dl-needs">
|
||||
{{ range .Params.needs }}<li>{{ . | markdownify }}</li>{{ end }}
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="dl-section">
|
||||
<p class="section-eyebrow">{{ .Params.steps_label }}</p>
|
||||
<ol class="dl-steps">
|
||||
{{ range .Params.steps }}
|
||||
<li class="step-card">
|
||||
<h2>{{ .title }}</h2>
|
||||
<div class="step-body">{{ replace .body "{iso}" $file | markdownify }}</div>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<section class="dl-section">
|
||||
<p class="section-eyebrow">{{ .Params.verify_label }}</p>
|
||||
{{ with $r.sha256 }}
|
||||
<p>{{ $.Params.verify_intro }}</p>
|
||||
<pre class="dl-hash"><code>{{ . }}</code></pre>
|
||||
<pre class="dl-cmds"><code><span class="c"># Linux</span>
|
||||
sha256sum {{ $file }}
|
||||
<span class="c"># macOS</span>
|
||||
shasum -a 256 {{ $file }}
|
||||
<span class="c"># Windows (PowerShell)</span>
|
||||
Get-FileHash {{ $file }}</code></pre>
|
||||
{{ else }}
|
||||
<p class="dl-muted">{{ $.Params.verify_missing }}</p>
|
||||
{{ end }}
|
||||
</section>
|
||||
|
||||
<p class="dl-older"><a href="{{ $r.all }}">{{ .Params.older }} →</a></p>
|
||||
</article>
|
||||
{{ end }}
|
||||
|
|
@ -1,41 +1,23 @@
|
|||
{{ define "main" }}
|
||||
{{- $r := partialCached "release.html" . "release" -}}
|
||||
{{- $dl := "download/" | relLangURL -}}
|
||||
<article class="home">
|
||||
<header class="hero">
|
||||
<p class="status-chip reveal"><span class="mono">{{ $r.version }}</span> — {{ .Params.status_text }}</p>
|
||||
{{ with .Params.status }}
|
||||
<p class="status-chip reveal">{{ . | safeHTML }}</p>
|
||||
{{ end }}
|
||||
<h1 class="reveal">{{ .Title }}</h1>
|
||||
{{ with site.Params.description }}<p class="lede reveal">{{ . }}</p>{{ end }}
|
||||
<p class="cta-row reveal">
|
||||
<a class="cta cta--primary" href="{{ $dl }}">
|
||||
{{ .Params.cta_download }}
|
||||
<a class="cta cta--primary" href="https://forgejo.sourcegate.online/daniel/furtka/releases">
|
||||
{{ if eq site.Language.Lang "de" }}Neuestes Release{{ else }}Latest release{{ end }}
|
||||
<span aria-hidden="true">→</span>
|
||||
</a>
|
||||
<a class="cta cta--ghost" href="{{ site.Params.forgejoURL }}/{{ site.Params.repoPath }}">{{ .Params.cta_source }}</a>
|
||||
</p>
|
||||
{{ with .Params.poll_link }}
|
||||
<p class="reveal"><a class="home-poll" href="{{ . }}">{{ partial "mark-m.html" (dict "class" "" "id" "hm") }}<span>{{ $.Params.poll_text }} →</span></a></p>
|
||||
{{ end }}
|
||||
</header>
|
||||
|
||||
{{ with .Params.intro }}
|
||||
<section class="intro">{{ . | markdownify }}</section>
|
||||
{{ end }}
|
||||
|
||||
{{ with .Params.steps }}
|
||||
<section class="feature-section">
|
||||
{{ with $.Params.steps_label }}<p class="section-eyebrow">{{ . }}</p>{{ end }}
|
||||
<ol class="how-steps">
|
||||
{{ range . }}
|
||||
<li class="how-step" data-gsap="card">
|
||||
<h3>{{ .title }}</h3>
|
||||
<p>{{ .body | markdownify }}</p>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ol>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ if .Params.features_today }}
|
||||
<section class="feature-section">
|
||||
{{ with .Params.features_today_label }}<p class="section-eyebrow">{{ . }}</p>{{ end }}
|
||||
|
|
@ -58,16 +40,6 @@
|
|||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ with .Params.band_title }}
|
||||
<section class="dl-band" data-gsap="card">
|
||||
<div>
|
||||
<h2>{{ . }}</h2>
|
||||
<p>{{ $.Params.band_text }}</p>
|
||||
</div>
|
||||
<a class="cta cta--primary" href="{{ $dl }}">{{ $.Params.cta_download }} <span aria-hidden="true">→</span></a>
|
||||
</section>
|
||||
{{ end }}
|
||||
|
||||
{{ with .Content }}
|
||||
<section class="prose closer">{{ . }}</section>
|
||||
{{ end }}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,6 @@
|
|||
{{- /* Furtka mark (M, small-size tier) — generated by tools/brand-assets.py from logo-assets.py geometry. */ -}}
|
||||
<svg class="gate-mark" width="1em" height="1em" viewBox="0 0 64 64" aria-hidden="true" focusable="false"><path fill="currentColor" fill-rule="evenodd" d="M5 60V27a27 27 0 0 1 54 0v33Z M19.5 60V26A10 10 0 0 1 29.5 16H46v10H32a2.5 2.5 0 0 0-2.5 2.5V32H46v10H29.5v18Z"/></svg>
|
||||
<svg class="gate-mark" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
||||
<path d="M4 20 V12 A9 9 0 0 1 20 12 V20"/>
|
||||
<line x1="12" y1="5" x2="12" y2="20"/>
|
||||
<line x1="3" y1="20" x2="21" y2="20"/>
|
||||
<line x1="15" y1="12" x2="15" y2="14.5"/>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 390 B After Width: | Height: | Size: 384 B |
|
|
@ -1,25 +1,16 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<script>document.documentElement.classList.replace('no-js','js');</script>
|
||||
{{ if eq .Type "poll" }}{{/* Coin-flip which mark sits left/first, so neither side collects the
|
||||
"first thing on the page" votes. Decided before first paint (no reflow), applied by CSS `order`,
|
||||
and kept for the tab session so a reload or a vote doesn't shuffle the page under the visitor. */}}
|
||||
<script>(function(){var k='furtka-logo-order',o=null;try{o=sessionStorage.getItem(k)}catch(e){}if(o!=='mr'&&o!=='rm'){o=Math.random()<0.5?'mr':'rm';try{sessionStorage.setItem(k,o)}catch(e){}}document.documentElement.setAttribute('data-logo-order',o)})();</script>
|
||||
{{ end }}<title>{{ if .IsHome }}{{ site.Title }} — {{ site.Params.description }}{{ else }}{{ .Title }} · {{ site.Title }}{{ end }}</title>
|
||||
<title>{{ if .IsHome }}{{ site.Title }} — {{ site.Params.description }}{{ else }}{{ .Title }} · {{ site.Title }}{{ end }}</title>
|
||||
<meta name="description" content="{{ with .Params.description }}{{ . }}{{ else }}{{ site.Params.description }}{{ end }}">
|
||||
<meta name="theme-color" content="#f7f6f3" media="(prefers-color-scheme: light)">
|
||||
<meta name="theme-color" content="#0d0d0f" media="(prefers-color-scheme: dark)">
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
||||
<meta property="og:site_name" content="{{ site.Title }}">
|
||||
<meta property="og:title" content="{{ if .IsHome }}{{ site.Title }}{{ else }}{{ .Title }} · {{ site.Title }}{{ end }}">
|
||||
<meta property="og:description" content="{{ with .Params.description }}{{ . }}{{ else }}{{ site.Params.description }}{{ end }}">
|
||||
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
|
||||
<meta property="og:url" content="{{ .Permalink }}">
|
||||
{{ with .Params.image | default "/img/brand/social.png" }}<meta property="og:image" content="{{ . | absURL }}">
|
||||
<meta property="og:image:width" content="1200">
|
||||
<meta property="og:image:height" content="630">
|
||||
<meta name="twitter:card" content="summary_large_image">{{ end }}
|
||||
{{ $parts := split .Site.Language.LanguageCode "-" }}<meta property="og:locale" content="{{ index $parts 0 }}{{ if gt (len $parts) 1 }}_{{ upper (index $parts 1) }}{{ end }}">
|
||||
{{ range .AllTranslations }}
|
||||
<link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}">
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
{{- /* Mark M — lowercase f cut out of a gate. 64-unit grid, even-odd knockout. */ -}}
|
||||
<svg class="pm {{ .class }}" viewBox="0 0 64 64" aria-hidden="true" focusable="false"><path fill="currentColor" fill-rule="evenodd" d="M6 60V28a26 26 0 0 1 52 0v32Z M20.0 60V26.5A10.5 10.5 0 0 1 30.5 16H45.0v8.6H32.5a3.5 3.5 0 0 0-3.5 3.5V32h16v8.6H29.0V60Z"/></svg>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
{{- /* Mark R — window, wheel and F. 104x114 grid, stroke 8, hub knocked out. */ -}}
|
||||
<svg class="pm {{ .class }}" viewBox="0 0 104 114" aria-hidden="true" focusable="false"><defs><clipPath id="pm-rc-{{ .id }}" clip-rule="evenodd"><path clip-rule="evenodd" d="M2 112V42A40 40 0 0 1 42 2H62A40 40 0 0 1 102 42V112Z M63 65a11 11 0 1 0-22 0a11 11 0 1 0 22 0Z"/></clipPath></defs><g fill="none" stroke="currentColor" stroke-width="8" stroke-linejoin="round"><path d="M6 108V42A36 36 0 0 1 42 6H62A36 36 0 0 1 98 42V108Z"/><path d="M52 8V106 M8 65H96 M52 65L4 31.1 M52 65L4 98.9 M52 65L100 98.9" clip-path="url(#pm-rc-{{ .id }})"/><path d="M52 22H79M52 37H69" stroke-linecap="round"/><circle cx="52" cy="65" r="15"/></g></svg>
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
{{- /*
|
||||
Latest Furtka release that has an ISO attached, looked up on Forgejo at
|
||||
build time. Returns a dict: version, url (ISO), size (bytes, 0 = unknown),
|
||||
date (time or ""), sha256 ("" when the release has no .iso.sha256), page
|
||||
(release page URL), live (false when the lookup failed and we fell back
|
||||
to site.Params.version). Use via partialCached "release.html" . "release".
|
||||
*/ -}}
|
||||
{{- $repo := printf "%s/%s" site.Params.forgejoURL site.Params.repoPath -}}
|
||||
{{- $v := site.Params.version -}}
|
||||
{{- $out := dict
|
||||
"version" $v
|
||||
"url" (printf "%s/releases/download/%s/furtka-%s.iso" $repo $v $v)
|
||||
"size" 0
|
||||
"date" ""
|
||||
"sha256" ""
|
||||
"page" (printf "%s/releases/tag/%s" $repo $v)
|
||||
"all" (printf "%s/releases" $repo)
|
||||
"live" false
|
||||
-}}
|
||||
{{- $api := printf "%s/api/v1/repos/%s/releases?limit=10" site.Params.forgejoURL site.Params.repoPath -}}
|
||||
{{- with try (resources.GetRemote $api) -}}
|
||||
{{- with .Err -}}
|
||||
{{- warnf "release.html: release lookup failed, using site.Params.version: %s" . -}}
|
||||
{{- else with .Value -}}
|
||||
{{- $done := false -}}
|
||||
{{- range (. | transform.Unmarshal) -}}
|
||||
{{- if and (not $done) (not .draft) -}}
|
||||
{{- $rel := . -}}
|
||||
{{- $iso := "" -}}
|
||||
{{- $sum := "" -}}
|
||||
{{- range .assets -}}
|
||||
{{- if strings.HasSuffix .name ".iso" }}{{ $iso = . }}{{ end -}}
|
||||
{{- if strings.HasSuffix .name ".iso.sha256" }}{{ $sum = . }}{{ end -}}
|
||||
{{- end -}}
|
||||
{{- with $iso -}}
|
||||
{{- $done = true -}}
|
||||
{{- $out = merge $out (dict
|
||||
"version" $rel.tag_name
|
||||
"url" .browser_download_url
|
||||
"size" .size
|
||||
"date" (time.AsTime $rel.published_at)
|
||||
"page" $rel.html_url
|
||||
"live" true) -}}
|
||||
{{- with $sum -}}
|
||||
{{- with try (resources.GetRemote .browser_download_url) -}}
|
||||
{{- with .Value -}}
|
||||
{{- $hash := index (split (trim .Content " \n") " ") 0 -}}
|
||||
{{- if eq (len $hash) 64 }}{{ $out = merge $out (dict "sha256" $hash) }}{{ end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $out -}}
|
||||
|
|
@ -1,183 +0,0 @@
|
|||
{{ define "main" }}
|
||||
{{- $p := .Params -}}
|
||||
{{/* Display order of the two marks; flip via `order: [r, m]` in front matter so neither
|
||||
side gets the "first thing on the page" advantage for the whole poll. */}}
|
||||
{{- $order := $p.order | default (slice "m" "r") -}}
|
||||
{{- $s := $p.show -}}
|
||||
<article class="{{ if $p.closed }}poll-closed{{ else }}poll{{ end }}" data-poll="{{ $p.poll }}" data-api="/api/poll/{{ $p.poll }}">
|
||||
<header class="page-header">
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{ with $p.description }}<p class="lede">{{ . }}</p>{{ end }}
|
||||
</header>
|
||||
{{ with $p.result }}<p class="poll-result" role="status">{{ . | markdownify }}</p>{{ end }}
|
||||
<div class="prose">{{ .Content }}</div>
|
||||
|
||||
{{/* ── Quick vote ─────────────────────────────────────────── */}}
|
||||
<div class="poll-grid" id="vote">
|
||||
{{ range $k := $order }}{{ $d := index site.Data.logo $k }}
|
||||
{{ $c := index $p $k }}
|
||||
{{- $total := 0 }}{{ range $v := $p.final }}{{ $total = add $total $v }}{{ end }}
|
||||
{{- $won := and $p.closed (eq $k (cond (gt (index $p.final "m") (index $p.final "r")) "m" "r")) }}
|
||||
<section class="poll-card{{ if $won }} is-yours{{ end }}" data-choice="{{ $k }}" aria-labelledby="poll-{{ $k }}-title">
|
||||
<div class="poll-art poll-art--{{ $k }}">{{ $d.display | safeHTML }}</div>
|
||||
<h2 id="poll-{{ $k }}-title">{{ $c.title }}</h2>
|
||||
<p class="poll-desc">{{ $c.text }}</p>
|
||||
{{ if $p.closed }}
|
||||
{{ $n := index $p.final $k }}
|
||||
<div class="poll-bar poll-bar--final" aria-hidden="true"><i style="width: {{ div (mul $n 100) $total }}%"></i></div>
|
||||
<p class="poll-count">{{ $n }} / {{ $total }}</p>
|
||||
{{ else }}
|
||||
<button type="button" class="poll-btn" data-vote="{{ $k }}">{{ $p.labels.vote }}</button>
|
||||
<div class="poll-bar" aria-hidden="true"><i></i></div>
|
||||
<p class="poll-count" data-count="{{ $k }}"></p>
|
||||
{{ end }}
|
||||
</section>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ if not $p.closed }}
|
||||
<p class="poll-status" role="status" aria-live="polite"
|
||||
data-t-voted="{{ $p.labels.voted }}"
|
||||
data-t-total="{{ $p.labels.total }}"
|
||||
data-t-error="{{ $p.labels.error }}"
|
||||
data-t-change="{{ $p.labels.change }}">{{ $p.labels.nojs }}</p>
|
||||
{{ end }}
|
||||
|
||||
{{/* ── Showcase ───────────────────────────────────────────── */}}
|
||||
<div class="show">
|
||||
<p class="section-eyebrow show-intro">{{ $s.intro }}</p>
|
||||
|
||||
<section class="show-row">
|
||||
<h2 class="show-h">{{ $s.sizes }}</h2>
|
||||
<p class="show-p">{{ $s.sizes_text }}</p>
|
||||
<div class="show-pair">
|
||||
{{ range $k := $order }}{{ $d := index site.Data.logo $k }}
|
||||
<div class="show-cell show-cell--{{ $k }}">
|
||||
<span class="show-tag">{{ index $p $k "short" }}</span>
|
||||
<div class="sizes">
|
||||
<figure><span class="sz sz-96">{{ $d.flat | safeHTML }}</span><figcaption>96</figcaption></figure>
|
||||
<figure><span class="sz sz-48">{{ $d.flat | safeHTML }}</span><figcaption>48</figcaption></figure>
|
||||
<figure><span class="sz sz-32">{{ $d.min | safeHTML }}</span><figcaption>32</figcaption></figure>
|
||||
<figure><span class="sz sz-24">{{ $d.min | safeHTML }}</span><figcaption>24</figcaption></figure>
|
||||
<figure><img class="px" src="{{ $d.tab16 | safeURL }}" width="16" height="16" alt=""><figcaption>16</figcaption></figure>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="show-row">
|
||||
<h2 class="show-h">{{ $s.name }}</h2>
|
||||
<p class="show-p">{{ $s.name_text }}</p>
|
||||
<div class="show-pair">
|
||||
{{ range $k := $order }}{{ $d := index site.Data.logo $k }}
|
||||
<div class="show-cell show-cell--{{ $k }}">
|
||||
<span class="show-tag">{{ index $p $k "short" }}</span>
|
||||
<div class="lock lock-h">{{ $d.lockup_h | safeHTML }}</div>
|
||||
<div class="lock lock-s">{{ $d.lockup_s | safeHTML }}</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="show-row">
|
||||
<h2 class="show-h">{{ $s.browser }}</h2>
|
||||
<p class="show-p">{{ $s.browser_text }}</p>
|
||||
<div class="show-pair">
|
||||
{{ range $k := $order }}{{ $d := index site.Data.logo $k }}
|
||||
<div class="show-cell show-cell--{{ $k }}">
|
||||
<span class="show-tag">{{ index $p $k "short" }}</span>
|
||||
<div class="mock">
|
||||
<div class="tabbar"><span class="tab"><img class="px" src="{{ $d.tab16 | safeURL }}" width="16" height="16" alt="">Furtka</span></div>
|
||||
<div class="urlbar">https://furtka.org</div>
|
||||
<div class="uihead"><span class="uihead-mark">{{ $d.flat | safeHTML }}</span><span class="uihead-name">Furtka</span><span class="uihead-nav"><span>{{ $s.nav1 }}</span><span>{{ $s.nav2 }}</span></span></div>
|
||||
<div class="uibody"><i></i><i class="s"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="show-row">
|
||||
<h2 class="show-h">{{ $s.phone }}</h2>
|
||||
<p class="show-p">{{ $s.phone_text }}</p>
|
||||
<div class="show-pair">
|
||||
{{ range $k := $order }}{{ $d := index site.Data.logo $k }}
|
||||
<div class="show-cell show-cell--{{ $k }}">
|
||||
<span class="show-tag">{{ index $p $k "short" }}</span>
|
||||
<div class="tiles"><img src="/img/logo/{{ $k }}/tile.png" width="96" height="96" alt=""><img src="/img/logo/{{ $k }}/tile-round.png" width="96" height="96" alt=""></div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="show-row">
|
||||
<h2 class="show-h">{{ $s.box }}</h2>
|
||||
<p class="show-p">{{ $s.box_text }}</p>
|
||||
<div class="show-pair">
|
||||
{{ range $k := $order }}{{ $d := index site.Data.logo $k }}
|
||||
<div class="show-cell show-cell--{{ $k }}">
|
||||
<span class="show-tag">{{ index $p $k "short" }}</span>
|
||||
<pre class="term"><i>{{ $d.banner }}</i>
|
||||
|
||||
<b>Furtka is ready.</b> Open http://furtka.local</pre>
|
||||
<img class="shot" src="/img/logo/{{ $k }}/splash.png" width="960" height="540" alt="">
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="show-row">
|
||||
<h2 class="show-h">{{ $s.shared }}</h2>
|
||||
<p class="show-p">{{ $s.shared_text }}</p>
|
||||
<div class="show-pair">
|
||||
{{ range $k := $order }}{{ $d := index site.Data.logo $k }}
|
||||
<div class="show-cell show-cell--{{ $k }}">
|
||||
<span class="show-tag">{{ index $p $k "short" }}</span>
|
||||
<img class="shot" src="/img/logo/{{ $k }}/social.png" width="600" height="315" alt="">
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="show-row">
|
||||
<h2 class="show-h">{{ $s.colour }}</h2>
|
||||
<p class="show-p">{{ $s.colour_text }}</p>
|
||||
<div class="show-pair">
|
||||
{{ range $k := $order }}{{ $d := index site.Data.logo $k }}
|
||||
<div class="show-cell show-cell--{{ $k }}">
|
||||
<span class="show-tag">{{ index $p $k "short" }}</span>
|
||||
<div class="grounds">
|
||||
<span class="ground" style="background:#f7f6f3;color:{{ $d.color }}">{{ $d.flat | safeHTML }}</span>
|
||||
<span class="ground" style="background:{{ $d.ink }};color:{{ $d.color }}">{{ $d.flat | safeHTML }}</span>
|
||||
<span class="ground" style="background:{{ $d.color }};color:#f7f6f3">{{ $d.flat | safeHTML }}</span>
|
||||
<span class="ground ground--fg">{{ $d.flat | safeHTML }}</span>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
{{/* ── Vote again at the end ─────────────────────────────── */}}
|
||||
{{ if not $p.closed }}
|
||||
<section class="poll-final">
|
||||
<h2 class="show-h">{{ $s.final }}</h2>
|
||||
<div class="poll-final-row">
|
||||
{{ range $k := $order }}{{ $d := index site.Data.logo $k }}
|
||||
<div class="poll-final-card" data-choice="{{ $k }}">
|
||||
<span class="poll-final-mark show-cell--{{ $k }}">{{ $d.flat | safeHTML }}</span>
|
||||
<button type="button" class="poll-btn" data-vote="{{ $k }}">{{ $p.labels.vote }} — {{ index $p $k "short" }}</button>
|
||||
<div class="poll-bar" aria-hidden="true"><i></i></div>
|
||||
<p class="poll-count" data-count="{{ $k }}"></p>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</section>
|
||||
<p class="poll-note">{{ $p.labels.note | safeHTML }}</p>
|
||||
{{ end }}
|
||||
</article>
|
||||
{{ if not $p.closed }}
|
||||
{{ $js := resources.Get "js/poll.js" | minify | fingerprint }}
|
||||
<script defer src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}"></script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
|
|
@ -1 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><style>svg{color:#c03a28}@media (prefers-color-scheme:dark){svg{color:#ff6b56}}</style><path fill="currentColor" fill-rule="evenodd" d="M5 60V27a27 27 0 0 1 54 0v33Z M19.5 60V26A10 10 0 0 1 29.5 16H46v10H32a2.5 2.5 0 0 0-2.5 2.5V32H46v10H29.5v18Z"/></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#a33e2e" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M4 20 V12 A9 9 0 0 1 20 12 V20"/>
|
||||
<line x1="12" y1="5" x2="12" y2="20"/>
|
||||
<line x1="3" y1="20" x2="21" y2="20"/>
|
||||
<line x1="15" y1="12" x2="15" y2="14.5"/>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 334 B |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |