consolelog 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/sh
  2. # Begin $rc_base/init.d/consolelog
  3. ########################################################################
  4. #
  5. # Description : Set the kernel log level for the console
  6. #
  7. # Authors : Dan Nicholson - dnicholson@linuxfromscratch.org
  8. #
  9. # Version : 00.00
  10. #
  11. # Notes : /proc must be mounted before this can run
  12. #
  13. ########################################################################
  14. . /etc/sysconfig/rc
  15. . ${rc_functions}
  16. # set the default loglevel
  17. LOGLEVEL=7
  18. if [ -r /etc/sysconfig/console ]; then
  19. . /etc/sysconfig/console
  20. fi
  21. case "${1}" in
  22. start)
  23. case "$LOGLEVEL" in
  24. [1-8])
  25. boot_mesg "Setting the console log level to ${LOGLEVEL}..."
  26. dmesg -n $LOGLEVEL
  27. evaluate_retval
  28. ;;
  29. *)
  30. boot_mesg "Console log level '${LOGLEVEL}' is invalid" ${FAILURE}
  31. echo_failure
  32. ;;
  33. esac
  34. ;;
  35. status)
  36. # Read the current value if possible
  37. if [ -r /proc/sys/kernel/printk ]; then
  38. read level line < /proc/sys/kernel/printk
  39. else
  40. boot_mesg "Can't read the current console log level" ${FAILURE}
  41. echo_failure
  42. fi
  43. # Print the value
  44. if [ -n "$level" ]; then
  45. ${ECHO} -e "${INFO}The current console log level" \
  46. "is ${level}${NORMAL}"
  47. fi
  48. ;;
  49. *)
  50. echo "Usage: ${0} {start|status}"
  51. exit 1
  52. ;;
  53. esac
  54. # End $rc_base/init.d/consolelog