From 03cbd49af221af2a9484ce1d775116339cd2ed3c Mon Sep 17 00:00:00 2001 From: moritzrfs Date: Sun, 14 Jun 2026 13:32:41 +0200 Subject: [PATCH] Update motd --- bootstrap.sh | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index ce04186..61789bd 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -143,7 +143,8 @@ mod_neovim() { mod_motd() { step "welcome message / motd" - # disable distro default motd noise where safe + + # 1. install our dynamic banner + disable noisy distro defaults if [[ -d /etc/update-motd.d ]]; then for f in /etc/update-motd.d/10-help-text /etc/update-motd.d/50-motd-news \ /etc/update-motd.d/00-header; do @@ -155,13 +156,51 @@ mod_motd() { < "${SCRIPT_DIR}/config/motd/01-banner.sh"; then ok "dynamic motd installed" else - log "motd already up to date" + log "banner already up to date" fi else - # fallback: static /etc/motd "${SCRIPT_DIR}/config/motd/01-banner.sh" 2>/dev/null | $SUDO tee /etc/motd >/dev/null ok "static /etc/motd written" fi + + # 2. clear the static /etc/motd (debian license blurb), idempotently + if [[ -d /etc/update-motd.d && -s /etc/motd ]]; then + $SUDO truncate -s 0 /etc/motd 2>/dev/null || $SUDO sh -c ': > /etc/motd' + ok "cleared static /etc/motd" + fi + + # 3. neutralize third-party login banners (e.g. ProxmoxVE community-scripts). + # matched by *content* so unrelated scripts and our own files stay untouched. + local sig='community-scripts|Provided by:|LXC Container|tteck' + local hit found=0 + + # profile.d is sourced -> chmod -x is useless; rename out of the *.sh glob. + # only consider real *.sh (never our already-renamed *.disabled). + if [[ -d /etc/profile.d ]]; then + while IFS= read -r hit; do + [[ -n "$hit" ]] || continue + case "$hit" in */zz-bootstrap-aliases.sh) continue ;; esac + $SUDO mv "$hit" "${hit}.disabled" + ok "disabled banner: ${hit##*/} (-> .disabled)" + found=1 + done < <($SUDO grep -rlE "$sig" --include='*.sh' /etc/profile.d 2>/dev/null || true) + fi + + # update-motd.d is executed -> dropping +x is enough (and idempotent). + if [[ -d /etc/update-motd.d ]]; then + while IFS= read -r hit; do + [[ -n "$hit" ]] || continue + case "$hit" in */01-bootstrap-banner) continue ;; esac + if [[ -x "$hit" ]]; then + $SUDO chmod -x "$hit" + ok "disabled banner: ${hit##*/}" + found=1 + fi + done < <($SUDO grep -rlE "$sig" /etc/update-motd.d 2>/dev/null || true) + fi + + [[ $found -eq 0 ]] && log "no third-party login banners found" + return 0 } mod_shell() {