Need automounter for smb
|Status:||Closed||Start date:||05 May 2014|
|Category:||04 - Root File System|
|Severity:||03 - Medium|
A PiBox Media Server or Media Player should automatically locate and mount local PiBox servers. This can be done with a simple daemon that queries the network periodically looking for the right workgroup (I think).
I could try using autofs though its probably faster to just write a simple app to do it.
#2 Updated by Hammel over 3 years ago
- % Done changed from 10 to 20
- findsmb, which is available in buildroot but requires adding perl to the build.
- smbclient -N -L, but this doesn't seem to give a server name
- Use nmap as in the ArchLinux wiki
I'd like to test findsmb but it's not on Fedora for some reason. I'll need to test it before I roll it into the distribution.
#3 Updated by Hammel over 3 years ago
- % Done changed from 20 to 30
This might be simpler than I thought. I found "findsmb" in the samba source and tried it. It didn't work, but I read the code and found it just called nmblookup. So I tried that with this command line:
And it worked. It gave me the IP address of a local smb client in the first field (space delimited). Since PiBox will run on a closed network with the Media Server providing the smb share this simple command is enough for the Media Player to find the IP of the Media Server and mout its share with this command.
mount -t cifs //<host>/media /mnt/pibox -o user=guest,guest
#5 Updated by Hammel over 3 years ago
- Priority changed from Immediate to High
- % Done changed from 30 to 50
- Severity changed from 01 - Critical to 03 - Medium
- Write a small program that runs once every X seconds to test for smb shares using nmblookup '*' - a cron job could be used but I'd have to have it run in very short intervals and I'd rather do that within a simple daemon.
- If nmblookup finds any hosts, its tries to mount them under /media/<ip>/. If that exists, then the mount attempt is ignored.
- After the nmblookup is run, the list of existing mounts should be run to make sure any existing mounts are still valid. If not, the mount is removed.
That should cover it. For efficient sake this program will be written in C. Now that I think about it, it would make sense to add this as a new thread in piboxd.
#6 Updated by Hammel about 3 years ago
- % Done changed from 50 to 60
The mount/unmount is implemented in piboxd and seems to work, but the network hiccups make it look like a mount goes away very quickly. This makes mounts bounce up and down very quickly.
There are a number of ways to address this. One is to not test a mount point that is in use (with, possibly, fuser?). Another is to not test a mount point that is younger than a configured time. That would require switching from simple strings in lists to data structures.
Another options is to run nmblookup multiple times so we have a better chance of catching nodes that appear to be missing.
#7 Updated by Hammel about 3 years ago
- Status changed from In Progress to Closed
- % Done changed from 60 to 100
Added support for mounting and unmounting smb shares to piboxd. Interestingly, I found that one of the Pi's with an available share was using a non-RT5370. That machine kept dropping out and coming back. The RT5370 Pi was stable. I'm now very adamant about getting an RT5370-based wifi adapter for all my boxes.
This issue can be closed.