summaryrefslogtreecommitdiff
path: root/openwrt/package/base-files/default/etc/hotplug.d
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2005-11-07 01:12:51 +0000
committerFelix Fietkau <nbd@openwrt.org>2005-11-07 01:12:51 +0000
commit2e8e51060ffcc46bb1308d7eae4d2bc3456deacf (patch)
treec82e5b250e3389ec4e4fe8ef16361eae61572845 /openwrt/package/base-files/default/etc/hotplug.d
parent14a88822fd3f6883af5b4d66f584a3254202fd29 (diff)
downloadmtk-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/hotplug.d')
-rw-r--r--openwrt/package/base-files/default/etc/hotplug.d/net/01-wds5
-rw-r--r--openwrt/package/base-files/default/etc/hotplug.d/usb/01-mount49
2 files changed, 54 insertions, 0 deletions
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