summaryrefslogtreecommitdiff
path: root/etc/rc.lkm
blob: 6c54fa0d49d754f35419c5c72c165a2ab284a09e (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#	$NetBSD: rc.lkm,v 1.9 2005/03/04 21:11:23 cube Exp $
#
# this script loads or unloads LKMs (loadable kernel modules).

if [ -s /etc/lkm.conf ]; then
	case "$1" in
	start)
		(while read path options entry postinstall output when; do
			flags=''
	
			case $path in
			\#*|"")
				continue
				;;
			/*)
				;;
			*)
				if [ -f "/lkm/$path" ]; then
					path="/lkm/$path"
				elif [ -f "/usr/lkm/$path" ]; then
					path="/usr/lkm/$path"
				else
					echo "couldn't find module $path"
				fi
				;;
			esac
	
			case $options in
			-)
				;;
			*)
				flags="$flags $options"
				;;
			esac
	
			case $entry in
			-)
				;;
			*)
				flags="$flags -e $entry"
				;;
			esac
	
			case $postinstall in
			-)
				;;
			*)
				flags="$flags -p $postinstall"
				;;
			esac
	
			case $output in
			-)
				;;
			*)
				if [ "$output" = TEMP ]; then
					flags="$flags -o /tmp/lkm.$$"
				else
					flags="$flags -o $output"
				fi
				;;
			esac
	
			case $when in
			-)
				when=BEFORENET
				;;
			[A-Z]*)
					;;
			*)
				echo "invalid \"when\" field \`${when}' in /etc/lkm.conf - $path not loaded!"
				continue
				;;
			esac
	
			if [ "$when" != "$lkmstage" ]; then
				continue
			fi
	
			echo -n "${path##*/}: "
			modload $flags $path
			rm -f /tmp/lkm.$$
		done) < /etc/lkm.conf
		;;
	stop)
		(while read path options entry postinstall output when; do
			case $path in
			\#*|"")
				continue
				;;
			/*)
				name=${path##*/}
				name=${name%.o}
				;;
			*)
				name=${path%.o}
				;;
			esac

			if [ "$when" = "$lkmstage" ]; then
				modunload -n ${name}
			fi
		done) < /etc/lkm.conf
		;;
	esac
fi