4

I have Raspberry Pi (with Raspbian) and using it as DLNA/UPnP server and renderer. I run minidlna as DLNA server and i have some media files on USB.

I would like to automaticaly rebuild DLNA DB when drive is mounted and unmounted. This is done by command:

sudo service minidlna force-reload

Is threre any way how to autorun this command?

BTW I use "USBmount" package for automount USB drives.

Thanx

dosdroid
  • 41
  • 1
  • 3
  • This might be better suited for [superuser](http://superuser.com) -- it does not seem to be a programming or software development question. – Jussi Kukkonen Jan 13 '14 at 20:35

2 Answers2

5

You can do this using the tool usbmount. It has the possibility to add scripts that will be run on mount/umount events in /etc/usbmount/mount.d/ and /etc/usbmount/umount.d/.

2

Start by finding your device in lsusb. Note the ID (eg 12f5:a91a)

Create a new udev rules file in /etc/udev/rules.d/ eg /etc/udev/rules.d/100-my-mount.rules and write a new rule in there like this:

ACTION=="add", ATTRS{idVendor}=="12f5", ATTRS{idProduct}=="a91a", RUN+="/home/your_username/bin/my-mount-script.sh"

For unmounted device use ACTION=="remove" in rule and another script.

Pavel Stárek
  • 959
  • 5
  • 6
  • But this will work just for one specific device right? I would like to have this behavior in general for every USB storage. – dosdroid Dec 24 '13 at 10:13
  • 1
    So try this rule: ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd[b-z]1", RUN+="/usr/local/bin/my-mount-script.sh" – Pavel Stárek Dec 24 '13 at 11:16