MiniDLNA Automatic Scan - Fix

Status
Not open for further replies.

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I was attempting to nest several "wait_on" commands to break up the scanning but have been unsuccessful at the time. I have a few other ideas, we shale see if they work. If something does work then I'll post it in this thread.
 

white_flag

Dabbler
Joined
Jul 18, 2012
Messages
16
hervon and joeschmuck
thanks for answers

I put the hervon script and the minidlna doesn't reboot. but I do not understand, why I see only one folder from /media

/media/Movies - this one I see't
/media/New Movies - not
/media/Music - not

I have the mount points correct ...can be seen via browser. but not in TV (Samsung) just the first folder (Movies)

any idea?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
hervon and joeschmuck
thanks for answers

I put the hervon script and the minidlna doesn't reboot. but I do not understand, why I see only one folder from /media

/media/Movies - this one I see't
/media/New Movies - not
/media/Music - not

I have the mount points correct ...can be seen via browser. but not in TV (Samsung) just the first folder (Movies)

any idea?
Actually the "hervon script" was one of my earlier versions of the script. But based on your message your call for wait_on should look like this...
Code:
wait_on -w '/media/Movies' '/media/New Movies' '/media/Music'
 

white_flag

Dabbler
Joined
Jul 18, 2012
Messages
16
Hello joeschmuck

sorry for the mistake.
inside of the code is already the

Code:
wait_on -w '/media/Movies' '/media/New Movies' '/media/Music'


but just the first folder is been seen (Movies)
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Hello joeschmuck

sorry for the mistake.
inside of the code is already the

Code:
wait_on -w '/media/Movies' '/media/New Movies' '/media/Music'


but just the first folder is been seen (Movies)
So you don't have MiniDLNA setup correctly is what you're saying, that has nothing to do with this script. Also, I suspect you have folders nested within /media/Music so that will not work properly here for any changes you make to a subfolder within, for example you add a file to '/media/Music/AC DC/Thunderstruck/newsong.mp3' or you relabel a title nested similar to that, it will not force a rescan.

First, fix MiniDLNA to display your media properly, then work on the rescanning script. Based on your previous posting you might have more than one mount point to /media in the FreeNAS GUI setup which does not work.
 

white_flag

Dabbler
Joined
Jul 18, 2012
Messages
16
Hello joeschmuck

you were right. My usb with minidlna database was acting strange. now, it is ok (I put your code (the second one - not that from the first page on this post)) and it is doing the job. one extra question. Can your script to scan just one folder?

in my case (just): /media/NewMovies
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
@ white_flag
Yes the script can scan only one folder but when I say that, I mean it will scan '/media/NewMovies' and that is it, no sub-folders. Using the script in posting #56 and just changing the wait_on line to look at your desired folder is all you need to do.

Now if you don't have a WDTV player or something else funny, you could use the first script and when you add folders it will automatically scan those as well. But since you have things working right now, why mess with it.

I am working on being able to increase the scan limit by 6 times (could be more if needed) but it's proving to be a challenge. I stopped working on it last week after pulling my hair out.
 

DarkCuddles

Dabbler
Joined
Aug 30, 2012
Messages
11
One of the issues I have with this is that restarts are triggered too often. If it happens while I'm in the middle of a tv show or movie, it just drops the connection.

Is there something I can change in this script to prevent that from happening?
 

William Grzybowski

Wizard
iXsystems
Joined
May 27, 2011
Messages
1,754
No, we have to wait until the minidlna developer write support for libevent or someone writes that patch, which is not trivial.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
One of the issues I have with this is that restarts are triggered too often. If it happens while I'm in the middle of a tv show or movie, it just drops the connection.

Is there something I can change in this script to prevent that from happening?
What do you mean by the rescans are triggering too often? You need to describe your situation and the equipment you have on your network. Ensure you read this entire thread as folks using WDTV have unique issues and there is a specific fix for that and you may be in one of those unique areas. Post more information (list equipment and tell me what you have done to date) and I'll be happy to help.

What William said was with respect to the minidlna program itself, not this work around I have going on.
 

DarkCuddles

Dabbler
Joined
Aug 30, 2012
Messages
11
What do you mean by the rescans are triggering too often? You need to describe your situation and the equipment you have on your network. Ensure you read this entire thread as folks using WDTV have unique issues and there is a specific fix for that and you may be in one of those unique areas. Post more information (list equipment and tell me what you have done to date) and I'll be happy to help.

What William said was with respect to the minidlna program itself, not this work around I have going on.



I'm running FreeNAS-8.3.0-RELEASE-p1-x64 (r12825) with CouchPotato, Sab, Sickbeard and MiniDLNA.
I have a large volume of media that I have been playing through my Samsung Smart TV over a wireless dongle that it came with. I have experienced no issues with this.
There are two Windows 7 machines and 1 macbook (which wasn't on the network during this occurrence).
Prior to installing your script, I would have to restart my nas (I have a seperate, unrelated issue - http://forums.freenas.org/showthrea...act-with-plugins&p=54298&viewfull=1#post54298) instead of the full plugin in order to rescan my folders.
I confirmed there was nothing in the sab queue and everything had finished processing, then installed your script.
I followed your instructions to the letter for installing your script (my mount point and folder organisation needed no changing).
I then fired up a movie and after only a few minutes it would cut out, I'd reopen the media folder through the tv and find that it was rescanning everything. I checked Sab and it wasn't downloading anything. The occurrences seems to fit in with the default 5 minute triggereddelay.
Nothing else was happening on the NAS which would indicate any kind of writing/updating to the media folder.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I'm happy to help you out here.

I have a few questions... While not watching a movie, can you tell if the system is rescanning every 5 minutes?

I have a Samsung Smart TV as well, just bought it a few months ago, nice TV, but I can watch movies through it as well and I have no problems with it.

Now to discuss the rescanning... The rescaning occurs on ANY write operation that occurs in the file area being monitored. In the case of the WDTV the device was writing hidden data when it opened the movie. This was not a good thing. So what we need to do is locate what is writing to the area being monitored.

I do not use anything other than MiniDLNA in my plugins so I cannot help you troubleshoot the other items you have running but if they are linked to the directory that the script is checking, that could be a problem. You should turn off all those extra services if you can and then turn on one at a time to see what is causing the issue. So if Sickbeard saves files into the monitored directory, that could be the issue.

You can also look at posting #56 above and that was one of my original scripts which did help some people out and might be the fix for you.

If you cannot figure it out please list all the symptoms and list the files structure, where does the script point to to check for the files, the additional software you are running, where do they point to? Do your best to over describe the problem. I'm not there so you are my eyes and ears.

Also, while you are troubleshooting you could reduce the timer from 5 minutes to 2 minutes so you don't have to wait as long. When you are done you might want to increase the timer to 15 minutes or whatever you like.
 

ulf

Dabbler
Joined
Apr 23, 2013
Messages
33
Nice script, but I think that I don't want the disk to be rescanned continuosly.

Plan to change this so that wait_on is looking in a "Trigger" directory.

If anything happens there, then the NAS will be rescanned.
When I add stuff to the NAS, I have to remember to create that file
(which will be removed by the script)
but I add stuff infrequentlyt, so that is not a problem.
 

ulf

Dabbler
Joined
Apr 23, 2013
Messages
33
Something you might consider adding to the script, is to ensure that all directories are accessible to minidlna
Some (most) subdirectories were not added during a scan, so I downloaded the minidlna source code, and found that
a directory is scanned if the condition below is true:

if( (type == TYPE_DIR) && (access(full_path, R_OK|X_OK) == 0) )
I.E: it is a directory, and the permissions are OK.
I checked, and realized that those directories, I had created using rsync to an NFS mount
from another machine, was only accessible by the owner of the directory, I.E: me, and not by minidlna.
The directories that scanned OK, was manually created by me, after ssh'ing in.

ls ld mydir would print out
software# ls -ld A
drwx------ 2 ulf wheel 44 May 5 09:31 A

so I fixed this:

software# chmod 777 A
software# ls -ld A
drwxrwxrwx 2 ulf wheel 44 May 5 09:31 A

and now the directory "A" can be found.
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Nice script, but I think that I don't want the disk to be rescanned continuosly.

Plan to change this so that wait_on is looking in a "Trigger" directory.

If anything happens there, then the NAS will be rescanned.
When I add stuff to the NAS, I have to remember to create that file
(which will be removed by the script)
but I add stuff infrequentlyt, so that is not a problem.
Not sure what you mean by rescanned continuously as that is why I added wait_on which waits for a change and does not scan the directories actively.

Something you might consider adding to the script, is to ensure that all directories are accessible to minidlna
I don't quite understand what you mean as this is the first time I've heard any directory was not accessible due to a permissions (who created it) issue. If you have a suggestion please post further details along with the full script. If it works properly then others can benefit from your experience. We are always looking for a better way to incorporate automatic scanning and I think the best answer would be if MiniDLNA had it built in and never had to be restarted manually to accomplish it.
 

ulf

Dabbler
Joined
Apr 23, 2013
Messages
33
My material is generated by converting a recorded DVD's to MPEG4 from one or more PCs.
This takes anywhere from 10-30 minutes per DVD, and with your script it may start to scan during the conversion.
I have DVD's with up to 11 titles which would force continuous rescans which I personally have no use for.
Also, I might convert using up to three PC's...

The permissions problem came when I NFS mounted the NAS, and rsync'ed with a disk I removed from my old NAS, and connected to my Linux laptop. Didn't check yet, but I assume that the other NAS generated the directories with permission 700, and during the rsync the user:group was not changed, making the stuff
not accessible to minidlna. I did change the group to "wheel" on everything after the rsync and the MP4's have 755, but did not think about changing the permission on the directories, until I scanned the minidlna code and realized what went wrong. I have seen a number of people having troubles not seeing any content, and if a fix can help people, why not?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
My material is generated by converting a recorded DVD's to MPEG4 from one or more PCs.
This takes anywhere from 10-30 minutes per DVD, and with your script it may start to scan during the conversion.
I have DVD's with up to 11 titles which would force continuous rescans which I personally have no use for.
Also, I might convert using up to three PC's...
I don't see a recommendation from you on what you want fixed.
I don't see a solution for you here if you are going to create into a directory which is being monitored. One recommendation is to create your content in an outside directory and then once you are ready, move the contents into your destination directory. If you do this properly it will be a fast move not a slow copy and delete. A second solution is to not use the script at all and just force MiniDLNA to restart manually. I think in your specific situation the second option might be best as it requires no real changes on your part.

The permissions problem came when I NFS mounted the NAS, and rsync'ed with a disk I removed from my old NAS, and connected to my Linux laptop. Didn't check yet, but I assume that the other NAS generated the directories with permission 700, and during the rsync the user:group was not changed, making the stuff not accessible to minidlna. I did change the group to "wheel" on everything after the rsync and the MP4's have 755, but did not think about changing the permission on the directories, until I scanned the minidlna code and realized what went wrong. I have seen a number of people having troubles not seeing any content, and if a fix can help people, why not?

This is not bad to bring up but this really has nothing to do with an autoscan script and is more about how to ensure a file has proper read permissions. I know that the FreeNAS user guide doesn't specifically call out that the files must have proper read permissions, I'm certain it is assumed you have some knowledge but you can see if it can be included in the users guide if you want.
 

sworn

Cadet
Joined
May 22, 2013
Messages
4
Hi,

thanks for your script - you did a great job.

My Problem:

My NAS is just in a local area network and hasnt got an internet connection. I faced the problem to download "wait_on" (because of no internet connection).

If you execute the command "pkg_add -r wait_on" at the FreeNAS Web-Shell you get kicked out of the jail without comment or error. I recommend to work with ssh (or with the shell of the machine [Option 9 at the console setup]).

So I connected via ssh to the nas and the following error occured:
Code:
#pkg_add -r wait_on
Error: Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-X.X-release/Latest/wait_on.tbz: No address record
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-X.X-release/Latest/wait_on.tbz' by URL


How I fixed that:

There is no chance to get that machine online - so the only way was to get the file on the machine.

1. Download the file from the link, which you got by the error message.

2. Copy the file to the directory to the mount points SOURCE. (e.g /mnt/Volume/Dataset/Share/Media)

3. Switch to the jail (jexec `jls jid` /bin/tcsh)

4. execute the following command: pkg_add /path/to/mountpoint/DESTINATION/wait_on.tbz - for more information [1]

The author of this thread used the mount point destination /media - please replace your destination with the path above (/path/to/...). There are different ways how you get the wait_on.tbz to the nas. I copied it with a configured CIFS share.

Best,
N.

[1] http://www.freebsd.org/doc/en/books/handbook/packages-using.html
 

tanik1

Contributor
Joined
Mar 31, 2013
Messages
163
I am a little confused. So if I have FreeNAS-8.3.1-RELEASE-x64 (r13452) is this scan supposed to be fixed? or do I still need to do what is posted here for the scan media fix?
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I am a little confused. So if I have FreeNAS-8.3.1-RELEASE-x64 (r13452) is this scan supposed to be fixed? or do I still need to do what is posted here for the scan media fix?
MiniDLNA will not automatically recognize changes in your file database for any FreeNAS system at this time. In order to work around this short coming I created this little tweak. Once there is a fix, I will update the posting to reflect which version you don't need this fix in. Of course you could just perform a manual rescan if you like, it depends how automated you want your system.
 
Status
Not open for further replies.
Top