Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ cat /etc/udev/rules.d/20-automount.rules
- ACTION!="add", GOTO="usb_add_end"
- KERNEL=="sd[b-z][0-9]", RUN+="/bin/systemctl start mount@%k"
- KERNEL=="mmcblk[0-9]", RUN+="/bin/systemctl start mount@%k"
- KERNEL=="mmcblk[0-9]p[0-9]", RUN+="/bin/systemctl start mount@%k"
- SUBSYSTEMS=="usb", ATTR{interface}=="MTP", RUN+="/bin/systemctl start mount@mtp"
- LABEL="usb_add_end"
- ACTION!="remove", GOTO="usb_rem_end"
- KERNEL=="sd[b-z][0-9]", RUN+="script/mount/automount.sh umnt %k"
- KERNEL=="mmcblk[0-9]", RUN+="script/mount/automount.sh umnt %k"
- KERNEL=="mmcblk[0-9]p[0-9]", RUN+="script/mount/automount.sh umnt %k"
- #нефурычит(((
- KERNEL=="2-1.3", ENV{ID_MTP_DEVICE}="1", RUN+="script/mount/automount.sh umnt mnt"
- LABEL="usb_rem_end"
- $ cat /etc/systemd/system/mount@.service
- [Unit]
- Description=mount_%I
- [Service]
- Type=forking
- ExecStart=/home/admin/script/mount/automount.sh mnt %I
- [Install]
- WantedBy=multi-user.target
- $ cat script/mount/automount.sh
- #!/bin/bash
- export DISPLAY=:0.0
- format_dev=`lsblk -dnro FSTYPE "/dev/$2"`
- user_dev=`ps -C dwm -o user=`
- fmnt()
- {
- mkdir /media/usb-$1
- chown $user_dev:$user_dev /media/usb-$1
- notify-send-root "#Udev:" "mount /media/usb-$1 $format_dev"
- if [ "$1" == "mtp" ]; then
- su $user_dev -c "simple-mtpfs /media/usb-$1"
- else
- case "$format_dev" in
- "" ) systemctl stop mount@$1 ;;
- ntfs ) mount /dev/$1 /media/usb-$1 -o uid=1000,fmask=113,dmask=002,utf8 ;;
- vfat ) mount /dev/$1 /media/usb-$1 -o uid=1000,utf8 ;;
- exfat ) mount /dev/$1 /media/usb-$1 -o uid=1000,utf8 ;;
- *) mount /dev/$1 /media/usb-$1
- esac
- fi
- }
- fumnt()
- {
- umount /media/usb-$1
- rmdir /media/usb-$1
- systemctl stop mount@$1
- }
- case "$1" in
- mnt ) fmnt $2;;
- umnt ) fumnt $2;;
- * ) ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement