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 |
|
---|
15 | ### BEGIN INIT INFO
|
---|
16 | # Provides: modules
|
---|
17 | # Required-Start: mountvirtfs sysctl
|
---|
18 | # Should-Start:
|
---|
19 | # Required-Stop:
|
---|
20 | # Should-Stop:
|
---|
21 | # Default-Start: S
|
---|
22 | # Default-Stop:
|
---|
23 | # Short-Description: Loads required modules.
|
---|
24 | # Description: Loads modules listed in /etc/sysconfig/modules.
|
---|
25 | # X-LFS-Provided-By: LFS
|
---|
26 | ### END INIT INFO
|
---|
27 |
|
---|
28 | # Assure that the kernel has module support.
|
---|
29 | [ -e /proc/modules ] || exit 0
|
---|
30 |
|
---|
31 | . /lib/lsb/init-functions
|
---|
32 |
|
---|
33 | case "${1}" in
|
---|
34 | start)
|
---|
35 | # Exit if there's no modules file or there are no
|
---|
36 | # valid entries
|
---|
37 | [ -r /etc/sysconfig/modules ] || exit 0
|
---|
38 | egrep -qv '^($|#)' /etc/sysconfig/modules || exit 0
|
---|
39 |
|
---|
40 | log_info_msg "Loading modules:"
|
---|
41 |
|
---|
42 | # Only try to load modules if the user has actually given us
|
---|
43 | # some modules to load.
|
---|
44 |
|
---|
45 | while read module args; do
|
---|
46 |
|
---|
47 | # Ignore comments and blank lines.
|
---|
48 | case "$module" in
|
---|
49 | ""|"#"*) continue ;;
|
---|
50 | esac
|
---|
51 |
|
---|
52 | # Attempt to load the module, passing any arguments provided.
|
---|
53 | modprobe ${module} ${args} >/dev/null
|
---|
54 |
|
---|
55 | # Print the module name if successful, otherwise take note.
|
---|
56 | if [ $? -eq 0 ]; then
|
---|
57 | log_info_msg2 " ${module}"
|
---|
58 | else
|
---|
59 | failedmod="${failedmod} ${module}"
|
---|
60 | fi
|
---|
61 | done < /etc/sysconfig/modules
|
---|
62 |
|
---|
63 | # Print a message about successfully loaded modules on the correct line.
|
---|
64 | log_success_msg2
|
---|
65 |
|
---|
66 | # Print a failure message with a list of any modules that
|
---|
67 | # may have failed to load.
|
---|
68 | if [ -n "${failedmod}" ]; then
|
---|
69 | log_failure_msg "Failed to load modules:${failedmod}"
|
---|
70 | exit 1
|
---|
71 | fi
|
---|
72 | ;;
|
---|
73 |
|
---|
74 | *)
|
---|
75 | echo "Usage: ${0} {start}"
|
---|
76 | exit 1
|
---|
77 | ;;
|
---|
78 | esac
|
---|
79 |
|
---|
80 | exit 0
|
---|
81 |
|
---|
82 | # End modules
|
---|