modules 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin modules
  4. #
  5. # Description : Module auto-loading script
  6. #
  7. # Authors : Zack Winkles
  8. # DJ Lucas - dj@linuxfromscratch.org
  9. # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
  10. #
  11. # Version : LFS 7.0
  12. #
  13. ########################################################################
  14. ### BEGIN INIT INFO
  15. # Provides: modules
  16. # Required-Start: mountvirtfs sysctl
  17. # Should-Start:
  18. # Required-Stop:
  19. # Should-Stop:
  20. # Default-Start: S
  21. # Default-Stop:
  22. # Short-Description: Loads required modules.
  23. # Description: Loads modules listed in /etc/sysconfig/modules.
  24. # X-LFS-Provided-By: LFS
  25. ### END INIT INFO
  26. # Assure that the kernel has module support.
  27. [ -e /proc/modules ] || exit 0
  28. . /lib/lsb/init-functions
  29. case "${1}" in
  30. start)
  31. # Exit if there's no modules file or there are no
  32. # valid entries
  33. [ -r /etc/sysconfig/modules ] || exit 0
  34. egrep -qv '^($|#)' /etc/sysconfig/modules || exit 0
  35. log_info_msg "Loading modules:"
  36. # Only try to load modules if the user has actually given us
  37. # some modules to load.
  38. while read module args; do
  39. # Ignore comments and blank lines.
  40. case "$module" in
  41. ""|"#"*) continue ;;
  42. esac
  43. # Attempt to load the module, passing any arguments provided.
  44. modprobe ${module} ${args} >/dev/null
  45. # Print the module name if successful, otherwise take note.
  46. if [ $? -eq 0 ]; then
  47. log_info_msg2 " ${module}"
  48. else
  49. failedmod="${failedmod} ${module}"
  50. fi
  51. done < /etc/sysconfig/modules
  52. # Print a message about successfully loaded modules on the correct line.
  53. log_success_msg2
  54. # Print a failure message with a list of any modules that
  55. # may have failed to load.
  56. if [ -n "${failedmod}" ]; then
  57. log_failure_msg "Failed to load modules:${failedmod}"
  58. exit 1
  59. fi
  60. ;;
  61. *)
  62. echo "Usage: ${0} {start}"
  63. exit 1
  64. ;;
  65. esac
  66. exit 0
  67. # End modules