Advertisement
Guest User

Untitled

a guest
May 24th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #Only operate on sdb1
  2. KERNEL!="sdb1", GOTO="usb-automount-end"
  3. ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="usb-automount-end"
  4.  
  5. #import useful variables from blkid program
  6. IMPORT{program}="/sbin/blkid -o udev -p %N"
  7.  
  8. #ignore anything other than vfat filesystems
  9. ACTION=="add", ENV{ID_FS_TYPE}!="vfat", GOTO="usb-automount-end"
  10.  
  11. #remount root as read-write. Not sure why we have to do this!
  12. #ACTION=="add", RUN+="/bin/mount -o remount,rw /"
  13.  
  14. #mount to /mnt/flash
  15. #ACTION=="add", RUN+="/bin/mkdir -p /mnt/flash"
  16. #ACTION=="add", RUN+="/bin/mount -t vfat -o dmask=000,fmask=111 /dev/%k /mnt/flash"
  17. ACTION=="add", RUN+="/root/test_run.sh", OPTIONS="last_rule"
  18.  
  19. #clean up after removal
  20. #ACTION=="remove", RUN+="/bin/umount -l /mnt/flash"
  21.  
  22. #label for goto end
  23. LABEL="usb-automount-end"
  24.  
  25. #!/bin/bash -x
  26. logger "running mount"
  27. mount | logger
  28. logger "remounting root"
  29. mount -o remount,rw / 2>&1 | logger
  30. logger "remount done"
  31. mount | logger
  32. logger "Running script. Adding dir"
  33. mkdir -p /mnt/flash2 2>&1 | logger
  34. logger "Directory added... mounting."
  35. mount -t vfat -o dmask=000,fmask=111 /dev/sdb1 /mnt/flash2 2>&1 | logger
  36. logger "Mounted"
  37. mount | logger
  38.  
  39. logger "Sleeping 5 then re-checking"
  40. sleep 5
  41.  
  42. mount | logger
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement