Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

One-line installer for Debian 13 (tools/install/install.sh): checks, SHA-256 verification, display manager switch, uninstall; docs

Federico Pereiradcc21ce58839
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d24407a..d0932fe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -83,6 +83,9 @@ architecture and dependency policy are in `docs/ARCHITECTURE.md`.
shown in About.
- English only: code, comments and documentation are now in English (UI text stays translated in
`assets/locales/`).
+- One-line installer for an existing Debian 13 system (`curl -fsSL https://lordos.org/install.sh | sh`,
+ `tools/install/install.sh`, `docs/INSTALL-DEBIAN.md`): SHA-256 check, apt install, the ISO's
+ setup, display manager switch and `--uninstall`. Tested in containers; a real-machine run is pending.
### Known gaps
diff --git a/docs/INSTALL-DEBIAN.md b/docs/INSTALL-DEBIAN.md
new file mode 100644
index 0000000..8020fec
--- /dev/null
+++ b/docs/INSTALL-DEBIAN.md
@@ -0,0 +1,212 @@
+# Installing LordOS on Debian 13
+
+LordOS can be added to a Debian 13 (trixie) system that is already installed, instead of booting the
+ISO. The installer downloads the LordOS package from the GitHub release, installs it with apt, and
+sets the system up the way the ISO does (`ISO.md`): LordOS's own login screen on tty1, its
+services, and the user's groups.
+
+```sh
+curl -fsSL https://lordos.org/install.sh | sh
+```
+
+The script asks before changing anything. It reads the answers from the terminal (`/dev/tty`), so
+this works even though the script itself comes through a pipe.
+
+> **Status (2026-10-18):** the repository is private until the first beta, so the download from
+> GitHub doesn't work publicly yet. Until then, use `--deb` with a package you already have (see
+> [Testing](#testing)).
+
+## Requirements
+
+| | |
+|---|---|
+| System | Debian 13 (trixie). A derivative based on trixie (`ID_LIKE=debian`) works, with a warning: only Debian itself is tested. |
+| Architecture | `amd64` or `arm64`. On a Raspberry Pi 5 the [Raspberry Pi image](RASPBERRY.md) is the recommended path (tested kernel and boot setup); the installer says so and continues. |
+| Rights | root, or a user who can use `sudo` |
+| Disk | at least 2 GB free on `/var` (the package plus the dependencies apt pulls in) |
+| Init | systemd running (Debian's default) |
+| Network | to download the release and the Debian dependencies |
+
+## What it does
+
+1. **Checks** the points above and shows what it is going to do. Nothing changes until you answer `y`.
+2. **Downloads** `SHA256SUMS` and `lordos_<version>_<arch>.deb` from the GitHub release
+ (`https://github.com/lordbasex/LordOS/releases`), by default the latest one. The latest
+ release is looked up through the GitHub API; since betas are marked as pre-releases, which
+ `releases/latest` skips, it falls back to the newest release of any kind.
+3. **Verifies** the `.deb`'s SHA-256 against `SHA256SUMS`. A mismatch stops everything.
+ - **Signature:** LordOS has no release-signing key yet, so `SHA256SUMS` itself is not signed.
+ The installer says so in its output: the checksum catches a corrupted download, not a
+ tampered release. The Ed25519 check is already written and switches on once the key is added
+ (`SIGNING.md`, "Release files").
+4. **Installs** with `apt-get install ./lordos_<version>_<arch>.deb`, so the dependencies come from
+ your Debian mirrors. It also installs, if they are missing, what the ISO adds for sound, fonts
+ and the user session (`dbus-user-session`, PipeWire with `pipewire-pulse`, `pipewire-alsa` and
+ WirePlumber, `rtkit`, `alsa-ucm-conf`, the Noto and DejaVu fonts, `libthai-data`,
+ `shared-mime-info`). `--no-extras` skips those. (LordOS's own package engine is for apps
+ inside LordOS; a local `.deb` on Debian goes through apt, as usual.)
+5. **Sets up LordOS** like the ISO:
+ - creates the `lordos-greeter` system user (the login screen's user) if it doesn't exist;
+ - adds your user (the one who ran `sudo`, or `--user NAME`) to whichever of these groups exist:
+ `audio video input render lpadmin pipewire plugdev`. It does **not** add anyone to `sudo`;
+ - generates the `en_US`, `es_ES` and `pt_BR` UTF-8 locales (the languages the interface ships).
+ Your system language is not changed;
+ - writes `/etc/lordos/session.conf` with an empty `AUTOLOGIN=`: the login screen, no automatic
+ login (Settings → Users changes it). An existing file is kept;
+ - enables `lord-netperm` (per-app network permissions) and `lord-fand` (fans);
+ - **display manager:** if GDM, SDDM, LightDM or another display manager is set as
+ `display-manager.service`, it asks whether to disable it. If you say yes, it is disabled (not
+ removed), `lordos.service` is enabled and `getty@tty1` is masked: at the next boot LordOS shows
+ its login screen on tty1. The other text consoles stay (Ctrl+Alt+F2). If you say no (or pass
+ `--keep-display-manager`), LordOS is installed but not enabled at boot, and the final message
+ shows the commands to switch later;
+ - enables linger for your user, so their PipeWire starts with the system (as on the installed ISO);
+ - enables the PipeWire user units globally (Debian's packages already do this).
+6. **Doesn't touch:**
+ - **the network.** NetworkManager, ifupdown and systemd-networkd keep their interfaces:
+ `lord-netd` shows them as system interfaces and doesn't run DHCP or Wi-Fi on them
+ (`NETWORK.md`). Only interfaces nobody manages get LordOS's DHCP;
+ - **remote desktop**, which stays off (port 5673 closed; Settings → Sharing turns it on);
+ - your home folder and your current desktop session. The display manager is only disabled for
+ the next boot; nothing is stopped while you are using it.
+7. **Prints** what changed, how to start LordOS and how to uninstall.
+
+What it changed is recorded in `/var/lib/lordos-installer/state`, so `--uninstall` undoes exactly
+that. No telemetry: the only requests go to `api.github.com`, `github.com` and your apt mirrors.
+
+### Starting LordOS
+
+- **Reboot** (`sudo reboot`): the LordOS login screen appears.
+- Or, if no display manager is running, from a text console: `sudo systemctl start lordos`. If GDM
+ or another display manager is still running your session, reboot instead: both want tty1 and the
+ graphics card.
+
+## Options
+
+```sh
+curl -fsSL https://lordos.org/install.sh | sh -s -- [options]
+```
+
+| Option | |
+|---|---|
+| `-y`, `--yes` | don't ask (also `LORDOS_YES=1`). With it, the display manager **is** disabled; add `--keep-display-manager` to avoid that |
+| `--version X` | install release `X` (`0.7.0-beta` or `v0.7.0-beta`) instead of the latest |
+| `--deb FILE` | install a local `.deb`. If a `SHA256SUMS` is next to it, it is checked; otherwise the output says the checksum was not verified |
+| `--user NAME` | the user to set up (default: the user who ran `sudo`; as plain root with no `sudo`, nobody) |
+| `--keep-display-manager` | leave the current display manager enabled; LordOS is not enabled at boot |
+| `--no-extras` | don't install the extra sound and font packages |
+| `--no-systemd-check` | continue without a running systemd (containers, chroots): services, display manager, getty and linger are skipped. Detected automatically in Docker/Podman |
+| `--uninstall` | remove LordOS and restore the previous login setup |
+| `--purge` | with `--uninstall`: purge the package and its files in `/etc` |
+| `-h`, `--help` | help |
+
+## Uninstalling
+
+```sh
+curl -fsSL https://lordos.org/install.sh | sh -s -- --uninstall
+```
+
+It asks first, then:
+
+- disables `lordos.service` and `lord-netperm` (the package's `prerm` gives the fans back to the
+ kernel and disables `lord-fand`);
+- unmasks `getty@tty1`;
+- enables the previous display manager again. Without a record (LordOS installed by hand), it
+ offers the first display manager it finds installed (`gdm3`, `sddm`, `lightdm`, …);
+- removes the package (`apt-get remove`; `--purge` for `apt-get purge`);
+- removes your user from the groups **the installer added** (not the ones you already had), turns
+ off the linger it turned on, deletes `/etc/lordos/session.conf` and the `lordos-greeter` user if
+ it created them.
+
+Your home folder and `~/.config/lordos` are kept. The dependencies apt pulled in stay installed;
+`sudo apt autoremove` removes them. Reboot to get your previous login screen back.
+
+### Switching back without uninstalling
+
+```sh
+sudo systemctl disable lordos.service
+sudo systemctl unmask [email protected]
+sudo systemctl enable gdm3 # or sddm, lightdm…
+sudo reboot
+```
+
+## Troubleshooting
+
+| Symptom | What to do |
+|---|---|
+| `no terminal to ask "Continue?"` | The script runs without a terminal (CI, `ssh host 'curl … \| sh'`). Use `ssh -t`, or `--yes`. |
+| `could not find the latest LordOS release on GitHub` | No connection to `api.github.com`, the GitHub API rate limit (60 requests/hour per IP), or the repository is still private. Pass `--version 0.7.0-beta`, or download the files and use `--deb`. |
+| `SHA-256 mismatch` | The download is corrupted or incomplete. Run it again; if it persists, report it: nothing was installed. |
+| `the SHA256SUMS signature is NOT valid` | (once releases are signed) Don't install; report it. |
+| `apt-get could not install LordOS` | Usually a broken apt state or mirrors that aren't trixie. `sudo apt-get update && sudo apt-get -f install`, then run the installer again. |
+| `LordOS needs Debian 13 (trixie)` | Debian 12 and testing/unstable are not supported: the package depends on trixie's library versions. |
+| Black screen or back to text after the reboot | Switch to tty2 (Ctrl+Alt+F2), log in, and look at `journalctl -b -u lordos`. To go back to your desktop meanwhile, see "Switching back" above. |
+| The previous desktop still appears | The display manager was kept (`--keep-display-manager` or "no" to the question). Disable it as shown in the final message. |
+| No sound | Log out and in again (the new groups and linger apply on the next login), and check `systemctl --user status pipewire wireplumber`. |
+| Network changed | It shouldn't: interfaces managed by NetworkManager, ifupdown or systemd-networkd are left alone. If an interface nobody managed now has a DHCP address, that is LordOS's DHCP (`NETWORK.md`); Settings → Network turns it off. |
+
+## For maintainers
+
+- **The canonical copy is `tools/install/install.sh`.** The website serves it at
+ `https://lordos.org/install.sh`, and **that file must stay byte-identical to the one in the
+ release tag** (`git show v0.7.0-beta:tools/install/install.sh | sha256sum` against
+ `curl -fsSL https://lordos.org/install.sh | sha256sum`). Change the script here, tag, then copy it
+ to the website, never the other way round.
+- POSIX `sh` with `set -eu`; everything is inside `main()`, called on the last line, so a truncated
+ download runs nothing. Commands that could read standard input (apt, dpkg) get `</dev/null`,
+ because under `curl | sh` standard input is the script.
+- `shellcheck -s sh tools/install/install.sh` must be clean (also `-s dash`, Debian's `/bin/sh`).
+- Release layout the script expects: tag `vX`, assets `SHA256SUMS` (`sha256sum` format), the
+ `lordos_<version>_<arch>.deb` files listed in it (the version inside the name doesn't have to match
+ the tag), and later `SHA256SUMS.sig`.
+
+### Testing
+
+Test-only environment variables:
+
+- `LORDOS_BASE_URL`: where the release files are, instead of
+ `https://github.com/lordbasex/LordOS/releases/download/<tag>` (for example `file:///srv/rel`; use it
+ with `--version` so the GitHub API is not asked). It lifts the https-only restriction.
+- `LORDOS_PUBKEY_FILE`: a PEM public key used instead of `RELEASE_PUBKEY_PEM`, to exercise the
+ signature check with a throwaway key.
+
+Done on 2026-10-18 on the development Mac with Docker (`debian:trixie`, amd64) and the
+`lordos_0.7.0_amd64.deb` built on VM 116 (sha256 `4684f1e9…147ffee`):
+
+| Test | Result |
+|---|---|
+| `cat install.sh \| sh -s -- --yes --deb …` as root, no systemd | OK: apt pulled the dependencies; greeter user, groups, locales, `session.conf`; systemd steps skipped with a warning |
+| The same as a sudo user (`bob`), with the user detected from `sudo` | OK |
+| Download from a local release (`LORDOS_BASE_URL=file://…`, `--version 0.7.0-beta`) | OK; the output says the signature was not checked |
+| Signature with a throwaway key: valid / signed by another key / no `.sig` | installs / stops before downloading the `.deb` / stops |
+| `SHA256SUMS` with a wrong hash | stops: "SHA-256 mismatch", nothing installed |
+| `--deb` with a `SHA256SUMS` next to it | checked |
+| Latest release through the GitHub API (repository private) | clear error suggesting `--version`/`--deb` |
+| Debian 12 `os-release` / a trixie-based derivative | refused / warning and continues |
+| A `.deb` for the other architecture, an unknown option, no terminal without `--yes` | refused with a clear message |
+| systemd as PID 1 in a privileged container, with a fake `lightdm.service` as `display-manager.service` | lightdm disabled, `lordos`/`lord-netperm`/`lord-fand` enabled, `getty@tty1` masked, linger on; `--uninstall` re-enabled lightdm (alias restored), unmasked getty, turned linger off, removed groups and the greeter user |
+| The same with answers typed on a pseudo-terminal while the script comes from a pipe | "no" to the display manager leaves it enabled and `lordos.service` disabled; "no" to "Continue?" changes nothing |
+| No display manager | `lordos` enabled, `getty@tty1` masked, the final message offers `systemctl start lordos` |
+| `--uninstall --purge` with the state file deleted | still finds and re-enables lightdm, unmasks getty, keeps the greeter user (not created by the installer) |
+| `shellcheck -s sh` and `-s dash` | clean |
+
+### Still to test on a real Debian 13 machine
+
+No free Debian 13 VM was available (the ISO work uses VMs 116, 117 and 120). Manual plan, on a fresh
+Debian 13 VM with a desktop (GNOME, which brings GDM and NetworkManager) and one without (server
+install, ifupdown):
+
+1. `curl -fsSL https://lordos.org/install.sh | sh` (or `sh install.sh --deb lordos_…_amd64.deb`
+ from a copy) as a sudo user, from inside the GNOME session. Answer "y" to both questions. The
+ running GNOME session must keep working until the reboot.
+2. `sudo reboot`: the LordOS login screen appears on tty1; log in with your Debian password. Check:
+ sound (Settings → Sound, `pw-cli info 0`), network unchanged (`nmcli device` still shows
+ NetworkManager managing the interface; no second DHCP client: `ps aux | grep -i dhcp`), Settings →
+ Sharing shows remote desktop off, `ss -ltn | grep 5673` is empty, Ctrl+Alt+F2 gives a text login.
+3. `systemctl status lordos lord-netperm lord-fand` are active; `journalctl -b -u lordos` has no errors.
+4. On the server install: run the installer from tty1 over the console, then `sudo systemctl start
+ lordos` without rebooting; then reboot and check ifupdown still owns `eth0`.
+5. `curl … | sh -s -- --uninstall`, reboot: GDM comes back with GNOME; on the server, the text login
+ on tty1.
+6. Repeat 1–5 on arm64 (a Raspberry Pi 5 with Raspberry Pi OS trixie, or an arm64 VM), where the
+ installer must warn that the image is the recommended path.
diff --git a/docs/SIGNING.md b/docs/SIGNING.md
index 3845f28..dccd1c1 100644
--- a/docs/SIGNING.md
+++ b/docs/SIGNING.md
@@ -66,7 +66,7 @@ They are shown in the Store and in the install dialog:
| | |
|---|---|
-| ![unsigned](m8-firma-sinfirma.png) | ![revoked](m8-firma-revocada.png) |
+| ![unsigned](signing-unsigned.png) | ![revoked](signing-revoked.png) |
| An unsigned package warns before installing | A revoked package is not installed, with a clear message |
## Rules
@@ -91,7 +91,7 @@ They are shown in the Store and in the install dialog:
| | |
|---|---|
-| ![modified by you](m8-firma-modificada.png) | ![restored](m8-firma-restaurada.png) |
+| ![modified by you](signing-modified.png) | ![restored](signing-restored.png) |
| "Modified by you": what changed, Restore and Share | "Fractal restored to the original" |
## Tools (`tools/lpk.mjs`)
@@ -121,6 +121,31 @@ one, the **development** key:
For a public release, the final key is added to `keys.h` and the development one is removed.
+### Release files (not signed yet)
+
+The GitHub release files (the `.deb`, the ISO, the Raspberry Pi image) are listed with their
+SHA-256 in `SHA256SUMS`. The Debian installer (`tools/install/install.sh`, see
+`INSTALL-DEBIAN.md`) always checks the `.deb` against it. **`SHA256SUMS` itself is not signed
+yet**, so that check catches corrupted downloads but not a tampered release page; the installer
+says so in its output.
+
+The verification side is already in the installer, waiting for a key:
+
+- `SHA256SUMS.sig` = base64 of the 64-byte Ed25519 signature over the exact bytes of `SHA256SUMS`;
+- the public key goes in `RELEASE_PUBKEY_PEM` in `install.sh` (PEM, as OpenSSL 3 reads it). From a
+ raw hex key like `packaging/keys/lordos-dev.pub`:
+ `printf '302a300506032b6570032100%s' "$(cat key.pub)" | xxd -r -p | openssl pkey -pubin -inform DER`;
+- when the key is set, a missing or invalid signature stops the install before the `.deb` is
+ downloaded (tested with a throwaway key through `LORDOS_PUBKEY_FILE`, a test-only override).
+
+TODO(release-signing), before the first public release:
+
+1. Generate the release key offline and keep the private half off the build VMs.
+2. Sign: `openssl pkeyutl -sign -rawin -inkey release.key.pem -in SHA256SUMS | base64 -w0 > SHA256SUMS.sig`,
+ and upload `SHA256SUMS.sig` with the release.
+3. Put the public key in `RELEASE_PUBKEY_PEM`, and publish its fingerprint on the website and in
+ the README, so people who download the ISO by hand can check `SHA256SUMS.sig` too.
+
## Files
| Path | What it is |
diff --git a/tools/install/install.sh b/tools/install/install.sh
new file mode 100755
index 0000000..491d6e3
--- /dev/null
+++ b/tools/install/install.sh
@@ -0,0 +1,724 @@
+#!/bin/sh
+# LordOS installer for an existing Debian 13 (trixie) system.
+#
+# curl -fsSL https://lordos.org/install.sh | sh
+# curl -fsSL https://lordos.org/install.sh | sh -s -- --uninstall
+#
+# Canonical copy: tools/install/install.sh in https://github.com/lordbasex/LordOS.
+# https://lordos.org/install.sh must stay byte-identical to the file in the release tag.
+# Documentation: docs/INSTALL-DEBIAN.md. No telemetry: the only network requests are to
+# api.github.com (to find the latest release), github.com (the release files) and the
+# Debian mirrors that apt already uses.
+#
+# Everything lives inside main(), called on the last line, so a truncated download runs nothing.
+set -eu
+
+INSTALLER_VERSION=1
+REPO="lordbasex/LordOS"
+API_URL="https://api.github.com/repos/$REPO"
+DL_URL="https://github.com/$REPO/releases/download"
+STATE_DIR=/var/lib/lordos-installer
+STATE_FILE=$STATE_DIR/state
+SESSION_CONF=/etc/lordos/session.conf
+GREETER_USER=lordos-greeter
+# groups of the live ISO's user (tools/iso/build.sh), added only when they exist; sudo is not added
+USER_GROUPS="audio video input render lpadmin pipewire plugdev"
+# what the ISO adds beyond the package's Depends/Recommends for sound, fonts and the session bus
+EXTRA_PKGS="dbus-user-session pipewire pipewire-pulse pipewire-alsa wireplumber rtkit alsa-ucm-conf
+ fonts-noto-core fonts-noto-color-emoji fonts-dejavu-core libthai-data shared-mime-info"
+# locales the interface ships translations for (en is the default); only generated, never selected
+LOCALES="en_US.UTF-8 es_ES.UTF-8 pt_BR.UTF-8"
+KNOWN_DMS="gdm3 gdm sddm lightdm lxdm xdm slim nodm greetd ly"
+
+# Ed25519 public key that signs SHA256SUMS (SHA256SUMS.sig = base64 of the 64-byte signature).
+# TODO(release-signing): LordOS has no release-signing key yet (docs/SIGNING.md, "Release files").
+# While this is empty only the SHA-256 checksum is verified, and the installer says so.
+RELEASE_PUBKEY_PEM=""
+
+# ---------------------------------------------------------------- output
+
+setup_colors() {
+ if [ -t 1 ] && [ -z "${NO_COLOR:-}" ] && [ "${TERM:-dumb}" != dumb ]; then
+ C_B=$(printf '\033[1m'); C_R=$(printf '\033[31m'); C_G=$(printf '\033[32m')
+ C_Y=$(printf '\033[33m'); C_C=$(printf '\033[36m'); C_0=$(printf '\033[0m')
+ else
+ C_B=""; C_R=""; C_G=""; C_Y=""; C_C=""; C_0=""
+ fi
+}
+say() { printf '%s\n' "$*"; }
+step() { printf '%s==>%s %s%s%s\n' "$C_C" "$C_0" "$C_B" "$*" "$C_0"; }
+ok() { printf ' %sok%s %s\n' "$C_G" "$C_0" "$*"; }
+warn() { printf '%swarning:%s %s\n' "$C_Y" "$C_0" "$*" >&2; }
+die() { printf '%serror:%s %s\n' "$C_R" "$C_0" "$*" >&2; exit 1; }
+
+CHANGES=""
+changed() { CHANGES="$CHANGES
+ - $*"; }
+
+usage() {
+ cat <<EOF
+LordOS installer for Debian 13 (trixie), version $INSTALLER_VERSION
+
+Usage:
+ curl -fsSL https://lordos.org/install.sh | sh
+ curl -fsSL https://lordos.org/install.sh | sh -s -- [options]
+ sh install.sh [options]
+
+Options:
+ -y, --yes do not ask for confirmation (also LORDOS_YES=1)
+ --version X install release X (for example 0.7.0-beta); default: the latest
+ --deb FILE install a local lordos_<version>_<arch>.deb instead of downloading;
+ a SHA256SUMS file next to it is verified when present
+ --user NAME the user to set up (default: the user who ran sudo)
+ --keep-display-manager do not disable the current display manager (LordOS is not
+ enabled at boot then; see the final message)
+ --no-extras do not install the extra sound/font packages the ISO has
+ --no-systemd-check continue without a running systemd (containers, chroots):
+ the systemd steps are skipped
+ --uninstall remove LordOS and restore the previous login setup
+ --purge with --uninstall: purge the package and its /etc files
+ -h, --help this help
+EOF
+}
+
+# ---------------------------------------------------------------- helpers
+
+as_root() {
+ if [ "$(id -u)" -eq 0 ]; then "$@"; else sudo "$@"; fi
+}
+
+# yes/no question read from the terminal, so it works under curl | sh; $2 is the --yes answer
+ask() {
+ if [ "$ASSUME_YES" = 1 ]; then return "${2:-0}"; fi
+ # a subshell: a failed redirection on ":" would end the whole script
+ if ! (: </dev/tty) 2>/dev/null; then
+ die "no terminal to ask \"$1\"; run again with --yes (or LORDOS_YES=1)"
+ fi
+ printf '%s%s%s [y/N] ' "$C_B" "$1" "$C_0" >/dev/tty
+ read -r answer </dev/tty || answer=""
+ case "$answer" in y|Y|yes|YES|Yes) return 0 ;; *) return 1 ;; esac
+}
+
+os_field() {
+ sed -n "s/^$1=//p" /etc/os-release 2>/dev/null | head -n 1 | sed 's/^"//; s/"$//'
+}
+
+in_container() {
+ if command -v systemd-detect-virt >/dev/null 2>&1 && systemd-detect-virt -cq 2>/dev/null; then return 0; fi
+ [ -f /.dockerenv ] || [ -f /run/.containerenv ]
+}
+
+user_in_group() { id -nG "$1" 2>/dev/null | tr ' ' '\n' | grep -qx "$2"; }
+
+state_get() {
+ [ -r "$STATE_FILE" ] || return 0
+ sed -n "s/^$1=//p" "$STATE_FILE" | tail -n 1
+}
+
+state_set() {
+ as_root mkdir -p "$STATE_DIR"
+ if [ -f "$STATE_FILE" ]; then
+ as_root sed -i "/^$1=/d" "$STATE_FILE"
+ fi
+ printf '%s=%s\n' "$1" "$2" | as_root tee -a "$STATE_FILE" >/dev/null
+}
+
+has_systemd() { [ "$NO_SYSTEMD" = 0 ]; }
+
+# the unit behind display-manager.service (gdm3.service, sddm.service, ...), or nothing
+current_dm() {
+ link=""
+ if [ -L /etc/systemd/system/display-manager.service ]; then
+ link=$(readlink /etc/systemd/system/display-manager.service)
+ fi
+ if [ -z "$link" ] && command -v systemctl >/dev/null 2>&1; then
+ link=$(systemctl show -p Id --value display-manager.service 2>/dev/null || true)
+ [ "$link" = display-manager.service ] && link=""
+ fi
+ [ -n "$link" ] && basename "$link"
+ return 0
+}
+
+unit_exists() {
+ # sh has no local variables: a name of its own so callers' loop variables survive
+ for _ue_dir in /etc/systemd/system /usr/lib/systemd/system /lib/systemd/system; do
+ [ -e "$_ue_dir/$1" ] && return 0
+ done
+ return 1
+}
+
+fetch() {
+ # $1 url, $2 output file; https only unless LORDOS_BASE_URL points somewhere else (tests)
+ if [ -n "${LORDOS_BASE_URL:-}" ]; then
+ curl -fsSL --retry 3 -o "$2" "$1"
+ else
+ curl -fsSL --proto '=https' --tlsv1.2 --retry 3 -o "$2" "$1"
+ fi
+}
+
+# ---------------------------------------------------------------- checks
+
+check_os() {
+ [ -r /etc/os-release ] || die "cannot read /etc/os-release: this does not look like Debian 13"
+ os_id=$(os_field ID); like=$(os_field ID_LIKE); code=$(os_field VERSION_CODENAME)
+ dcode=$(os_field DEBIAN_CODENAME); name=$(os_field PRETTY_NAME)
+ if [ "$os_id" = debian ] && [ "$code" = trixie ]; then
+ ok "system: $name"
+ return
+ fi
+ case " $like " in
+ *" debian "*)
+ if [ "$code" = trixie ] || [ "$dcode" = trixie ]; then
+ warn "$name is a Debian derivative, not Debian itself. LordOS is tested on Debian 13 (trixie) only; continuing."
+ return
+ fi ;;
+ esac
+ die "LordOS needs Debian 13 (trixie); this system is ${name:-unknown} (ID=$os_id, VERSION_CODENAME=${code:-none})."
+}
+
+check_arch() {
+ command -v dpkg >/dev/null 2>&1 || die "dpkg is missing: this is not a Debian system"
+ ARCH=$(dpkg --print-architecture)
+ case "$ARCH" in
+ amd64|arm64) ok "architecture: $ARCH" ;;
+ *) die "LordOS is built for amd64 and arm64 only; this system is $ARCH." ;;
+ esac
+ model=""
+ if [ -r /proc/device-tree/model ]; then model=$(tr -d '\000' </proc/device-tree/model); fi
+ case "$model" in
+ *"Raspberry Pi 5"*)
+ warn "This is a $model. The LordOS Raspberry Pi image is the recommended way to run it there (it brings the tested kernel and boot configuration); continuing with the package." ;;
+ esac
+}
+
+check_root() {
+ if [ "$(id -u)" -eq 0 ]; then
+ ok "running as root"
+ return
+ fi
+ command -v sudo >/dev/null 2>&1 || die "run this as root, or install sudo and add your user to the sudo group"
+ say " Some steps need administrator rights; sudo may ask for your password."
+ sudo true || die "sudo did not grant administrator rights"
+ ok "administrator rights through sudo"
+}
+
+check_disk() {
+ free_kb=$(df -Pk /var 2>/dev/null | awk 'NR == 2 { print $4 }')
+ [ -n "$free_kb" ] || { warn "could not measure the free disk space"; return; }
+ if [ "$free_kb" -lt 2097152 ]; then
+ die "LordOS needs at least 2 GB free on /var (for the package and its dependencies); there are $((free_kb / 1024)) MB."
+ fi
+ ok "free disk space: $((free_kb / 1024)) MB"
+}
+
+check_systemd() {
+ if [ -d /run/systemd/system ] && command -v systemctl >/dev/null 2>&1; then
+ ok "systemd is running"
+ return
+ fi
+ if [ "$SKIP_SYSTEMD_CHECK" = 1 ] || in_container; then
+ NO_SYSTEMD=1
+ warn "systemd is not running (container or chroot): services, the display manager, getty and linger will NOT be configured."
+ return
+ fi
+ die "LordOS needs systemd as the init system (/run/systemd/system is missing). Use --no-systemd-check only in containers or chroots."
+}
+
+pick_user() {
+ if [ -z "$TARGET_USER" ]; then
+ if [ "$(id -u)" -ne 0 ]; then TARGET_USER=$(id -un)
+ elif [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != root ]; then TARGET_USER=$SUDO_USER
+ fi
+ fi
+ if [ -n "$TARGET_USER" ]; then
+ getent passwd "$TARGET_USER" >/dev/null 2>&1 || die "user $TARGET_USER does not exist"
+ ok "user to set up: $TARGET_USER"
+ else
+ warn "running as root without sudo: no user's groups will be changed (use --user NAME)."
+ fi
+}
+
+# ---------------------------------------------------------------- download and verification
+
+resolve_tag() {
+ if [ -n "$WANT_VERSION" ]; then
+ TAG="v${WANT_VERSION#v}"
+ else
+ TAG=""
+ out="$TMP/release.json"
+ # releases/latest skips pre-releases (the betas): fall back to the newest release of any kind
+ if fetch "$API_URL/releases/latest" "$out" 2>/dev/null; then
+ TAG=$(sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' "$out" | head -n 1)
+ fi
+ if [ -z "$TAG" ] && fetch "$API_URL/releases?per_page=1" "$out" 2>/dev/null; then
+ TAG=$(sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' "$out" | head -n 1)
+ fi
+ [ -n "$TAG" ] || die "could not find the latest LordOS release on GitHub ($API_URL). Check the connection, or use --version X or --deb FILE."
+ fi
+ case "$TAG" in *[!A-Za-z0-9._-]*|"") die "invalid release name: $TAG" ;; esac
+}
+
+sha256_of() { sha256sum "$1" | awk '{ print $1 }'; }
+
+# the expected hash of file $2 in SHA256SUMS $1 (accepts "hash name" and "hash *name")
+sum_for() {
+ awk -v f="$2" '{ n = $2; sub(/^\*/, "", n); if (n == f) { print $1; exit } }' "$1"
+}
+
+verify_signature() {
+ # $1 SHA256SUMS, $2 SHA256SUMS.sig (may be missing)
+ pem=$RELEASE_PUBKEY_PEM
+ if [ -n "${LORDOS_PUBKEY_FILE:-}" ]; then
+ # testing only: lets the signature path be exercised with a throwaway key
+ pem=$(cat "$LORDOS_PUBKEY_FILE")
+ warn "using the release key from LORDOS_PUBKEY_FILE (testing)"
+ fi
+ if [ -z "$pem" ]; then
+ SIG_NOTE="not checked: LordOS has no release-signing key yet, so only the SHA-256 checksum is verified (it protects against corrupted downloads, not against a compromised release page)"
+ warn "signature $SIG_NOTE."
+ return
+ fi
+ [ -s "$2" ] || die "the release has no SHA256SUMS.sig signature: refusing to install"
+ if ! command -v openssl >/dev/null 2>&1; then
+ say " Installing openssl to check the signature..."
+ as_root env DEBIAN_FRONTEND=noninteractive apt-get install -y -q openssl </dev/null >/dev/null \
+ || die "openssl is needed to check the release signature"
+ fi
+ printf '%s\n' "$pem" > "$TMP/release.pub"
+ base64 -d < "$2" > "$TMP/sums.sig.bin" 2>/dev/null || die "SHA256SUMS.sig is not valid base64"
+ if openssl pkeyutl -verify -pubin -inkey "$TMP/release.pub" -rawin \
+ -in "$1" -sigfile "$TMP/sums.sig.bin" >/dev/null 2>&1; then
+ SIG_NOTE="valid Ed25519 signature of SHA256SUMS"
+ ok "signature: $SIG_NOTE"
+ else
+ die "the SHA256SUMS signature is NOT valid: the release files may have been tampered with. Nothing was installed."
+ fi
+}
+
+check_deb_file() {
+ pkg=$(dpkg-deb -f "$1" Package 2>/dev/null || true)
+ [ "$pkg" = lordos ] || die "$1 is not the LordOS package (Package: ${pkg:-unreadable})"
+ darch=$(dpkg-deb -f "$1" Architecture 2>/dev/null || true)
+ [ "$darch" = "$ARCH" ] || die "$(basename "$1") is built for $darch, but this system is $ARCH"
+ DEB_VERSION=$(dpkg-deb -f "$1" Version)
+}
+
+get_package() {
+ SIG_NOTE=""
+ # apt reads the file as the _apt user: a world-readable copy in our private-but-traversable dir
+ chmod 755 "$TMP"
+ if [ -n "$LOCAL_DEB" ]; then
+ [ -f "$LOCAL_DEB" ] || die "no such file: $LOCAL_DEB"
+ base=$(basename "$LOCAL_DEB")
+ sums="$(dirname "$LOCAL_DEB")/SHA256SUMS"
+ cp "$LOCAL_DEB" "$TMP/$base"
+ DEB_PATH="$TMP/$base"
+ if [ -f "$sums" ]; then
+ want=$(sum_for "$sums" "$base")
+ [ -n "$want" ] || die "$sums has no entry for $base"
+ [ "$(sha256_of "$DEB_PATH")" = "$want" ] || die "SHA-256 mismatch for $base: the file is corrupted or not the released one"
+ ok "SHA-256 matches $sums"
+ verify_signature "$sums" "$sums.sig"
+ else
+ SIG_NOTE="not checked: local file without a SHA256SUMS next to it"
+ warn "no SHA256SUMS next to $LOCAL_DEB: the checksum was not verified (you provided this file)."
+ fi
+ else
+ command -v curl >/dev/null 2>&1 || die "curl is missing (apt-get install curl)"
+ resolve_tag
+ base_url="${LORDOS_BASE_URL:-$DL_URL/$TAG}"
+ say " Release $TAG from $base_url"
+ fetch "$base_url/SHA256SUMS" "$TMP/SHA256SUMS" \
+ || die "could not download SHA256SUMS of release $TAG (does the release exist? is the repository public yet?)"
+ fetch "$base_url/SHA256SUMS.sig" "$TMP/SHA256SUMS.sig" 2>/dev/null || rm -f "$TMP/SHA256SUMS.sig"
+ base=$(awk '{ n = $2; sub(/^\*/, "", n); print n }' "$TMP/SHA256SUMS" \
+ | grep -E "^lordos_[A-Za-z0-9.+~-]+_${ARCH}\.deb\$" | head -n 1 || true)
+ [ -n "$base" ] || die "release $TAG has no LordOS package for $ARCH"
+ # check the signature before trusting anything else the file says
+ verify_signature "$TMP/SHA256SUMS" "$TMP/SHA256SUMS.sig"
+ say " Downloading $base..."
+ fetch "$base_url/$base" "$TMP/$base" || die "could not download $base"
+ DEB_PATH="$TMP/$base"
+ [ "$(sha256_of "$DEB_PATH")" = "$(sum_for "$TMP/SHA256SUMS" "$base")" ] \
+ || die "SHA-256 mismatch for $base: the download is corrupted. Nothing was installed."
+ ok "SHA-256 of $base matches SHA256SUMS"
+ fi
+ chmod 644 "$DEB_PATH"
+ check_deb_file "$DEB_PATH"
+ ok "package: lordos $DEB_VERSION ($ARCH)"
+}
+
+# ---------------------------------------------------------------- install
+
+apt_install() {
+ as_root env DEBIAN_FRONTEND=noninteractive apt-get install -y -q \
+ -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold "$@" </dev/null
+}
+
+install_package() {
+ step "Installing the package and its dependencies from Debian"
+ as_root env DEBIAN_FRONTEND=noninteractive apt-get update -q </dev/null \
+ || warn "apt-get update failed; trying with the package lists already on the system"
+ extras=""
+ if [ "$NO_EXTRAS" = 0 ]; then
+ for p in $EXTRA_PKGS; do
+ if apt-cache show "$p" >/dev/null 2>&1; then extras="$extras $p"; fi
+ done
+ fi
+ was=$(dpkg-query -W -f '${Version}' lordos 2>/dev/null || true)
+ # shellcheck disable=SC2086 # $extras is a list of package names
+ apt_install "$DEB_PATH" $extras || die "apt-get could not install LordOS (see the messages above). Nothing else was changed."
+ if [ -n "$was" ]; then changed "package lordos $was replaced by $DEB_VERSION"
+ else changed "package lordos $DEB_VERSION installed (with its Debian dependencies)"; fi
+ if [ -n "$extras" ]; then changed "extra packages ensured:$extras"; fi
+ state_set INSTALLED_VERSION "$DEB_VERSION"
+}
+
+setup_greeter_user() {
+ if getent passwd "$GREETER_USER" >/dev/null 2>&1; then
+ ok "system user $GREETER_USER already exists"
+ return
+ fi
+ as_root useradd --system --home-dir /var/lib/lordos-greeter --create-home \
+ --shell /usr/sbin/nologin --comment LordOS "$GREETER_USER"
+ state_set GREETER_CREATED 1
+ changed "system user $GREETER_USER created (the login screen's user)"
+}
+
+setup_groups() {
+ [ -n "$TARGET_USER" ] || return 0
+ added=""
+ for g in $USER_GROUPS; do
+ getent group "$g" >/dev/null 2>&1 || continue
+ user_in_group "$TARGET_USER" "$g" && continue
+ as_root usermod -aG "$g" "$TARGET_USER"
+ added="$added $g"
+ done
+ if [ -n "$added" ]; then
+ prev=$(state_get GROUPS_ADDED)
+ state_set GROUPS_USER "$TARGET_USER"
+ state_set GROUPS_ADDED "$(printf '%s %s' "$prev" "$added" | tr ' ' '\n' | sed '/^$/d' | sort -u | tr '\n' ' ' | sed 's/ $//')"
+ changed "user $TARGET_USER added to:$added (takes effect at the next login)"
+ else
+ ok "user $TARGET_USER already has the groups LordOS uses"
+ fi
+}
+
+setup_locales() {
+ if [ ! -f /etc/locale.gen ] || ! command -v locale-gen >/dev/null 2>&1; then
+ warn "the locales package is missing: the interface works, but only the C locale is generated"
+ return 0
+ fi
+ new=""
+ for loc in $LOCALES; do
+ if grep -qE "^[[:space:]]*${loc}[[:space:]]+UTF-8" /etc/locale.gen; then continue; fi
+ if grep -qE "^#[[:space:]]*${loc}[[:space:]]+UTF-8" /etc/locale.gen; then
+ as_root sed -i -E "s/^#[[:space:]]*(${loc}[[:space:]]+UTF-8)/\\1/" /etc/locale.gen
+ else
+ printf '%s UTF-8\n' "$loc" | as_root tee -a /etc/locale.gen >/dev/null
+ fi
+ new="$new $loc"
+ done
+ if [ -n "$new" ]; then
+ as_root locale-gen </dev/null >/dev/null
+ changed "locales generated:$new (the system language was not changed)"
+ fi
+}
+
+setup_session_conf() {
+ if [ -e "$SESSION_CONF" ]; then
+ ok "$SESSION_CONF already exists (kept)"
+ return
+ fi
+ as_root mkdir -p /etc/lordos
+ printf '# LordOS: empty AUTOLOGIN shows the login screen. Settings > Users changes it.\nAUTOLOGIN=\n' \
+ | as_root tee "$SESSION_CONF" >/dev/null
+ state_set SESSION_CONF_CREATED 1
+ changed "$SESSION_CONF written: the login screen, no automatic login"
+}
+
+setup_systemd() {
+ if ! has_systemd; then
+ warn "skipped without systemd: enabling lordos.service, lord-netperm and lord-fand, the display manager, getty@tty1 and linger"
+ return
+ fi
+ step "Configuring the system services"
+ as_root systemctl daemon-reload
+ # user PipeWire (Debian's packages enable it already; just in case, like the ISO)
+ as_root systemctl --global enable pipewire.socket pipewire-pulse.socket wireplumber.service >/dev/null 2>&1 || true
+ as_root systemctl enable lord-netperm.service lord-fand.service >/dev/null 2>&1 \
+ || warn "could not enable lord-netperm/lord-fand"
+ changed "lord-netperm (per-app network permissions) and lord-fand (fans) enabled"
+
+ DM_SWITCHED=0
+ if [ -n "$DM_UNIT" ] && [ "$DM_UNIT" != lordos.service ]; then
+ if [ "$KEEP_DM" = 1 ]; then
+ warn "keeping $DM_UNIT as the display manager (--keep-display-manager): LordOS is not enabled at boot"
+ elif ask "Disable $DM_UNIT so LordOS shows its own login screen at boot?" 0; then
+ as_root systemctl disable "$DM_UNIT" >/dev/null 2>&1 || die "could not disable $DM_UNIT"
+ state_set PREV_DM "$DM_UNIT"
+ changed "display manager $DM_UNIT disabled (still installed; --uninstall turns it back on)"
+ DM_SWITCHED=1
+ else
+ KEEP_DM=1
+ warn "kept $DM_UNIT: LordOS is installed but not enabled at boot"
+ fi
+ fi
+ if [ "$KEEP_DM" = 1 ] && [ -n "$DM_UNIT" ]; then
+ return
+ fi
+ as_root systemctl enable lordos.service >/dev/null 2>&1 || die "could not enable lordos.service"
+ changed "lordos.service enabled: LordOS starts on tty1 at boot"
+ if [ "$(systemctl is-enabled [email protected] 2>/dev/null || true)" != masked ]; then
+ as_root systemctl mask [email protected] >/dev/null 2>&1
+ state_set GETTY_MASKED 1
+ changed "getty@tty1 masked (text logins remain on tty2-tty6: Ctrl+Alt+F2)"
+ fi
+ if [ -n "$TARGET_USER" ] && [ ! -e "/var/lib/systemd/linger/$TARGET_USER" ] && command -v loginctl >/dev/null 2>&1; then
+ if as_root loginctl enable-linger "$TARGET_USER" 2>/dev/null; then
+ state_set LINGER_USER "$TARGET_USER"
+ changed "linger enabled for $TARGET_USER (their PipeWire starts with the system, like on the ISO)"
+ fi
+ fi
+}
+
+remote_note() {
+ if [ -f /etc/lordos/remote/config ] && grep -q '^enabled=1' /etc/lordos/remote/config 2>/dev/null; then
+ warn "remote desktop was already turned on in /etc/lordos/remote/config before this run; it was left as it was (Settings > Sharing)"
+ else
+ ok "remote desktop: off (port 5673 closed; Settings > Sharing turns it on)"
+ fi
+}
+
+network_note() {
+ nm=""; nd=""; ifu=""
+ if [ -d /run/NetworkManager/devices ]; then nm=" NetworkManager"; fi
+ if has_systemd && systemctl is-active -q systemd-networkd.service 2>/dev/null; then nd=" systemd-networkd"; fi
+ if command -v ifup >/dev/null 2>&1 && cat /etc/network/interfaces /etc/network/interfaces.d/* 2>/dev/null \
+ | grep -E '^[[:space:]]*(auto|allow-hotplug|iface)[[:space:]]' | grep -vqE '^[[:space:]]*[a-z-]+[[:space:]]+lo([[:space:]]|$)'; then
+ ifu=" ifupdown"
+ fi
+ if [ -n "$nm$ifu$nd" ]; then
+ ok "network: managed by$nm$ifu$nd and left untouched (LordOS shows those interfaces as system ones)"
+ else
+ ok "network: configuration untouched"
+ fi
+}
+
+do_install() {
+ step "Checking this system"
+ check_os
+ check_arch
+ check_root
+ check_disk
+ check_systemd
+ pick_user
+ DM_UNIT=""
+ if has_systemd; then DM_UNIT=$(current_dm); fi
+ dm_active=0
+ if [ -n "$DM_UNIT" ] && systemctl is-active -q "$DM_UNIT" 2>/dev/null; then dm_active=1; fi
+ installed=$(dpkg-query -W -f '${db:Status-Abbrev} ${Version}' lordos 2>/dev/null || true)
+
+ say ""
+ step "This will:"
+ if [ -n "$LOCAL_DEB" ]; then say " 1. Use the local package $LOCAL_DEB"
+ elif [ -n "$WANT_VERSION" ]; then say " 1. Download LordOS v${WANT_VERSION#v} for $ARCH from github.com/$REPO and verify its SHA-256"
+ else say " 1. Download the latest LordOS release for $ARCH from github.com/$REPO and verify its SHA-256"; fi
+ case "$installed" in ii*) say " (LordOS ${installed#ii } is already installed: it will be upgraded or reinstalled)" ;; esac
+ say " 2. Install it with apt-get; its dependencies come from your Debian mirrors"
+ [ "$NO_EXTRAS" = 0 ] && say " plus PipeWire, fonts and the user D-Bus session if missing"
+ say " 3. Create the $GREETER_USER system user (if missing) and generate the en/es/pt locales"
+ [ -n "$TARGET_USER" ] && say " 4. Add $TARGET_USER to the groups that exist of: $USER_GROUPS"
+ if has_systemd; then
+ say " 5. Enable lordos.service, lord-netperm and lord-fand, and mask getty@tty1"
+ if [ -n "$DM_UNIT" ] && [ "$KEEP_DM" = 0 ]; then
+ say " 6. Offer to disable your current display manager, $DM_UNIT (you can switch back)"
+ fi
+ fi
+ say " It does NOT touch your network configuration, and remote desktop stays off."
+ say ""
+ ask "Continue?" 0 || die "cancelled; nothing was changed"
+
+ TMP=$(mktemp -d)
+ trap 'rm -rf "$TMP"' EXIT INT TERM
+ step "Getting the package"
+ get_package
+ install_package
+ step "Setting up LordOS"
+ setup_greeter_user
+ setup_groups
+ setup_locales
+ setup_session_conf
+ setup_systemd
+ remote_note
+ network_note
+ state_set INSTALLER_VERSION "$INSTALLER_VERSION"
+
+ say ""
+ step "${C_G}LordOS $DEB_VERSION is installed.${C_0}"
+ say "What changed:$CHANGES"
+ say ""
+ if [ -n "$SIG_NOTE" ]; then say "Signature: $SIG_NOTE."; say ""; fi
+ if ! has_systemd; then
+ say "No systemd here, so nothing was set to start. On a real system run the installer again."
+ elif [ "$KEEP_DM" = 1 ] && [ -n "$DM_UNIT" ]; then
+ say "LordOS is installed but $DM_UNIT is still your display manager. To switch later:"
+ say " sudo systemctl disable $DM_UNIT"
+ say " sudo systemctl enable lordos.service && sudo systemctl mask [email protected]"
+ say " sudo reboot"
+ else
+ say "To start LordOS:"
+ say " - reboot: ${C_B}sudo reboot${C_0} (LordOS's login screen appears on the screen)"
+ if [ "$dm_active" = 1 ]; then
+ say " - $DM_UNIT is still running this session, so rebooting is the safe way."
+ else
+ say " - or, from a text console (not over SSH from inside a desktop): ${C_B}sudo systemctl start lordos${C_0}"
+ fi
+ if [ "$DM_SWITCHED" = 1 ]; then
+ say ""
+ say "To go back to $DM_UNIT without uninstalling:"
+ say " sudo systemctl disable lordos.service && sudo systemctl unmask [email protected]"
+ say " sudo systemctl enable $DM_UNIT && sudo reboot"
+ fi
+ fi
+ say ""
+ say "To uninstall: curl -fsSL https://lordos.org/install.sh | sh -s -- --uninstall"
+ say "Documentation: https://github.com/$REPO/blob/main/docs/INSTALL-DEBIAN.md"
+}
+
+# ---------------------------------------------------------------- uninstall
+
+do_uninstall() {
+ step "Checking this system"
+ check_root
+ check_systemd
+ installed=$(dpkg-query -W -f '${db:Status-Abbrev}' lordos 2>/dev/null || true)
+ prev_dm=$(state_get PREV_DM)
+ if [ -z "$prev_dm" ] && has_systemd && [ -z "$(current_dm)" ]; then
+ # no record (installed by hand?): offer the first display manager still installed
+ for d in $KNOWN_DMS; do
+ if unit_exists "$d.service"; then prev_dm="$d.service"; break; fi
+ done
+ fi
+ say ""
+ step "This will:"
+ case "$installed" in
+ ii*|iF*|iU*|rc*) if [ -n "$PURGE" ]; then say " - purge the lordos package"; else say " - remove the lordos package"; fi ;;
+ *) say " - (the lordos package is not installed)" ;;
+ esac
+ if has_systemd; then
+ say " - disable lordos.service and lord-netperm, and restore getty@tty1"
+ [ -n "$prev_dm" ] && say " - enable the display manager $prev_dm again"
+ fi
+ [ -n "$(state_get GROUPS_ADDED)" ] && say " - remove $(state_get GROUPS_USER) from the groups the installer added: $(state_get GROUPS_ADDED)"
+ [ "$(state_get GREETER_CREATED)" = 1 ] && say " - delete the $GREETER_USER system user"
+ say " Your home folder and LordOS settings in it (~/.config/lordos) are kept."
+ say ""
+ ask "Continue?" 0 || die "cancelled; nothing was changed"
+
+ if has_systemd; then
+ as_root systemctl disable lordos.service lord-netperm.service >/dev/null 2>&1 || true
+ as_root systemctl stop lord-netperm.service >/dev/null 2>&1 || true
+ changed "lordos.service and lord-netperm disabled"
+ if [ "$(systemctl is-enabled [email protected] 2>/dev/null || true)" = masked ]; then
+ as_root systemctl unmask [email protected] >/dev/null 2>&1 || true
+ changed "getty@tty1 unmasked"
+ fi
+ if [ "$(systemctl is-enabled [email protected] 2>/dev/null || true)" = disabled ]; then
+ as_root systemctl enable [email protected] >/dev/null 2>&1 || true
+ fi
+ if [ -n "$prev_dm" ]; then
+ if ask "Enable $prev_dm again as the display manager?" 0; then
+ if as_root systemctl enable "$prev_dm" >/dev/null 2>&1 || as_root systemctl enable --force "$prev_dm" >/dev/null 2>&1; then
+ changed "display manager $prev_dm enabled again"
+ else
+ warn "could not enable $prev_dm; run: sudo systemctl enable --force $prev_dm"
+ fi
+ fi
+ fi
+ lu=$(state_get LINGER_USER)
+ if [ -n "$lu" ] && command -v loginctl >/dev/null 2>&1; then
+ as_root loginctl disable-linger "$lu" 2>/dev/null || true
+ changed "linger disabled for $lu"
+ fi
+ fi
+ case "$installed" in
+ ii*|iF*|iU*|rc*)
+ step "Removing the package"
+ if [ -n "$PURGE" ]; then
+ as_root env DEBIAN_FRONTEND=noninteractive apt-get purge -y -q lordos </dev/null
+ changed "package lordos purged"
+ else
+ as_root env DEBIAN_FRONTEND=noninteractive apt-get remove -y -q lordos </dev/null
+ changed "package lordos removed (its /etc files are kept; --purge removes them)"
+ fi ;;
+ esac
+ gu=$(state_get GROUPS_USER)
+ for g in $(state_get GROUPS_ADDED); do
+ if [ -n "$gu" ] && user_in_group "$gu" "$g"; then
+ as_root gpasswd -d "$gu" "$g" >/dev/null 2>&1 || true
+ fi
+ done
+ if [ -n "$(state_get GROUPS_ADDED)" ]; then changed "$gu removed from: $(state_get GROUPS_ADDED)"; fi
+ if [ "$(state_get SESSION_CONF_CREATED)" = 1 ] && [ -f "$SESSION_CONF" ]; then
+ as_root rm -f "$SESSION_CONF"
+ as_root rmdir /etc/lordos 2>/dev/null || true
+ changed "$SESSION_CONF removed"
+ fi
+ if [ "$(state_get GREETER_CREATED)" = 1 ] && getent passwd "$GREETER_USER" >/dev/null 2>&1; then
+ if as_root userdel -r "$GREETER_USER" >/dev/null 2>&1 || as_root userdel "$GREETER_USER" >/dev/null 2>&1; then
+ changed "system user $GREETER_USER deleted"
+ else
+ warn "could not delete $GREETER_USER (still logged in?); after a reboot: sudo userdel -r $GREETER_USER"
+ fi
+ elif getent passwd "$GREETER_USER" >/dev/null 2>&1; then
+ say " The $GREETER_USER system user was not created by this installer and was kept (sudo userdel -r $GREETER_USER removes it)."
+ fi
+ as_root rm -rf "$STATE_DIR"
+
+ say ""
+ step "LordOS was uninstalled."
+ say "What changed:${CHANGES:-
+ - nothing}"
+ say ""
+ say "Reboot to get back to your previous login screen: sudo reboot"
+ say "Packages pulled in as dependencies can be removed with: sudo apt autoremove"
+}
+
+# ---------------------------------------------------------------- main
+
+main() {
+ setup_colors
+ ASSUME_YES=0; [ "${LORDOS_YES:-0}" = 1 ] && ASSUME_YES=1
+ WANT_VERSION=""; LOCAL_DEB=""; TARGET_USER=""; MODE=install; PURGE=""
+ KEEP_DM=0; NO_EXTRAS=0; SKIP_SYSTEMD_CHECK=0; NO_SYSTEMD=0; DM_SWITCHED=0
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ -y|--yes) ASSUME_YES=1 ;;
+ --version) [ $# -ge 2 ] || die "--version needs a value"; WANT_VERSION=$2; shift ;;
+ --version=*) WANT_VERSION=${1#*=} ;;
+ --deb) [ $# -ge 2 ] || die "--deb needs a file"; LOCAL_DEB=$2; shift ;;
+ --deb=*) LOCAL_DEB=${1#*=} ;;
+ --user) [ $# -ge 2 ] || die "--user needs a name"; TARGET_USER=$2; shift ;;
+ --user=*) TARGET_USER=${1#*=} ;;
+ --keep-display-manager) KEEP_DM=1 ;;
+ --no-extras) NO_EXTRAS=1 ;;
+ --no-systemd-check) SKIP_SYSTEMD_CHECK=1 ;;
+ --uninstall) MODE=uninstall ;;
+ --purge) PURGE=1 ;;
+ -h|--help) usage; exit 0 ;;
+ *) usage >&2; die "unknown option: $1" ;;
+ esac
+ shift
+ done
+ if [ -n "$LOCAL_DEB" ]; then
+ case "$LOCAL_DEB" in /*) ;; *) LOCAL_DEB="$(pwd)/$LOCAL_DEB" ;; esac
+ fi
+ if [ -n "$WANT_VERSION" ] && [ -n "$LOCAL_DEB" ]; then die "use --version or --deb, not both"; fi
+ if [ -n "$PURGE" ] && [ "$MODE" != uninstall ]; then die "--purge only goes with --uninstall"; fi
+
+ say "${C_B}LordOS installer for Debian 13${C_0} (installer v$INSTALLER_VERSION)"
+ if [ "$MODE" = uninstall ]; then do_uninstall; else do_install; fi
+}
+
+main "$@"