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