udev-netif-hotplug-handler: initial commit

This commit is contained in:
Johannes Winkelmann 2006-08-23 19:48:06 +00:00
parent bc189a8ea2
commit 28b6583412
6 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,7 @@
drwxr-xr-x root/root etc/
drwxr-xr-x root/root etc/udev/
drwxr-xr-x root/root etc/udev/rules.d/
-rw-r--r-- root/root etc/udev/rules.d/26-crux-netif.rules
drwxr-xr-x root/root lib/
drwxr-xr-x root/root lib/udev/
-rwxr-xr-x root/root lib/udev/netif_handler

View File

@ -0,0 +1,2 @@
7bf9a4d9a27373c7402735fbd3ff1f1f 26-crux-netif.rules
7e3eef4cd843bf9c4b53b0e2d83abedc netif_handler

View File

@ -0,0 +1,3 @@
# Network hotplugging
ACTION=="add", SUBSYSTEM=="net", ENV{INTERFACE}=="*", RUN+="/lib/udev/netif_handler"
ACTION=="remove", SUBSYSTEM=="net", ENV{INTERFACE}=="*", RUN+="/lib/udev/netif_handler"

View File

@ -0,0 +1,15 @@
# Maintainer: Johannes Winkelmann, jw at smts dot ch
# Description: udev network interface hotplug handler
# URL: http://crux.nu/
# Depends on: udev
name=udev-netif-hotplug-handler
version=1.2
release=1
source=(netif_handler 26-crux-netif.rules)
build() {
install -m 755 -D netif_handler $PKG/lib/udev/netif_handler
install -m 644 -D 26-crux-netif.rules \
$PKG/etc/udev/rules.d/26-crux-netif.rules
}

View File

@ -0,0 +1,6 @@
This port implements a hotplug handler for network devices, allowing to react
on hotplug events i.e. to assign an IP.
Once active, a handler script will call
/etc/rc.d/net.<ifname> [start|stop]
where 'ifname' is the name of the interface, i.e. eth0, ath0, usb0 etc.

View File

@ -0,0 +1,47 @@
#!/bin/bash
# udev network interface starter
# adapted from
# http://linuxfromscratch.org/pipermail/cross-lfs/2006-January/001042.html
#
# Johannes Winkelmann, jw at smts dot ch
version=1.2
DEBUG=no
log() {
logger $*
}
debug() {
if [ x"$DEBUG" = "xyes" ]; then
log $*
fi
}
# validate $INTERFACE
case "$INTERFACE" in
"")
debug_log "$call: empty device; exiting"
exit 1
;;
ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
debug_log "assuming $INTERFACE is already up"
exit 0
;;
esac
# valid interface, try calling the appropriate handler
call=`basename $0`
if [ ! -f /etc/rc.d/net.$INTERFACE ]; then
debug_log "$call: not found: /etc/rc.d/net.$INTERFACE"
exit 0
fi
if [ "$ACTION" = "add" ]; then
command=start
else
command=stop
fi
/etc/rc.d/net.$INTERFACE $command
log "$call $INTERFACE $command"