diff options
author | Felix Fietkau <nbd@openwrt.org> | 2005-11-07 01:12:51 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2005-11-07 01:12:51 +0000 |
commit | 2e8e51060ffcc46bb1308d7eae4d2bc3456deacf (patch) | |
tree | c82e5b250e3389ec4e4fe8ef16361eae61572845 /openwrt/package/base-files/default/etc | |
parent | 14a88822fd3f6883af5b4d66f584a3254202fd29 (diff) | |
download | mtk-20170518-2e8e51060ffcc46bb1308d7eae4d2bc3456deacf.zip mtk-20170518-2e8e51060ffcc46bb1308d7eae4d2bc3456deacf.tar.gz mtk-20170518-2e8e51060ffcc46bb1308d7eae4d2bc3456deacf.tar.bz2 |
add hotplug stuff to trunk/
SVN-Revision: 2364
Diffstat (limited to 'openwrt/package/base-files/default/etc')
3 files changed, 63 insertions, 6 deletions
diff --git a/openwrt/package/base-files/default/etc/functions.sh b/openwrt/package/base-files/default/etc/functions.sh index bc9767f..9cfc802 100755 --- a/openwrt/package/base-files/default/etc/functions.sh +++ b/openwrt/package/base-files/default/etc/functions.sh @@ -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 index 0000000..38bd696 --- /dev/null +++ b/openwrt/package/base-files/default/etc/hotplug.d/net/01-wds @@ -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 index 0000000..c28ada2 --- /dev/null +++ b/openwrt/package/base-files/default/etc/hotplug.d/usb/01-mount @@ -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 |