Update motd
This commit is contained in:
45
bootstrap.sh
45
bootstrap.sh
@@ -143,7 +143,8 @@ mod_neovim() {
|
|||||||
|
|
||||||
mod_motd() {
|
mod_motd() {
|
||||||
step "welcome message / 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
|
if [[ -d /etc/update-motd.d ]]; then
|
||||||
for f in /etc/update-motd.d/10-help-text /etc/update-motd.d/50-motd-news \
|
for f in /etc/update-motd.d/10-help-text /etc/update-motd.d/50-motd-news \
|
||||||
/etc/update-motd.d/00-header; do
|
/etc/update-motd.d/00-header; do
|
||||||
@@ -155,13 +156,51 @@ mod_motd() {
|
|||||||
< "${SCRIPT_DIR}/config/motd/01-banner.sh"; then
|
< "${SCRIPT_DIR}/config/motd/01-banner.sh"; then
|
||||||
ok "dynamic motd installed"
|
ok "dynamic motd installed"
|
||||||
else
|
else
|
||||||
log "motd already up to date"
|
log "banner already up to date"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
# fallback: static /etc/motd
|
|
||||||
"${SCRIPT_DIR}/config/motd/01-banner.sh" 2>/dev/null | $SUDO tee /etc/motd >/dev/null
|
"${SCRIPT_DIR}/config/motd/01-banner.sh" 2>/dev/null | $SUDO tee /etc/motd >/dev/null
|
||||||
ok "static /etc/motd written"
|
ok "static /etc/motd written"
|
||||||
fi
|
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() {
|
mod_shell() {
|
||||||
|
|||||||
Reference in New Issue
Block a user