{"action":"opened","issue":{"url":"https://api.github.com/repos/HalisCz/udev-automount/issues/1","repository_url":"https://api.github.com/repos/HalisCz/udev-automount","labels_url":"https://api.github.com/repos/HalisCz/udev-automount/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/HalisCz/udev-automount/issues/1/comments","events_url":"https://api.github.com/repos/HalisCz/udev-automount/issues/1/events","html_url":"https://github.com/HalisCz/udev-automount/issues/1","id":143647043,"number":1,"title":"Improved 10-flash-mounts.rules","user":{"login":"wifiextender","id":4725121,"avatar_url":"https://avatars.githubusercontent.com/u/4725121?v=3","gravatar_id":"","url":"https://api.github.com/users/wifiextender","html_url":"https://github.com/wifiextender","followers_url":"https://api.github.com/users/wifiextender/followers","following_url":"https://api.github.com/users/wifiextender/following{/other_user}","gists_url":"https://api.github.com/users/wifiextender/gists{/gist_id}","starred_url":"https://api.github.com/users/wifiextender/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wifiextender/subscriptions","organizations_url":"https://api.github.com/users/wifiextender/orgs","repos_url":"https://api.github.com/users/wifiextender/repos","events_url":"https://api.github.com/users/wifiextender/events{/privacy}","received_events_url":"https://api.github.com/users/wifiextender/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-26T01:37:21Z","updated_at":"2016-03-26T01:37:21Z","closed_at":null,"body":"Ahoi kamarat,\r\n\r\n```bash\r\n\r\n#! /bin/sh\r\n\r\n####################################################\r\n#        USB Flash Drives automounting             #\r\n#    Device without partitions will not be mounted #\r\n#                                                  #\r\n#        parted -a optimal /dev/sdX                #\r\n#        mklabel msdos                             #\r\n#        mkpart primary 1 -1                       #\r\n#        quit                                      #\r\n#        mkfs.TYPE /dev/sdX1                       #\r\n#                                                  #\r\n####################################################\r\n\r\n# start at sdb to ignore the system drive\r\nKERNEL!=\"sd[b-z]*\", GOTO=\"exit\"\r\nACTION==\"add\", PROGRAM!=\"/sbin/blkid %N\", GOTO=\"exit\"\r\n\r\n# import some useful filesystem info as variables\r\nIMPORT{program}=\"/sbin/blkid -o udev -p %N\"\r\n#IMPORT{program}=\"/bin/udevadm info -n %N\"\r\n\r\n# get the label if present, otherwise assign one based on device/partition\r\nENV{ID_FS_LABEL}!=\"\", ENV{dir_name}=\"%E{ID_FS_LABEL}\"\r\nENV{ID_FS_LABEL}==\"\", ENV{dir_name}=\"USB_%k\"\r\nENV{ID_FS_TYPE}==\"\", GOTO=\"exit\"\r\n\r\n\r\n# Your $USER goes here if you want rw access\r\nENV{MY_UZER}=\"frost\"\r\n\r\n\r\n# determine whether the FS is vfat or ntfs\r\n# and assign some environment variables to\r\n# make our life easier\r\nENV{ID_FS_TYPE}!=\"(vfat|ntfs)\", ENV{da_mount_type}=\"auto\"\r\nENV{ID_FS_TYPE}==\"vfat\", ENV{da_mount_type}=\"vfat\"\r\nENV{ID_FS_TYPE}==\"ntfs\", ENV{da_mount_type}=\"ntfs-3g\"\r\n\r\n# create the dir in /media\r\nACTION==\"add\", RUN+=\"/bin/mkdir -p '/media/%E{dir_name}'\"\r\n\r\nACTION==\"add\", ENV{mount_optionz}=\"gid=100,dmask=000,fmask=110,utf8,flush,rw,noauto,discard,noatime,users\"\r\nACTION==\"add\", ENV{ID_FS_TYPE}!=\"vfat\", ENV{ID_FS_TYPE}!=\"ntfs\", ENV{mount_optionz}=\"rw,noauto,discard,noatime,users\"\r\n\r\n# remove existing device and then add it to /etc/fstab\r\nACTION==\"add\", RUN+=\"/bin/sed -i '/\\/dev\\/%k /d' /etc/fstab\"\r\nACTION==\"add\", RUN+=\"/bin/sed -i '$a\\/dev/%k /media/%E{dir_name} %E{da_mount_type} %E{mount_optionz} 0 0' /etc/fstab\"\r\n\r\n# mount device and change ownership to have rw access\r\nACTION==\"add\", RUN+=\"/bin/mount -t %E{da_mount_type} -o %E{mount_optionz} /dev/%k '/media/%E{dir_name}'\"\r\nACTION==\"add\", RUN+=\"/bin/chown -R %E{MY_UZER}:users /media/%E{dir_name}\"\r\n\r\n# clean up after device removal\r\nACTION==\"remove\", RUN+=\"/bin/umount -l '/media/%E{dir_name}'\", RUN+=\"/bin/rmdir '/media/%E{dir_name}'\"\r\nACTION==\"remove\", RUN+=\"/bin/sed -i '/\\/dev\\/%k /d' /etc/fstab\"\r\n\r\n# exit\r\nLABEL=\"exit\"\r\n\r\n```\r\n\r\nNashle"}}