Scripting help miniDLNA rescan and restart

Apologies for my n00bishness, getting back into Linux after a long time away. I was previously using DD-WRT but wanted a bit more flexibility on my Archer C7 v2s to do things like run Transmission Daemon and miniDLNA. (DD did the DLNA well, but the build for my particular model of router kept throwing roadblocks in my face, and had a bunch of features like VPN that I have no use for).

I've got the services running the way I want but when I copy files into the DLNA media folders they are not automatically discovered. I've read some forum articles for other versions of miniDLNA that give some ideas but nothing seems to work.

Since I'm manually copying files from one folder into the media folder, what I would like to do is make a simple bash script to do the following:

rescandb.sh

#!/bin/sh
#I'll add a chmod/chown here to make sure any newly copied files match the ownership/permissions of the rest of the folder
service minidlna stop
minidlnad -R
service minidlna start

When I attempt to run said script I get the following error:

root@OpenWrt:/mnt/media/DLNA# ./rescandb.sh
./rescandb.sh: line 3: service: not found
./rescandb.sh: line 5: service: not found

I'm sure I'm just missing something basic, but any help would be largely appreciated. I have a crap memory and it's less effective for me to remember the sytax for stopping services etc every time I add new media.

You've probably already looked into this, but just in case you can set the notify function to scan more frequently, it's set in seconds and default is 900 i think (15 minutes), so you could set it to 300 (5 minutes) or whatever you'd like to discover new files quicker.

Thanks Mike,

I had looked into that setting on a variety of other forums, it's apparently related to how often the server announces itself on the network, rather than how often it scans for content.

I've also added content and left it overnight to see if it would appear automagically.

I had read in a raspberry pi minidlna forum that correctly configuring inotify on the system would allow the daemon to be alerted of directory changes, but haven't found anything specific to OpenWRT yet. I'm not overly concerned with it happening automatically as I don't add to my library that often.

Ahh ok, maybe notify and inotify are different settings then, here's what it says in the OpenWrt doc -

inotify boolean no 1 set this to no to disable inotify monitoring to automatically discover new files

I'm not sure if that means setting it to no will disable automatic discovery or enable it, but might be worth a try if you haven't already.

Thanks Mike,

inotify is set to 1 by default, which seems to indicate it's enabled. I wonder if there are configurations missing in OpenWRT rather than miniDLNA.

not being terribly concerned about automagically rescanning, I was more interrested in scripting something that I could run manually after copying in files (which I also do manually).

if I can get it to happen using inotify even better, but I'm not fixated on that outcome.

I figured out what was missing to have my script work.

#!/bin/sh /etc/init.d

service minidlna stop
minidlnad -R
service minidlna start

Since I'm telling the service to stop and then start, the /etc/init.d is what was missing.

I also do some chown and chmod commands in that script to ensure that the minidlna user has access to all the files.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.