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