modules 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/sh
  2. # Begin /etc/init.d/modules
  3. ### BEGIN INIT INFO
  4. # Provides: modules
  5. # Required-Start: mountkernfs sysctl
  6. # Should-Start:
  7. # Required-Stop:
  8. # Should-Stop:
  9. # Default-Start: S
  10. # Default-Stop:
  11. # Short-Description: Loads required modules.
  12. # Description: Loads modules listed in /etc/sysconfig/modules.
  13. # X-LFS-Default-Start: S10
  14. # X-LFS-Default-Stop:
  15. # X-LFS-Provided-By: LFS
  16. ### END INIT INFO
  17. . /lib/lsb/init-functions
  18. # Assure that the kernel has module support.
  19. [ -e /proc/ksyms -o -e /proc/modules ] || exit 0
  20. case "${1}" in
  21. start)
  22. # Exit if there's no modules file or there are no
  23. # valid entries
  24. [ -r /etc/sysconfig/modules ] &&
  25. egrep -qv '^($|#)' /etc/sysconfig/modules ||
  26. exit 0
  27. # If proc is mounted, find the current kernel
  28. # message level
  29. if [ -f /proc/sys/kernel/printk ]; then
  30. prev_msg=`cat /proc/sys/kernel/printk | \
  31. sed 'l 1' | sed -n '2~0p' | \
  32. sed 's/\\\//'`
  33. else
  34. prev_msg="6"
  35. fi
  36. # Now set the message level to 1 so not to make too
  37. # much noise when loading modules
  38. dmesg -n 1
  39. # Only try to load modules if the user has actually given us
  40. # some modules to load.
  41. if egrep -qv '^(#|$)' /etc/sysconfig/modules 2>/dev/null
  42. then
  43. # Read in the configuration file.
  44. exec 9>&0 < /etc/sysconfig/modules
  45. message="${INFO}Loading modules:"
  46. while read module args
  47. do
  48. # Ignore comments and blank lines.
  49. case "${module}" in
  50. ""|\#*) continue ;;
  51. esac
  52. # Attempt to load the module, making
  53. # sure to pass any arguments provided.
  54. modprobe ${module} ${args} > /dev/null
  55. # Print the module name if successful,
  56. # otherwise take note.
  57. if [ ${?} -eq 0 ]; then
  58. message="${message}${NORMAL} ${module}"
  59. else
  60. failedmod="${failedmod} ${module}"
  61. fi
  62. done
  63. # Print a message about successfully loaded
  64. # modules on the correct line.
  65. log_success_msg "${message}"
  66. # Print a failure message with a list of any
  67. # modules that may have failed to load.
  68. if [ "${failedmod}" ]; then
  69. log_failure_msg "${FAILURE}Failed to load modules:${failedmod}"
  70. fi
  71. exec 0>&9 9>&-
  72. fi
  73. # Set the kernel message level back to it's previous value.
  74. dmesg -n "${prev_msg}"
  75. ;;
  76. *)
  77. echo "Usage: ${0} {start}"
  78. exit 1
  79. ;;
  80. esac
  81. # End /etc/init.d/modules