D.4.
/etc/rc.d/init.d/consolelog
#!/bin/sh
########################################################################
# Begin consolelog
#
# Description : Set the kernel log level for the console
#
# Authors : Dan Nicholson - [email protected]
# Authors : Gerard Beekmans - [email protected]
# Update : Bruce Dubbs - [email protected]
#
# Version : LFS 7.0
#
# Notes : /proc must be mounted before this can run
#
########################################################################
### BEGIN INIT INFO
# Provides: consolelog
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Sets the console log level.
# Description: Sets the console log level.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/boot/functions
# set the default loglevel
LOGLEVEL=7
[ -r /etc/sysconfig/console ] && . /etc/sysconfig/console
case "${1}" in
start)
case "$LOGLEVEL" in
[1-8])
boot_mesg "Setting the console log level to ${LOGLEVEL}..."
dmesg -n $LOGLEVEL
evaluate_retval
;;
*)
boot_mesg "Console log level '${LOGLEVEL}' is invalid" ${FAILURE}
echo_failure
;;
esac
;;
status)
# Read the current value if possible
if [ -r /proc/sys/kernel/printk ]; then
read level line < /proc/sys/kernel/printk
else
boot_mesg "Can't read the current console log level" ${FAILURE}
echo_failure
fi
# Print the value
if [ -n "$level" ]; then
${ECHO} -e "${INFO}The current console log level is ${level}${NORMAL}"
fi
;;
*)
echo "Usage: ${0} {start|status}"
exit 1
;;
esac
# End consolelog