#!/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 \
    | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
    | while read MODULE; do
	# ignore blacklisted devices
	if grep -qi "^$MODULE\$" /etc/hotplug/blacklist; then
	    return 0
	fi

	# see do_pnp_entry() in /usr/src/linux/scripts/file2alias.c
	if $MODPROBE -q pnp:d$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

