История изменений
Исправление Stanson, (текущая версия) :
Вызывается из правила udev
KERNEL=="sd[c-z][0-9]|sd[c-z]|mmcblk[0-9]|mmcblk[0-9]p[0-9]", RUN+="/etc/udev/usb-mount %k"
/etc/udev/usb-mount
#!/bin/sh -e
NAME=$1
DEV="/dev/${NAME}"
GROUP="plugdev"
DIR="Desktop"
if ret=`/sbin/blkid -o udev -p "${DEV}" 2>/dev/null` ; then
eval $ret
else
no_media=yes
fi
[ -n "${ID_FS_LABEL}" ] && label="${ID_FS_LABEL}"
[ -z "${label}" ] && label="${NAME}"
case "${ACTION}" in
add)
[ "${ID_FS_USAGE}" != "filesystem" ] && exit 0
mount_options="noatime,sync"
case "${ID_FS_TYPE}" in
vfat|ntfs)
gid=`getent group "${GROUP}" | cut -f3 -d:`
mount_options="${mount_options},utf8,uid=0,gid=${gid},fmask=113,dmask=002,noexec"
;;
esac
for u in `groupmems -g "${GROUP}" -l` ; do
h=`getent passwd "${u}" | cut -f6 -d:`
mount_point="${h}/${DIR}/${label}"
/bin/mkdir -p "${mount_point}"
/bin/mount -o "${mount_options}" "$DEV" "${mount_point}"
done
;;
remove)
dirs=`cat /proc/mounts | grep -w "${DEV}" | cut -d ' ' -f 2`
for mount_point in ${dirs} ; do
/bin/umount -l "${mount_point}"
/bin/rmdir "${mount_point}"
done
;;
change)
[ -z "${no_media}" ] && exit 0
DEV=`ls $DEV[0-9]`
for i in ${DEV} ; do
dirs=`cat /proc/mounts | grep -w "${i}" | cut -d ' ' -f 2`
for mount_point in ${dirs} ; do
/bin/umount -l "${mount_point}"
/bin/rmdir "${mount_point}"
done
done
;;
esac
Исходная версия Stanson, :
#!/bin/sh -e
NAME=$1
DEV="/dev/${NAME}"
GROUP="plugdev"
DIR="Desktop"
if ret=`/sbin/blkid -o udev -p "${DEV}" 2>/dev/null` ; then
eval $ret
else
no_media=yes
fi
[ -n "${ID_FS_LABEL}" ] && label="${ID_FS_LABEL}"
[ -z "${label}" ] && label="${NAME}"
case "${ACTION}" in
add)
[ "${ID_FS_USAGE}" != "filesystem" ] && exit 0
mount_options="noatime,sync"
case "${ID_FS_TYPE}" in
vfat|ntfs)
gid=`getent group "${GROUP}" | cut -f3 -d:`
mount_options="${mount_options},utf8,uid=0,gid=${gid},fmask=113,dmask=002,noexec"
;;
esac
for u in `groupmems -g "${GROUP}" -l` ; do
h=`getent passwd "${u}" | cut -f6 -d:`
mount_point="${h}/${DIR}/${label}"
/bin/mkdir -p "${mount_point}"
/bin/mount -o "${mount_options}" "$DEV" "${mount_point}"
done
;;
remove)
dirs=`cat /proc/mounts | grep -w "${DEV}" | cut -d ' ' -f 2`
for mount_point in ${dirs} ; do
/bin/umount -l "${mount_point}"
/bin/rmdir "${mount_point}"
done
;;
change)
[ -z "${no_media}" ] && exit 0
DEV=`ls $DEV[0-9]`
for i in ${DEV} ; do
dirs=`cat /proc/mounts | grep -w "${i}" | cut -d ' ' -f 2`
for mount_point in ${dirs} ; do
/bin/umount -l "${mount_point}"
/bin/rmdir "${mount_point}"
done
done
;;
esac