#!/bin/ash # # This version of /sbin/hotplug should works on most GNU/Linux systems # using Linux 2.2.18+ or 2.4.* kernels. On 2.2.*, only USB has such # hotplugging support; on 2.4.*, so do PCI/Cardbus and network interfaces. # # The kernel HOTPLUG configuration option needs to be enabled, and KMOD # will normally be enabled so that kernels needn't statically link every # known driver. # # # HISTORY: # # 27-Jan-2001 Minor updates, Gioele Barabucci # 04-Jan-2001 First "New" version, which only delegates to # specialized hotplug agents. # 2001-Dec-19 modified to work with ash instead of bash # # $Id: hotplug,v 1.3 2001/02/14 18:21:27 dbrownell Exp $ # HOTPLUG_DIR=/etc/hotplug cd ${HOTPLUG_DIR} # ash "." fn does not start with current dir, use absolute path to fix . ${HOTPLUG_DIR}/hotplug.functions [ "$DEBUG" != "" ] && mesg "arguments ($*) env (`env`)" # # Only one required argument: event type type being dispatched. # Examples: usb, pci, isapnp, net, ieee1394, printer, disk, # parport, ... # if [ $# -lt 1 -o "$1" = help -o "$1" = '--help' ]; then if [ -t ]; then echo "Usage: $0 AgentName ..." AGENTS="" for AGENT in /etc/hotplug/*.agent ; do TYPE=`basename $AGENT | sed s/.agent//` if [ -x $AGENT ] ; then AGENTS="$AGENTS $TYPE" else AGENTS="$AGENTS ($TYPE)" fi done echo "AgentName values on this system: $AGENTS" echo "Most agents also require particular environment parameters." else mesg "illegal usage $*" fi exit 1 fi AGENT=/etc/hotplug/$1.agent # # Delegate event handling: # /sbin/hotplug FOO ..args.. ==> /etc/hotplug/FOO.agent ..args.. # if [ -x $AGENT ]; then shift if [ "$DEBUG" != "" ]; then mesg "invoke $AGENT" fi exec $AGENT "$@" mesg "couldn't exec $AGENT" exit 1 fi mesg "no runnable $AGENT is installed" exit 1