Advertisement
metalx1000

Auto Mount Drive and Move All Files udev rules

Jan 10th, 2022
1,680
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.43 KB | None | 0 0
  1. #create rule
  2. sudo vim /etc/udev/rules.d/99_move_photos.rules
  3. ACTION=="add", KERNEL=="sd?[0-9]", SUBSYSTEM=="block", RUN+="/usr/local/bin/move_photos"
  4.  
  5. #reload rules
  6. sudo udevadm control --reload
  7.  
  8. #/usr/local/bin/move_photos script
  9. #!/bin/sh
  10.  
  11. if [ "${ACTION}" = add -a -d "/sys${DEVPATH}" ]; then
  12.   echo "add ${DEVNAME}" >>/tmp/test.log
  13.   mkdir -p /tmp/photos/
  14.   mount ${DEVNAME} /mnt
  15.   mv /mnt/* /tmp/photos/
  16.   umount /mnt
  17. fi
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement