diff --git a/udev-netif-hotplug-handler/.footprint b/udev-netif-hotplug-handler/.footprint new file mode 100644 index 000000000..b3e096a09 --- /dev/null +++ b/udev-netif-hotplug-handler/.footprint @@ -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 diff --git a/udev-netif-hotplug-handler/.md5sum b/udev-netif-hotplug-handler/.md5sum new file mode 100644 index 000000000..ef689f01f --- /dev/null +++ b/udev-netif-hotplug-handler/.md5sum @@ -0,0 +1,2 @@ +7bf9a4d9a27373c7402735fbd3ff1f1f 26-crux-netif.rules +7e3eef4cd843bf9c4b53b0e2d83abedc netif_handler diff --git a/udev-netif-hotplug-handler/26-crux-netif.rules b/udev-netif-hotplug-handler/26-crux-netif.rules new file mode 100644 index 000000000..4bd5d2b96 --- /dev/null +++ b/udev-netif-hotplug-handler/26-crux-netif.rules @@ -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" diff --git a/udev-netif-hotplug-handler/Pkgfile b/udev-netif-hotplug-handler/Pkgfile new file mode 100644 index 000000000..dcbdaaf81 --- /dev/null +++ b/udev-netif-hotplug-handler/Pkgfile @@ -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 +} diff --git a/udev-netif-hotplug-handler/README b/udev-netif-hotplug-handler/README new file mode 100644 index 000000000..df892d3b6 --- /dev/null +++ b/udev-netif-hotplug-handler/README @@ -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. [start|stop] +where 'ifname' is the name of the interface, i.e. eth0, ath0, usb0 etc. diff --git a/udev-netif-hotplug-handler/netif_handler b/udev-netif-hotplug-handler/netif_handler new file mode 100644 index 000000000..483878b99 --- /dev/null +++ b/udev-netif-hotplug-handler/netif_handler @@ -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"