File: isapnp.rc

package info (click to toggle)
hotplug 0.0.20040329-22
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 448 kB
  • ctags: 22
  • sloc: sh: 671; makefile: 183
file content (73 lines) | stat: -rw-r--r-- 1,718 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh -e
#
# isapnp.rc	synthesizes isapnp hotplug events at boot time
#		it requires a 2.6 kernel with CONFIG_ISAPNP defined
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#	
#  Copyright (C) 2004 Simone Gotti <simone.gotti@email.it>
#  Copyright (C) 2004 Marco d'Itri <md@linux.it>
#

# only 2.6 kernels are supported
[ -d /sys/bus/pnp/devices/ ] || exit 0

cd /etc/hotplug
. ./hotplug.functions

isapnp_boot_events()
{
    if [ "$(echo /sys/bus/pnp/devices/*/id)" = "/sys/bus/pnp/devices/*/id" ];
    then
	return 0
    fi

    cat /sys/bus/pnp/devices/*/id \
    | while read PNPID; do
	# get the name of the module which should be loaded
	MODULE=$(modprobe --show-depends -q pnp:d$PNPID \
		| sed -e '$!d;s/.*\/\(.*\)\.ko .*/\1/')

	case "$MODULE" in
	"")			# continue if there is no alias available
	    continue
	    ;;
	install*)		# skip the blacklist check if install is used
	    MODULE="pnp:d$PNPID"
	    ;;
	*)			# ignore blacklisted devices
	    if is_blacklisted $MODULE; then
		mesg "     $MODULE: blacklisted"
		continue
	    fi
	    ;;
	esac

	# see do_pnp_entry() in /usr/src/linux/scripts/file2alias.c
	if $MODPROBE -q $MODULE; then
	    mesg "     $MODULE: loaded sucessfully"
	else
	    mesg "     $MODULE: can't be loaded"
	fi
    done
}

# See how we were called.
case "$1" in
    start|restart)
	isapnp_boot_events
	;;
    stop)
	# echo "isapnp stop -- ignored"
	;;
    status)
	# echo "isapnp status -- ignored"
	;;
    *)
	echo "Usage: $0 {start|stop|status|restart}"
	exit 1
esac