Minidlna doesnt see any files - any script help to fix this appreciated

I have the classic minidlna issue that, when a usb external drive is plugged in, minidlna sees no files although it is enabled and running, because minidlana starts before the drive has finished mounting.

the result is that to watch something I often have to SSH in to the router and restart the minidlna service, whereupon the files show up correctly.

could anyone help me - a complete novice at this - draft a script to fix

So I am thinking of

  1. disabling automatic mount for the two USB drives
  2. And instead running a script in /etc/rc.local (I assume that writing it in Luci > System > scheduled Tasks does the same) to a) mount the two USB drives first, b) enforce a delay, and then c) start Minidlna.

I hope that the act of plugging the drives into the router triggers the mount and the mounting triggers the minidlna start.

but could anyone advise what such a script should look like please?

I think you should start putting your script together and once you have specific questions, ask them.

You could start here:
https://openwrt.org/docs/guide-developer/procd-init-scripts

Paying attention to
procd_add_reload_mount_trigger, procd_add_restart_mount_trigger

Sadly i think i am out of my depth at this level..

Just for testing purposes, you could start off this way.

  1. Install blockd: opkg update; opkg install blockd
  2. Follow this guide to have your external storage devices always mount to known mount points:

    https://openwrt.org/docs/guide-user/storage/fstab

Edit the init script for minidlna: nano /etc/init.d/minidlna
Scroll down to service_triggers()
Add this line right after service_triggers() {:
procd_add_reload_mount_trigger /mnt/example (replacing /mnt/example with the mount point of your external storage device)
Run these commands to (hopefully) make procd realize that the service triggers changed:
service minidlna stop; service minidlna disable; service minidlna enable; service minidlna start
(I'm not sure that this will do it, a restart may be needed?)

Now re/connect your external drive and check whether minidlna now finds the media on it.

Thank you so much for this. I have just one question...i have two drives /dev/sda mounted as /mnt/usb01 and /dev/sdb mounted as /mnt/usb02,

So where you refer to mnt/example, what syntax is correct to cover both drives?

Thanks again

I suggest you to start with just one drive. This is just a test to see if this works or not. If this does work, a permanent solution would be to make a custom init script and there both of your drives can be set up.

Perfect. Ill do that soon and report back. Thanks!

1 Like