confd: Notify user of all bootstrapping issues via login banners

Collect all bootstrapping issues in all banner-like files during boot,
so that they are presented to the user when logging in. This should
make it harder to miss overlook the fact that a system is running in a
degraded state.
This commit is contained in:
Tobias Waldekranz
2023-11-30 11:39:42 +01:00
parent af2b1f95a9
commit 445fbf7873
2 changed files with 20 additions and 3 deletions
+5 -3
View File
@@ -80,9 +80,11 @@ console_error()
[ -z "$STATUS" ] || return
STATUS="CRITICAL ERROR: $1"
printf "\n$PRETTY_NAME\n%s\n\n" "$STATUS" | tee /etc/banner > /etc/issue.net
printf "\n$PRETTY_NAME (console)\n%s\n\n" "$STATUS" > /etc/issue
printf "\n$STATUS\n" | tee -a \
/etc/banner \
/etc/issue \
/etc/issue.net \
>/dev/null
return 0
}
+15
View File
@@ -9,6 +9,17 @@
#
set -e
banner_append()
{
printf "\n$@\n" | tee -a \
/etc/banner \
/etc/issue \
/etc/issue.net \
>/dev/null
return 0
}
# shellcheck disable=SC1091
. /etc/confdrc
@@ -35,6 +46,7 @@ if ! sysrepocfg -v3 -I"$fn" -f json; then
;;
failure-config)
logger -sik -p user.error "Failed loading $fn, aborting!"
banner_append "CRITICAL ERROR: Logins are disabled, no credentials available"
initctl -nbq runlevel 9
;;
esac
@@ -42,3 +54,6 @@ if ! sysrepocfg -v3 -I"$fn" -f json; then
exit 1
fi
logger -sik -p user.notice "Loaded $fn successfully."
if [ "$config" = "failure-config" ]; then
banner_append "ERROR: Corrupt startup-config, system has reverted to default login credentials"
fi