File: module-init-tools.init

package info (click to toggle)
module-init-tools 3.2-pre1-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 384 kB
  • ctags: 27
  • sloc: sh: 566; makefile: 217
file content (55 lines) | stat: -rw-r--r-- 1,320 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/sh -e

# Silently exit if the kernel does not support modules or needs modutils.
[ -f /proc/modules ] || exit 0
[ ! -f /proc/ksyms ] || exit 0
[ -x /sbin/depmod  ] || exit 0

PATH="/sbin:/bin"

KVER=$(uname -r)
KMAJ=${KVER%${KVER#*.*[^.]}}
KMAJ=${KMAJ%.}

if [ -w /lib/modules/$KVER/ ]; then
  echo -n "Calculating module dependencies... "
  depmod --quick
  echo "done."
else
  echo "Not running depmod because /lib/modules/$KVER/ is not writeable."
fi

if [ -e /etc/modules-$KVER ]; then
  MODULES_FILE=/etc/modules-$KVER
elif [ -e /etc/modules-$KMAJ ]; then
  MODULES_FILE=/etc/modules-$KMAJ
else
  MODULES_FILE=/etc/modules
fi

# Loop over every line in /etc/modules.
echo 'Loading modules...'
grep '^[^#]' $MODULES_FILE | \
while read module args; do
  [ "$module" ] || continue
  echo "    $module"
  modprobe $module $args || true
done
echo "All modules loaded."

# Just in case a sysadmin prefers generic symbolic links in
# /lib/modules/boot for boot time modules we will load these modules.
boot="$(modprobe --list --type boot)"
for d in $boot; do
    mod="${d##*/}"
    mod="${mod%.ko}"
    modprobe "$mod"
done

if [ -r /etc/modprobe.conf ] \
	&& ! grep -q '^include.*modprobe.d' /etc/modprobe.conf; then
   echo 'WARNING: /etc/modprobe.conf exists but does not include /etc/modprobe.d/!'
fi

exit 0