let ipkg fail when a package file to be installed is not found
[openwrt/svn-archive/archive.git] / openwrt / package / base-files / default / etc / hotplug.d / usb / 01-mount
1 mount_storage() {
2 cd /dev/discs
3 for dev in disc*; do
4 [ -f /tmp/.${dev}_id ] || {
5 echo ${INTERFACE}${PRODUCT} > /tmp/.${dev}_id
6 mount | grep /mnt/${dev} || (
7 [ -d /mnt/. ] || {
8 mkdir -p /tmp/mnt
9 ln -s /tmp/mnt /
10 }
11 cd $dev
12 for part in part*; do
13 path=/mnt/${dev}_${part##*part}
14 mkdir -p ${path}
15 mount ${part} ${path}
16 done
17 )
18 }
19 done
20 }
21
22 umount_storage() {
23 for tmp in /tmp/.*_id; do
24 id=$(cat $tmp 2>&-)
25 [ "${INTERFACE}${PRODUCT}" = "$id" ] && {
26 rm -f $tmp
27 disc=${tmp##*disc}
28 disc=${disc%%_id}
29 for disc in /mnt/disc${disc}*; do
30 umount -f $disc || umount -l $disc
31 done
32 }
33 done
34 }
35
36 [ -f /proc/bus/usb/devices ] || mount -t usbfs none /proc/bus/usb
37
38 case "$ACTION" in
39 add)
40 case "${INTERFACE%%/*}" in
41 8) mount_storage ;;
42 esac
43 ;;
44 remove)
45 case "${INTERFACE%%/*}" in
46 8) umount_storage ;;
47 esac
48 ;;
49 esac