add hotplug stuff to trunk/
authorFelix Fietkau <nbd@openwrt.org>
Mon, 7 Nov 2005 01:12:51 +0000 (01:12 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 7 Nov 2005 01:12:51 +0000 (01:12 +0000)
SVN-Revision: 2364

26 files changed:
openwrt/package/base-files/Makefile
openwrt/package/base-files/default/etc/functions.sh
openwrt/package/base-files/default/etc/hotplug.d/net/01-wds [new file with mode: 0644]
openwrt/package/base-files/default/etc/hotplug.d/usb/01-mount [new file with mode: 0644]
openwrt/package/base-files/default/sbin/hotplug [new file with mode: 0755]
openwrt/package/base-files/default/sbin/ifdown
openwrt/package/base-files/default/usr/share/udhcpc/default.script
openwrt/package/base-files/files/hotplug [deleted file]
openwrt/package/base-files/ipkg/hotplug.control [deleted file]
openwrt/package/busybox/Makefile
openwrt/package/ntpclient/Makefile
openwrt/package/ntpclient/files/ntpclient.init
openwrt/package/ppp/Makefile
openwrt/package/ppp/files/etc/ppp/ip-down [new file with mode: 0755]
openwrt/package/ppp/files/etc/ppp/ip-up [new file with mode: 0755]
openwrt/package/ppp/files/ifup.pppoa
openwrt/package/ppp/files/ifup.pppoe
openwrt/package/pptp/Makefile
openwrt/package/pptp/files/ifup.pptp
openwrt/target/linux/imagebuilder/lists/default-annex-a.ar7-2.4
openwrt/target/linux/imagebuilder/lists/default-annex-b.ar7-2.4
openwrt/target/linux/imagebuilder/lists/micro.ar7-2.4
openwrt/target/linux/imagebuilder/lists/micro.brcm-2.4
openwrt/target/linux/imagebuilder/lists/micro.x86-2.4
openwrt/target/linux/imagebuilder/lists/pptp.brcm-2.4
openwrt/target/linux/imagebuilder/lists/pptp.x86-2.4

index 5f300f28456dff87004a71df65e44d12f9f60de3..adf2ffbb57bfa70ffc9b19f90b8f75b17b78333c 100644 (file)
@@ -3,7 +3,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=base-files
-PKG_RELEASE:=4
+PKG_RELEASE:=6
 PKG_BUILD_DIR:=$(BUILD_DIR)/base-files
 
 REV:=${shell svn info | grep Revision | cut -d ' ' -f 2}
@@ -16,9 +16,6 @@ include $(TOPDIR)/package/rules.mk
 IDIR_BASE:=$(PKG_BUILD_DIR)/base-files
 IPKG_BASE:=$(PACKAGE_DIR)/$(PKG_NAME)_$(PKG_RELEASE)_$(ARCH).ipk
 
-IDIR_HOTPLUG:=$(PKG_BUILD_DIR)/hotplug
-IPKG_HOTPLUG:=$(PACKAGE_DIR)/hotplug_$(PKG_RELEASE)_$(ARCH).ipk
-
 UCLIBC_VERSION:=${shell cat $(STAGING_DIR)/uclibc_version}
 IDIR_UCLIBC:=$(PKG_BUILD_DIR)/uclibc
 IPKG_UCLIBC:=$(PACKAGE_DIR)/uclibc_$(UCLIBC_VERSION)-$(PKG_RELEASE)_$(ARCH).ipk
@@ -27,7 +24,7 @@ LIBGCC_VERSION:=${shell cat $(STAGING_DIR)/gcc_version}
 IDIR_LIBGCC:=$(PKG_BUILD_DIR)/libgcc
 IPKG_LIBGCC:=$(PACKAGE_DIR)/libgcc_$(LIBGCC_VERSION)-$(PKG_RELEASE)_$(ARCH).ipk
 
-PACKAGES:=$(IPKG_BASE) $(IPKG_UCLIBC) $(IPKG_LIBGCC) $(IPKG_HOTPLUG)
+PACKAGES:=$(IPKG_BASE) $(IPKG_UCLIBC) $(IPKG_LIBGCC)
 
 $(PKG_BUILD_DIR)/.prepared:
        mkdir -p $(PKG_BUILD_DIR) $(PACKAGE_DIR)
@@ -74,12 +71,6 @@ $(IPKG_LIBGCC):
        -$(STRIP) $(IDIR_LIBGCC)/lib/*
        $(IPKG_BUILD) $(IDIR_LIBGCC) $(PACKAGE_DIR)
 
-$(IPKG_HOTPLUG):
-       $(SCRIPT_DIR)/make-ipkg-dir.sh $(IDIR_HOTPLUG) ipkg/hotplug.control $(PKG_RELEASE) $(ARCH)
-       mkdir -p $(IDIR_HOTPLUG)/sbin
-       install -m0755 files/hotplug $(IDIR_HOTPLUG)/sbin
-       $(IPKG_BUILD) $(IDIR_HOTPLUG) $(PACKAGE_DIR)
-       
 package-clean:
        rm -f $(PACKAGES)
        
index bc9767f49117892c1ae59985621362605e0e0458..9cfc8023579b38ba20438bab70d2ed443ba5808e 100755 (executable)
@@ -41,12 +41,14 @@ do_ifup() {
                $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
                ${gateway:+$DEBUG route add default gw $gateway}
 
-               [ -f /etc/resolv.conf ] && return
-
-               debug "# --- creating /etc/resolv.conf ---"
-               for dns in $(nvram get ${2}_dns); do
-                       echo "nameserver $dns" >> /etc/resolv.conf
-               done
+               [ -f /etc/resolv.conf ] || {
+                       debug "# --- creating /etc/resolv.conf ---"
+                       for dns in $(nvram get ${2}_dns); do
+                               echo "nameserver $dns" >> /etc/resolv.conf
+                       done
+               }
+               
+               env -i ACTION="ifup" INTERFACE="${2}" PROTO=static /sbin/hotplug "iface" &
        ;;
        dhcp)
                DHCP_IP=$(nvram get ${2}_ipaddr)
@@ -64,6 +66,7 @@ do_ifup() {
                        sleep 1
                        kill -9 $oldpid
                }
+               # hotplug events are handled by /usr/share/udhcpc/default.script
        ;;
        none|"")
        ;;
diff --git a/openwrt/package/base-files/default/etc/hotplug.d/net/01-wds b/openwrt/package/base-files/default/etc/hotplug.d/net/01-wds
new file mode 100644 (file)
index 0000000..38bd696
--- /dev/null
@@ -0,0 +1,5 @@
+[ "${INTERFACE%%[0-9]*}" = "wds" ] && { 
+       ifconfig $INTERFACE 0.0.0.0 up
+       /usr/sbin/brctl addif br0 $INTERFACE
+}
+               
diff --git a/openwrt/package/base-files/default/etc/hotplug.d/usb/01-mount b/openwrt/package/base-files/default/etc/hotplug.d/usb/01-mount
new file mode 100644 (file)
index 0000000..c28ada2
--- /dev/null
@@ -0,0 +1,49 @@
+mount_storage() {
+       cd /dev/discs
+       for dev in disc*; do
+               [ -f /tmp/.${dev}_id ] || {
+                       echo ${INTERFACE}${PRODUCT} > /tmp/.${dev}_id
+                       mount | grep /mnt/${dev} || (
+                               [ -d /mnt/. ] || {
+                                       mkdir -p /tmp/mnt
+                                       ln -s /tmp/mnt /
+                               }
+                               cd $dev
+                               for part in part*; do
+                                       path=/mnt/${dev}_${part##*part}
+                                       mkdir -p ${path}
+                                       mount ${part} ${path}
+                               done
+                       )
+               }
+       done
+}
+
+umount_storage() {
+       for tmp in /tmp/.*_id; do
+               id=$(cat $tmp 2>&-)
+               [ "${INTERFACE}${PRODUCT}" = "$id" ] && {
+                       rm -f $tmp
+                       disc=${tmp##*disc}
+                       disc=${disc%%_id}
+                       for disc in /mnt/disc${disc}*; do
+                               umount -f $disc || umount -l $disc
+                       done
+               }
+       done
+}
+
+[ -f /proc/bus/usb/devices ] || mount -t usbfs none /proc/bus/usb
+
+case "$ACTION" in
+       add)
+               case "${INTERFACE%%/*}" in
+                       8) mount_storage ;;
+               esac
+       ;;
+       remove)
+               case "${INTERFACE%%/*}" in
+                       8) umount_storage ;;
+               esac
+       ;;
+esac
diff --git a/openwrt/package/base-files/default/sbin/hotplug b/openwrt/package/base-files/default/sbin/hotplug
new file mode 100755 (executable)
index 0000000..57ee969
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+PATH=/bin:/sbin:/usr/bin:/usr/sbin
+LOGNAME=root
+USER=root
+export PATH LOGNAME USER
+
+[ \! -z "$1" -a -d /etc/hotplug.d/$1 ] && {
+       for script in $(ls /etc/hotplug.d/$1/* 2>&-); do (
+               [ -f $script ] && . $script
+       ); done
+}
index 1471369498243174a92adf57b5538b96a5d6e705..f2f8bbfe8168d9065aa3b30162c802a1ba346c5d 100755 (executable)
@@ -1,13 +1,19 @@
-#!/bin/ash
+#!/bin/sh
 [ $# = 0 ] && { echo "  $0 <group>"; exit; }
 . /etc/functions.sh
-. /etc/network.overrides
+. /etc/network.overrides  
 [ "$FAILSAFE" != "true" -a -e /etc/config/network ] && . /etc/config/network
+
 type=$1
 debug "### ifdown $type ###"
+
 if=$(nvram get ${type}_ifname)
 proto=$(nvram get ${type}_proto)
 if_valid $if && $DEBUG ifconfig $if down
 kill $(cat /var/run/${if}.pid 2>&-) 2>&-
-[ "$if" = "ppp0" ] && killall pppd
 killall ifup.$proto >&- 2>&-
+case "$proto" in
+       pptp|pppoe) killall pppd >&- 2>&- ;;
+       static) env -i ACTION="ifdown" INTERFACE="$if" PROTO=static /sbin/hotplug "iface" ;;
+esac
+
index 0c08985e717b4ca79db3a8bbd6e885e1102942a1..9fac6286c9ffcf1eb3b30a808d5899087845aee9 100755 (executable)
@@ -1,42 +1,51 @@
 #!/bin/sh
-# udhcpc script edited by Tim Riker <Tim@Rikers.org>
-# (slightly modified for OpenWrt)
-
 [ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
 
 RESOLV_CONF="/tmp/resolv.conf"
 
-case "$1" in
-        deconfig)
-                ifconfig $interface 0.0.0.0
-                ;;
-
-        renew|bound)
-                ifconfig $interface $ip \
-                netmask ${subnet:-255.255.255.0} \
-                broadcast ${broadcast:-+}
-
-                if [ -n "$router" ] ; then
-                        echo "deleting routers"
-                        while route del default gw 0.0.0.0 dev $interface ; do
-                                :
-                        done
-
-                        for i in $router ; do
-                                route add default gw $i dev $interface
-                        done
-                fi
-
-                echo -n > $RESOLV_CONF
-                ${domain:+echo search $domain} >> $RESOLV_CONF
-                for i in $dns ; do
-                        echo adding dns $i
-                        echo nameserver $i >> $RESOLV_CONF
+hotplug_event() {
+       nvram show 2>&- | grep _proto=dhcp | {
+               while :; do
+                       read FOO
+                       [ -z "$FOO" ] && break
+                       FOO="${FOO%%_*}"
+                       [ "$(nvram get ${FOO}_ifname)" = "${interface}" ] || continue
+                       env -i ACTION="$1" INTERFACE="${FOO}" PROTO=dhcp /sbin/hotplug iface
+               done
+       }
+}
 
+case "$1" in
+       deconfig)
+               ifconfig $interface 0.0.0.0
+               hotplug_event ifdown
+       ;;
+       renew|bound)
+               ifconfig $interface $ip \
+               netmask ${subnet:-255.255.255.0} \
+               broadcast ${broadcast:-+}
+
+               if [ -n "$router" ] ; then
+                       echo "deleting routers"
+                       while route del default gw 0.0.0.0 dev $interface ; do :; done
+                                       
+                       for i in $router ; do
+                               route add default gw $i dev $interface
+                       done
+               fi
+
+               echo -n > $RESOLV_CONF
+               ${domain:+echo search $domain} >> $RESOLV_CONF
+               for i in $dns ; do
+                       echo adding dns $i
+                       echo nameserver $i >> $RESOLV_CONF
+               done
+               
+               hotplug_event ifup
+               
                # user rules
                [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
-
-                done
-                ;;
+       ;;
 esac
+
 exit 0
diff --git a/openwrt/package/base-files/files/hotplug b/openwrt/package/base-files/files/hotplug
deleted file mode 100755 (executable)
index 74134e8..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/ash
-# $Id$
-[ "${INTERFACE%%[0-9]*}" = "wds" ] && { 
-       ifconfig $INTERFACE 0.0.0.0 up
-       /usr/sbin/brctl addif br0 $INTERFACE
-}
diff --git a/openwrt/package/base-files/ipkg/hotplug.control b/openwrt/package/base-files/ipkg/hotplug.control
deleted file mode 100644 (file)
index 5266e85..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Package: hotplug
-Priority: optional
-Section: net
-Description: Hotplug script for WDS
index 1e1968dcb99b2e307786788d875549a847b1eb93..37e49971255a4f7cf6433f4575939ba49ae84d39 100644 (file)
@@ -39,5 +39,4 @@ $(IPKG_BUSYBOX):
        $(MAKE) CC=$(TARGET_CC) CROSS="$(TARGET_CROSS)" PREFIX="$(IDIR_BUSYBOX)" \
                EXTRA_CFLAGS="$(TARGET_CFLAGS)" -C $(PKG_BUILD_DIR) install
        $(STRIP) $(IDIR_BUSYBOX)/bin/busybox
-       -chmod a+x $(IDIR_BUSYBOX)/usr/share/udhcpc/default.script
        $(IPKG_BUILD) $(IDIR_BUSYBOX) $(PACKAGE_DIR)
index 679e5fca59c3bf84f27956d01be27a455f93916b..31fe5519472a3e6a7023ef52ceeb993fc5380e15 100644 (file)
@@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ntpclient
 PKG_VERSION:=2003_194
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_MD5SUM:=94e84d5c6023c5e1f3890b28d0a08c92
 
 PKG_SOURCE_URL:=http://doolittle.faludi.com/ntpclient
@@ -26,8 +26,8 @@ $(PKG_BUILD_DIR)/.built:
        touch $@
 
 $(IPKG_NTPCLIENT):
-       install -d -m0755 $(IDIR_NTPCLIENT)/etc/init.d
-       install -m0755 ./files/ntpclient.init $(IDIR_NTPCLIENT)/etc/init.d/S60ntpclient
+       install -d -m0755 $(IDIR_NTPCLIENT)/etc/hotplug.d/iface
+       install -m0755 ./files/ntpclient.init $(IDIR_NTPCLIENT)/etc/hotplug.d/iface/10-ntpclient
        install -d -m0755 $(IDIR_NTPCLIENT)/usr/sbin
        install -m0755 $(PKG_BUILD_DIR)/ntpclient $(IDIR_NTPCLIENT)/usr/sbin/
        $(RSTRIP) $(IDIR_NTPCLIENT)
index 923022bfccbcf332467e83119be06930521577cb..2ad4beb77397228cbdb87a9fd91f6c6262c4157a 100644 (file)
@@ -1,2 +1,11 @@
 #!/bin/sh
-/usr/sbin/ntpclient -c 1 -s -h pool.ntp.org &
+server=$(nvram get ntp_server)
+case "$ACTION" in
+       ifup)
+               ps x | grep '[n]tpclient' >&- || {
+                       route -n 2>&- | grep '0.0.0.0' >&- && /usr/sbin/ntpclient -c 1 -s -h ${server:-pool.ntp.org} &
+               }
+               ;;
+       ifdown)
+               route -n 2>&- | grep '0.0.0.0' >&- || killall ntpclient 2>&- >&- ;;
+esac
index 1b20c4e7cd619ccc0deb5b04eaae3604ab9df131..eec2bd8462784146283417c983b491b4f68eaac9 100644 (file)
@@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ppp
 PKG_VERSION:=2.4.3
-PKG_RELEASE:=6
+PKG_RELEASE:=7
 PKG_MD5SUM:=848f6c3cafeb6074ffeb293c3af79b7c
 
 PKG_SOURCE_URL:=ftp://ftp.samba.org/pub/ppp/
@@ -82,6 +82,8 @@ $(IPKG_PPP):
        ln -sf /tmp/resolv.conf $(IDIR_PPP)/etc/ppp/resolv.conf
        install -m0600 ./files/etc/ppp/chap-secrets $(IDIR_PPP)/etc/ppp/
        install -m0644 ./files/etc/ppp/options $(IDIR_PPP)/etc/ppp/
+       install -m0755 ./files/etc/ppp/ip-up $(IDIR_PPP)/etc/ppp/
+       install -m0755 ./files/etc/ppp/ip-down $(IDIR_PPP)/etc/ppp/
        install -d -m0755 $(IDIR_PPP)/etc/ppp/peers
        install -m0644 ./files/etc/ppp/peers/sample $(IDIR_PPP)/etc/ppp/peers/
        install -d -m0755 $(IDIR_PPP)/usr/sbin
diff --git a/openwrt/package/ppp/files/etc/ppp/ip-down b/openwrt/package/ppp/files/etc/ppp/ip-down
new file mode 100755 (executable)
index 0000000..044759f
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+[ -z "$6" ] || env -i ACTION="ifdown" INTERFACE="$6" PROTO=ppp /sbin/hotplug "iface"
diff --git a/openwrt/package/ppp/files/etc/ppp/ip-up b/openwrt/package/ppp/files/etc/ppp/ip-up
new file mode 100755 (executable)
index 0000000..c67a3d0
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+[ -z "$6" ] || env -i ACTION="ifup" INTERFACE="$6" PROTO=ppp /sbin/hotplug "iface"
index 51b0fe3344424e0270d882c74a95dc4b922061ec..892836636417b7e154d9bca3f9e51c42c520f215 100644 (file)
@@ -31,6 +31,7 @@ while :; do
        usepeerdns \
        defaultroute \
        linkname $type \
+       ipparam $type \
        user "$USERNAME" \
        password "$PASSWORD" \
        mtu $MTU mru $MTU \
index 9a5d0a3494de55b66b37143b1cad8badd757a1db..da9a441ad9628332f2a648c4ccdf6767f970a159 100644 (file)
@@ -32,6 +32,7 @@ while :; do
        usepeerdns \
        defaultroute \
        linkname $type \
+       ipparam $type \
        user "$USERNAME" \
        password "$PASSWORD" \
        mtu $MTU mru $MTU \
index 3334f23114204f7e4a82e609d31159d5eae7f3c7..870341c87d2ad2bc2ba669807532cb0b7c49125e 100644 (file)
@@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=pptp
 PKG_VERSION:=1.6.0
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 PKG_MD5SUM:=9a706327fb9827541d7c86d48ceb9631
 
 PKG_SOURCE_URL:=@SF/pptpclient
index 15178fe302b11aca9054bbc3f7b704b4bae0c0a3..acaeabd971e5352a33868795763eef8af2791e63 100644 (file)
@@ -22,7 +22,7 @@ while :; do
        IDLETIME=$(nvram get ppp_idletime)
        IDLETIME=${IDLETIME:+lcp-echo-failure $IDLETIME}
        MTU=$(nvram get ppp_mtu)
-       MTU=${MTU:+ mtu $MTU mru $MTU}
+       MTU=${MTU:-1452}
 
        do_ifup $PPTP_PROTO $type
        
@@ -38,10 +38,12 @@ while :; do
                usepeerdns \
                defaultroute \
                replacedefaultroute \
-               linkname $type \
+               linkname "$type" \
+               ipparam "$type" \
                user "$USERNAME" \
                password "$PASSWORD" \
-               $MTU \
+               mtu $MTU \
+               mru $MTU \
                $IDLETIME \
                $REDIAL
 done &
index ac18fe6af8597efd70554c28a6d138e21b584a21..ea359c798d2daf49c7681358681c6eb8b0247e26 100644 (file)
@@ -5,7 +5,6 @@ bridge
 busybox
 dnsmasq
 dropbear
-hotplug
 iptables
 kmod-atm
 kmod-cpmac
index 4de1e1abadc5d63acbf6b81b8f9ae32aea9de4d4..4e89ff3952b4a0e2930ca021898cc0888ef54821 100644 (file)
@@ -5,7 +5,6 @@ bridge
 busybox
 dnsmasq
 dropbear
-hotplug
 iptables
 kmod-atm
 kmod-cpmac
index b79e0aba14a7d642fa927a400668d6fa80bbe031..802b08dd1e72003ffbd82b9e6ee1ad1bf4034cac 100644 (file)
@@ -5,7 +5,6 @@ busybox
 dnsmasq
 dropbear
 iptables
-hotplug
 kmod-cpmac
 libgcc
 mtd
index d47422d40b55045c2197c2f9ed5c3850a955063d..44ba92a2790e89993ce4a88fe9b66b2101343e7e 100644 (file)
@@ -5,7 +5,6 @@ busybox
 dnsmasq
 dropbear
 iptables
-hotplug
 kmod-brcm-et
 kmod-brcm-wl
 kmod-diag
index 2ff92cac7a6a393db244d367f79c27cdb65b84ca..956a07b13fc0c6bf948f5642265469fe855e723e 100644 (file)
@@ -5,7 +5,6 @@ busybox
 dnsmasq
 dropbear
 iptables
-hotplug
 kmod-net-natsemi
 libgcc
 mtd
index 79a6b9f7e7073216154783cea54ef38c48ed32d1..595bea9bca4c5eaf2f4586ef20afe1741c71bf13 100644 (file)
@@ -5,7 +5,6 @@ busybox
 dnsmasq
 dropbear
 iptables
-hotplug
 kmod-brcm-et
 kmod-brcm-wl
 kmod-diag
index 1fa77b21f6fa78b3de79dde0ccc56fe2407a3911..cb34ceab9f77f1f96c2e737b51230a01f34f17c2 100644 (file)
@@ -5,7 +5,6 @@ busybox
 dnsmasq
 dropbear
 iptables
-hotplug
 kmod-net-natsemi
 kmod-ppp
 kmod-gre