add basic support for the Magicbox boards
[openwrt.git] / package / base-files / default / etc / hotplug.d / usb / 01-mount
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3
4 mount_storage() {
5 cd /dev/discs
6 for dev in disc*; do
7 [ -f /tmp/.${dev}_id ] || {
8 echo ${INTERFACE}${PRODUCT} > /tmp/.${dev}_id
9 mount | grep /mnt/${dev} || (
10 [ -d /mnt/. ] || {
11 mkdir -p /tmp/mnt
12 ln -s /tmp/mnt /
13 }
14 cd $dev
15 for part in part*; do
16 path=/mnt/${dev}_${part##*part}
17 mkdir -p ${path}
18 mount ${part} ${path}
19 done
20 )
21 }
22 done
23 }
24
25 umount_storage() {
26 for tmp in /tmp/.*_id; do
27 id=$(cat $tmp 2>&-)
28 [ "${INTERFACE}${PRODUCT}" = "$id" ] && {
29 rm -f $tmp
30 disc=${tmp##*disc}
31 disc=${disc%%_id}
32 for disc in /mnt/disc${disc}*; do
33 umount -f $disc || umount -l $disc
34 done
35 }
36 done
37 }
38
39 [ -f /proc/bus/usb/devices ] || mount -t usbfs none /proc/bus/usb
40
41 case "$ACTION" in
42 add)
43 case "${INTERFACE%%/*}" in
44 8) mount_storage ;;
45 esac
46 ;;
47 remove)
48 case "${INTERFACE%%/*}" in
49 8) umount_storage ;;
50 esac
51 ;;
52 esac
This page took 0.047115 seconds and 5 git commands to generate.