feat(install): system-wide low-disk login warning via /etc/profile.d

Add etc/profile.d/disk-usage-warning.sh (POSIX sh) that warns in bold
red at login when / or /home cross 85% usage. Deployed system-wide via
install_disk_warning() (sudo install -D -m 0644), gated inside the
apt-get block since df --output=pcent and /etc/profile.d are GNU/Debian
conventions absent on macOS. Idempotent and re-runnable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CN1KSmsuLG6TxSeN5m8xvM
This commit is contained in:
Bastien Chanot
2026-06-24 18:00:17 +02:00
co-authored by Claude Opus 4.8
parent 57cdfeaf25
commit c0fddc6f94
7 changed files with 56 additions and 0 deletions
+14
View File
@@ -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