From 5d602696d56e57192afb39580695ee22adc6012c Mon Sep 17 00:00:00 2001 From: bchanot Date: Sun, 11 Oct 2026 23:37:05 +0200 Subject: [PATCH 1/2] feat(install): offer GNOME desktop and RDP remote login instead of forcing them, default no on WSL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ubuntu-desktop-minimal and gnome-remote-desktop were installed unconditionally in the Linux block. On WSL they are useless (Windows owns the display) and the desktop's NetworkManager/systemd-resolved rewrite /etc/resolv.conf, which lost DNS mid-install (fail2ban/whois fetch failed on 'Temporary failure resolving'). - confirm() takes an optional default (y → [Y/n], Enter = yes, no tty = yes) - is_wsl(): WSL_DISTRO_NAME or 'microsoft' in /proc/version - offer_desktop(): desktop [Y/n], then RDP [Y/n]; WSL flips both to [y/N] - README step 11 + table + packages, CHANGELOG Unreleased --- .claude/tasks/TODO.md | 10 +++++++ CHANGELOG.md | 1 + README.md | 8 +++--- install.sh | 61 ++++++++++++++++++++++++++++++++++--------- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index f7f63c2..20861bf 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -155,3 +155,13 @@ Branch: feature/tmux-copy-exit-keys (off develop). Chosen in chat: only after a - [x] tmux.conf — MouseDragEnd1Pane sets `@mouse_sel` (both clipboard branches), pane-mode-changed hook clears it, run-shell after tpm - [x] install.sh chmod list + CLAUDE.md layout + README (bin table, step 8) + CHANGELOG - [x] Live test on the running server: marker → g exits; no marker → k stays, q exits; marker → C-u stays; script idempotent + +## Feature — desktop + RDP offered, not forced; WSL default no (2026-10-11) +Branch: feature/desktop-rdp-prompt (off develop). Trigger: WSL install lost DNS mid-run +after ubuntu-desktop-minimal (hypothesis: NetworkManager/systemd-resolved rewrote +/etc/resolv.conf); desktop + RDP useless on WSL anyway. +- [x] install.sh: `is_wsl()` (WSL_DISTRO_NAME or /proc/version) +- [x] install.sh: `confirm` optional default `y` ([Y/n], no tty → default) +- [x] install.sh: `offer_desktop()` — desktop [Y/n] then RDP [Y/n]; WSL → both default n with hint +- [x] README step 11 + table + packages line; CHANGELOG Unreleased +- [x] shellcheck + bash -n + stub harness for confirm defaults / WSL branch diff --git a/CHANGELOG.md b/CHANGELOG.md index bc54e80..fd8c57f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versioning: se - `tmux.conf`: Ctrl+Alt+arrow moves between panes without the prefix, in copy-mode too (macOS: map Ctrl+Cmd+arrow in iTerm2 to `[1;7A` `[1;7B` `[1;7D` `[1;7C`). ### Changed +- `install.sh`: the GNOME desktop (`ubuntu-desktop-minimal`) and the RDP remote login are now offered (`[Y/n]` each, RDP only after the desktop) instead of always installed; on WSL both default to no, since Windows owns the display and the desktop's NetworkManager/systemd-resolved rewrite `/etc/resolv.conf` and break DNS mid-install. - `.githooks/post-commit` and `post-merge` fail closed on `gitflow.autopush`: an unreadable or non-boolean value means no push, with a named warning (was: silently treated as `true`). ### Fixed diff --git a/README.md b/README.md index f1aba57..0574349 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/main/remote-install. | Path | Purpose | | -------------------- | -------------------------------------------------------------- | -| `install.sh` | Linux: installs apt packages + Docker + code-server + RDP (gnome-remote-desktop), backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts, pipx tools and a low-disk login warning; ends by offering four extras (`/tmp` on disk, SSH memory guard, the `cloudpex` NAS mount helper, rootless Docker). macOS: same tooling through Homebrew (see [macOS](#macos)), deploys the tmux config, then prints what was not installed compared with Linux. | +| `install.sh` | Linux: installs apt packages + Docker + code-server, offers the GNOME desktop + RDP (gnome-remote-desktop; default no on WSL), backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts, pipx tools and a low-disk login warning; ends by offering four extras (`/tmp` on disk, SSH memory guard, the `cloudpex` NAS mount helper, rootless Docker). macOS: same tooling through Homebrew (see [macOS](#macos)), deploys the tmux config, then prints what was not installed compared with Linux. | | `tmux.conf` | tmux config (vi keys, mouse, status bar, tpm plugins: resurrect + continuum session restore, window-name). Deployed on both OSes to `~/.config/tmux/tmux.conf` (tmux ≥ 3.1). | | `cloudpex/` | On-demand SMB mount of a NAS share (`cloudpex` command + its installer, offered `[y/N]` at the end of a Linux install). Site values (host, share, SMB user, mount point, SMB version) are prompted at install and stored in `/etc/cloudpex.conf`, never in the script. French README inside. | | `etc/tmpfiles.d/tmp.conf` | Cleanup rules for a disk-backed `/tmp` (wiped at boot, 10-day purge). Deployed by the `/tmp` on disk offer. | @@ -73,7 +73,7 @@ What it does: 8. Copies the `bin/` scripts (`dt`, `dtach-router`, `claude-provider`, `repo-sync`, `tmux-copy-exit-keys`) into `~/.local/bin`. The dtach session-resume menu ships in the deployed bashrc (both OSes), so every interactive shell offers it — including VS Code Remote-SSH terminals, which are non-login and never read `~/.profile`. The installer also strips any older dtach block left in `~/.profile` so a plain SSH login doesn't prompt twice. 9. On Linux, installs `etc/profile.d/disk-usage-warning.sh` to `/etc/profile.d/` (needs `sudo`) so each login warns when `/` or `/home` cross 85% usage. 10. On Linux, installs **code-server** (VS Code in the browser) via its vendor script — skipped if already present — and enables the `code-server@` systemd service (login from `id -un`: the bashrc overrides `$USER`). -11. On Linux, installs **`ubuntu-desktop-minimal`** (GDM + GNOME Shell, ~1.5 GB): the RDP remote login below hands out a GNOME session, which a bare server install does not have. Then sets up **RDP remote login** via `gnome-remote-desktop` (Wayland-native): installs the daemon + `openssl`, generates a self-signed TLS cert once, and prompts interactively for shared "gate" credentials (skipped when no terminal is attached, or already set). Disables `xrdp` if present; opens UFW port `3389` only when UFW is already active. Finally, when `lspci` sees an NVIDIA GPU, runs `ubuntu-drivers install` to put on the driver the distro recommends for the card (no version pinned; loads at the next reboot). Skipped on machines without an NVIDIA GPU. +11. On Linux, **offers** (`[Y/n]`, Enter = yes) to install **`ubuntu-desktop-minimal`** (GDM + GNOME Shell, ~1.5 GB): the RDP remote login below hands out a GNOME session, which a bare server install does not have. If accepted, then **offers** (`[Y/n]`) **RDP remote login** via `gnome-remote-desktop` (Wayland-native); no desktop means no RDP question. On **WSL** (`WSL_DISTRO_NAME` set or `microsoft` in `/proc/version`) both default to **no** (`[y/N]`): Windows owns the display, and the desktop drags in NetworkManager + systemd-resolved, which rewrite `/etc/resolv.conf` and break DNS for the rest of the install. With no terminal attached the default applies. The RDP setup installs the daemon + `openssl`, generates a self-signed TLS cert once, and prompts interactively for shared "gate" credentials (skipped when no terminal is attached, or already set). Disables `xrdp` if present; opens UFW port `3389` only when UFW is already active. Finally, when `lspci` sees an NVIDIA GPU, runs `ubuntu-drivers install` to put on the driver the distro recommends for the card (no version pinned; loads at the next reboot). Skipped on machines without an NVIDIA GPU. 12. On Linux, at the very end, **offers** (`[y/N]`) to install the **`cloudpex`** NAS mount helper to `/usr/local/bin` via `cloudpex/install.sh`, which prompts for the NAS host, share name, SMB user, mount point and SMB version and writes them to `/etc/cloudpex.conf` (root, `0600`; an existing config is shown and kept unless you say `n`; skipped when no terminal is attached). Nothing is mounted, no password stored, see [`cloudpex/README.md`](cloudpex/README.md). 13. On Linux, installs the **security baseline**, always, no prompt: **fail2ban** (+ `nftables`) with `etc/fail2ban/jail.d/local.conf` (sshd jail reading the journal, bans the offending IP on every port so the SSH port does not matter, 5 failures in 10 min → 1 h ban, loopback and private LAN ranges never banned); **unattended-upgrades** enabled through `etc/apt/apt.conf.d/20auto-upgrades`; and the **sshd drop-in** `etc/ssh/sshd_config.d/20-hardening.conf` (`PermitRootLogin no`, `MaxAuthTries 3`, `LoginGraceTime 20`), checked with `sshd -t` and removed again if sshd rejects it, then `reload ssh`. Authentication methods, port and user lists are left as they are. 14. On Linux, at the very end, **offers** (`[y/N]`, skipped when no terminal is attached) to move **`/tmp` to disk**: Ubuntu mounts `/tmp` as a RAM-backed tmpfs capped at 50% of RAM, which agent runs fill, halving the RAM and breaking every shell with "No space left on device". Accepting masks `tmp.mount` and installs `etc/tmpfiles.d/tmp.conf` (wipe at boot, 10-day purge). Effective at the next reboot. @@ -89,8 +89,8 @@ What it does: - **Web stack (local WordPress/LAMP)**: `mariadb-server imagemagick php-mysql php-gd php-imagick php-mbstring php-xml php-intl php-curl` (unversioned `php-*` metapackages, so they follow the distro's PHP) - **Media / doc CLI**: `ffmpeg weasyprint poppler-utils qpdf webp libavif-bin` - **Docker**: `docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras` (via Docker's repo) -- **Desktop / GPU**: `ubuntu-desktop-minimal` (always, Linux) + the distro-recommended NVIDIA driver via `ubuntu-drivers install` (only when an NVIDIA GPU is detected) -- **Remote access**: `gnome-remote-desktop openssl` (apt) + `code-server` (via its vendor install script, not apt) — RDP remote login + browser VS Code +- **Desktop / GPU**: `ubuntu-desktop-minimal` (offered, Linux; default yes, no on WSL) + the distro-recommended NVIDIA driver via `ubuntu-drivers install` (only when an NVIDIA GPU is detected) +- **Remote access**: `gnome-remote-desktop openssl` (apt, offered after the desktop) + `code-server` (via its vendor install script, not apt) — RDP remote login + browser VS Code - **pipx**: `PyMuPDF` (`pymupdf`), `Markdown` (`markdown_py`) - **Security baseline (Linux, always)**: `fail2ban nftables unattended-upgrades` - **Optional (end-of-install offer, Linux)**: `earlyoom`; `uidmap dbus-user-session slirp4netns` (rootless Docker) diff --git a/install.sh b/install.sh index 03a25b5..3e8e473 100755 --- a/install.sh +++ b/install.sh @@ -235,23 +235,64 @@ harden_sshd() { sudo systemctl reload ssh } -# Yes/no prompt for the optional system changes offered at the end of the install. -# Declines (returns 1) when no terminal is attached (curl | bash), so an offer is -# skipped with a hint instead of blocking; re-run ./install.sh from a terminal to -# get it offered again. +# Yes/no prompt for the optional system changes. $2 is the default taken on Enter: +# "n" (the default, offers shown [y/N]) or "y" (shown [Y/n]). With no terminal attached +# (curl | bash) the default is applied without blocking: a declined offer is skipped +# with a hint, re-run ./install.sh from a terminal to get it offered again. confirm() { - local answer="" + local answer="" default="${2:-n}" if [ ! -t 0 ]; then + if [ "$default" = y ]; then + echo "No terminal attached, default yes: $1" >&2 + return 0 + fi echo "Skipped (no terminal attached): $1" >&2 return 1 fi - read -rp "$1 [y/N] " answer || true + if [ "$default" = y ]; then + read -rp "$1 [Y/n] " answer || true + else + read -rp "$1 [y/N] " answer || true + fi case "$answer" in [yY]|[yY][eE][sS]) return 0 ;; + [nN]|[nN][oO]) return 1 ;; + "") [ "$default" = y ] ;; *) return 1 ;; esac } +# WSL (Windows Subsystem for Linux): no GDM, no GNOME session, no RDP target — the +# Windows side owns the display. Detected from the env var WSL sets, else the kernel +# string. +is_wsl() { + [ -n "${WSL_DISTRO_NAME:-}" ] || grep -qi microsoft /proc/version 2>/dev/null +} + +# GNOME desktop (GDM + Shell, ubuntu-desktop-minimal, ~1.5 GB) and, on top of it, the +# RDP remote login (gnome-remote-desktop, see setup_remote_desktop). Both asked, yes by +# default: a headless server or a local workstation wants them, WSL does not — there +# the default flips to no. The desktop pulls NetworkManager + systemd-resolved, which +# on WSL rewrite /etc/resolv.conf and kill DNS mid-install, so declining is also what +# keeps the rest of the install working. RDP needs a GNOME session: no desktop, no RDP. +offer_desktop() { + local default=y + if is_wsl; then + echo "WSL detected: a GNOME desktop and RDP remote login are not useful here (Windows owns the display)." + default=n + fi + if ! confirm "Install the GNOME desktop (ubuntu-desktop-minimal, ~1.5 GB)?" "$default"; then + echo "GNOME desktop and RDP remote login skipped." + return 0 + fi + sudo apt-get install -y ubuntu-desktop-minimal + if confirm "Set up RDP remote login (gnome-remote-desktop, port 3389)?" "$default"; then + setup_remote_desktop + else + echo "RDP remote login skipped." + fi +} + # /tmp on disk instead of the tmpfs Ubuntu mounts by default (RAM-backed, capped at # 50% of RAM). Agent runs fill it: that eats half the RAM and, once the cap is hit, # every temp-file creation fails with ENOSPC — which is what breaks shells. Masking @@ -702,12 +743,8 @@ if command -v apt-get >/dev/null 2>&1; then # id -un, not $USER: the deployed bashrc sets USER to the git/vim identity. sudo systemctl enable --now "code-server@$(id -un)" - # GNOME desktop (GDM + Shell): the RDP remote login below needs a GNOME session - # to hand out; a bare server install has none. Ubuntu-only metapackage. - sudo apt-get install -y ubuntu-desktop-minimal - - # Remote desktop (gnome-remote-desktop — see the function header for why not xrdp). - setup_remote_desktop + # GNOME desktop + RDP remote login, both offered ([Y/n]; [y/N] on WSL). + offer_desktop # NVIDIA driver, only when an NVIDIA GPU is present. install_nvidia_driver From 64f7d92b0b4d45c1bf913bd504880a3aaee03574 Mon Sep 17 00:00:00 2001 From: bchanot Date: Sun, 11 Oct 2026 23:37:15 +0200 Subject: [PATCH 2/2] =?UTF-8?q?chore(memory):=20journal=20=E2=80=94=20desk?= =?UTF-8?q?top/RDP=20offer,=20WSL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/memory/journal.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 8feb460..f136dcb 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -141,3 +141,6 @@ Done: `bind -n M-Left/M-Right previous/next-window` (status on, mirrors C-n/C-p) ## 2026-10-09 (6) — tmux Ctrl+Alt+arrow panes + README key-mapping table Done: `bind -n C-M-Up/Down/Left/Right select-pane` (root + copy-mode-vi, no vim pass-through). README "Terminal key mappings for tmux": iTerm2 Send Escape Sequence table (Cmd+arrow `[1;3D/C`, Ctrl+Cmd+arrow `[1;7A/B/D/C`), Linux notes (native, GNOME workspace shortcut may grab Ctrl+Alt+arrow, unverified). Merged on signal; manual push. + +## 2026-10-11 — desktop + RDP offered, WSL default no +Done: `offer_desktop()` (desktop [Y/n] → RDP [Y/n], WSL → [y/N] + hint), `confirm` default arg, `is_wsl()`. Trigger: WSL install lost DNS mid-run after ubuntu-desktop-minimal (hypothesis: NetworkManager/systemd-resolved rewrote /etc/resolv.conf), fail2ban/whois fetch failed. 8-case stub harness OK, shellcheck clean. Branch feature/desktop-rdp-prompt, commit 5d60269, pushed, not merged.