diff --git a/.claude/memory/decisions.md b/.claude/memory/decisions.md index 4ae3c22..9c621cd 100644 --- a/.claude/memory/decisions.md +++ b/.claude/memory/decisions.md @@ -33,3 +33,10 @@ Implemented install.sh `setup_remote_desktop` + `ensure_rdp_credentials`. Connec Alts rejected: (a) force Xorg GDM + xrdp — sacrifices Wayland desktop, fragile; (b) VNC (wayvnc) — RDP preferred (mstsc native on Win client, TLS); (c) g-r-d user "Desktop Sharing" mode — shares existing local session, wanted independent headless login. See LRN-004, BLK-004. Status: done. + +## BDR-006 — Disk-usage login warning deployed system-wide to /etc/profile.d +2026-06-24. New `etc/profile.d/disk-usage-warning.sh` (POSIX sh, bold-red warn when / or /home ≥85%) +deployed via `sudo install -D -m 0644` to `/etc/profile.d/` from `install_disk_warning()`, gated in +the apt-get Linux block (see LRN-005). Alt rejected: per-user append to `~/.bashrc` — wanted the warn +for EVERY login account on the box, not just the installing user, so system-wide profile.d won. Known +limit: login-shell scope only (non-login terminals miss it). Status: done. diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 1f9ce6e..b9b5cc7 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -26,3 +26,9 @@ xrdp abandoned (Wayland-only GNOME kills Xorg session). Replaced install_xrdp empty (BLK-004); 2-layer auth gate→GDM PAM (LRN-004). Added ensure_rdp_credentials (prompt, TTY-guard, idempotent). Connection CONFIRMED live. install.sh committed 0bd936b (bash -n + shellcheck CLEAN); push blocked here (HTTPS remote, no creds in env) → user pushes. TPM GKeyFile-fallback warn harmless. + +## 2026-06-24 — disk-usage login warning +Added etc/profile.d/disk-usage-warning.sh (POSIX sh, warns bold red when / or /home ≥85%). +install_disk_warning() in install.sh: sudo install -D -m 0644 → /etc/profile.d, gated in apt block +(Linux-only: df --output=pcent GNU-only + /etc/profile.d Debian convention). shellcheck + sh -n CLEAN, +both code paths runtime-verified. README + CLAUDE.md synced. Not committed (master, user to confirm). diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index dba1fcd..b7820c0 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -29,3 +29,10 @@ enable+start `gnome-remote-desktop.service`. Auth = 2 layers: shared gate creds Listening socket + TLS + enable NOT enough alone. TPM warn `Init TPM credentials failed ... using GKeyFile as fallback` = harmless on TPM-less host (creds → keyfile). Connect: client → ip:3389, accept self-signed cert, gate creds, then GDM user. Supersedes LRN-003 for Wayland GNOME. + +## LRN-005 — df --output=pcent is GNU-only → keep /etc/profile.d disk scripts Linux-gated +2026-06-24. `df --output=pcent` (and `/etc/profile.d` itself) are GNU coreutils / Debian conventions, +absent on macOS BSD df. Any install step deploying such a snippet system-wide must sit inside the +`command -v apt-get` (Linux) block, never the OS-agnostic path. Deploy idempotently with +`sudo install -D -m 0644 src /etc/profile.d/x.sh` (-D makes the dir, overwrite = re-runnable). Caveat: +`/etc/profile.d/*.sh` runs for LOGIN shells only — non-login terminals need `/etc/bash.bashrc` instead. diff --git a/CLAUDE.md b/CLAUDE.md index c8506a4..41df39b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -22,6 +22,7 @@ vim/autoload/ pathogen loader (committed) vim/colors/ molokai colorscheme (committed) bash/bashrc-{linux,osx} OS-detected bashrc bin/{dt,dtach-router,claude-provider} CLI scripts deployed to ~/.local/bin +etc/profile.d/disk-usage-warning.sh login-time low-disk warning → /etc/profile.d (Linux only) .claude/{tasks,memory,audits}/ Claude working state ``` diff --git a/README.md b/README.md index d3970b9..951424a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/master/remote-instal | `bin/dt` | dtach session manager for claude-in-dtach sessions. | | `bin/dtach-router` | SSH-login dashboard to resume dtach sessions (sourced from bashrc). | | `bin/claude-provider`| Switch Claude Code between Anthropic and OpenRouter. | +| `etc/profile.d/disk-usage-warning.sh` | Login-time warning (bold red) when `/` or `/home` cross 85% usage. Deployed to `/etc/profile.d/` on Linux. | ## Install @@ -57,6 +58,7 @@ What it does: 6. Picks the bashrc by OS: macOS → `bashrc-osx` (falls back to `bashrc-linux` if missing), everything else → `bashrc-linux`. Copies it to `~/.bashrc`. 7. Installs Python CLIs via `pipx` (`PyMuPDF` → `pymupdf`, `Markdown` → `markdown_py`) — skipped if `pipx` is absent. 8. Copies the `bin/` scripts (`dt`, `dtach-router`, `claude-provider`) into `~/.local/bin`. +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. ### Packages installed (apt) diff --git a/etc/profile.d/disk-usage-warning.sh b/etc/profile.d/disk-usage-warning.sh new file mode 100644 index 0000000..fc00efa --- /dev/null +++ b/etc/profile.d/disk-usage-warning.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# disk-usage-warning.sh — login-time low-disk warning. +# Deployed to /etc/profile.d/ by install.sh, so every login shell sources it. +# Warns in bold red when / or /home crosses THRESHOLD% usage. +THRESHOLD=85 + +check_disk() { + mount_point="$1" + usage=$(df "$mount_point" --output=pcent 2>/dev/null | tail -1 | tr -dc '0-9') + [ -z "$usage" ] && return + if [ "$usage" -ge "$THRESHOLD" ]; then + printf '\033[1;31m' # rouge gras + printf '⚠ WARNING: %s à %s%% (seuil %s%%)\n' "$mount_point" "$usage" "$THRESHOLD" + printf '\033[0m' + fi +} + +check_disk /home +check_disk / diff --git a/install.sh b/install.sh index ca444d8..eade4c8 100755 --- a/install.sh +++ b/install.sh @@ -102,6 +102,17 @@ setup_remote_desktop() { sudo systemctl restart gnome-remote-desktop.service } +# Disk-usage login warning: a profile.d snippet that warns (bold red) at login when +# / or /home cross the usage threshold. Deployed system-wide so every login shell +# sources it. /etc/profile.d is a Debian/Ubuntu convention and df --output=pcent is +# GNU-only, so this is Linux-only (called from the apt-get block). Idempotent: install +# overwrites in place and -D creates the dir if missing. +install_disk_warning() { + echo "Installing disk-usage login warning to /etc/profile.d" + sudo install -D -m 0644 "$SCRIPT_DIR/etc/profile.d/disk-usage-warning.sh" \ + /etc/profile.d/disk-usage-warning.sh +} + # System packages: Debian/Ubuntu only. Skipped where apt-get is absent (e.g. macOS). if command -v apt-get >/dev/null 2>&1; then sudo apt-get update @@ -127,6 +138,9 @@ if command -v apt-get >/dev/null 2>&1; then # Remote desktop (gnome-remote-desktop — see the function header for why not xrdp). setup_remote_desktop + + # Low-disk login warning (system-wide profile.d snippet). + install_disk_warning else echo "apt-get not found — skipping system packages (install vim/git manually)." fi