[Dev] constructing a USB media upload and download device

Nicolás Reynolds fauno at kiwwwi.com.ar
Mon Oct 15 23:03:47 GMT 2012


Quiliro Ordóñez <quiliro at congresolibre.org> writes:

> I have successfully used devmon for automatically mounting a USB memory, 
> copying a directory to it and then unmounting it. It works correctly as 
> root user with the following command:
> devmon --exec-on-drive "cp -r /home/quiliro/media %d ; umount %d"
> I would like devmon to do that on a specific USB port. On another 
> specific port, I would like to do the opposite copy operation:
> devmon --exec-on-drive "cp -r %d/media /home/quiliro/ ; umount %d"
> I understand that can be done by adding a udev rule. I found the 
> specifications of the ports by using:
> udevadm info -a -p $(udevadm info -q path -n /dev/sdb1)
> after plugging in any USB memory to both ports:
> KERNELS=="2-1" for the right USB port
> KERNELS=="2-2" for the left USB port
> The point is not to recognize a USB memory specific product id or device 
> id, but to recognize the specific port it was connected to.
>
> So I suppose I need to create a udev rule. I think I have to assign a 
> symlink to the USB memories connected to the left port and another to 
> the right port. Then, I should use these commands:
> devmon --exec-on-device /dev/right_USB "cp -r /home/quiliro/media %d ; 
> umount %d"
> devmon --exec-on-device /dev/right_USB "cp -r %d/media /home/quiliro/ ; 
> umount %d"
>
> Please suggest the rule I should use and the appropiate devmon command. 
> If no one is able to answer this question, please guide me to a udev 
> rule forum. Thank you.

wouldn't it be more simple/easier to do both things at the same time,
for instance:

devmon --exec-on-device /dev/usb "rsync -a %d/ /home/quiliro/; rsync -a /home/quiliro/ %d/ ; umount %d" 

will synchronize usb to the sharing device and back, then umount :D
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <https://lists.parabola.nu/pipermail/dev/attachments/20121015/3b63bd5e/attachment.sig>


More information about the Dev mailing list