Sign up here and you can log into the forum!

NETAPP from a different folder(other than root of the share)

General homebrew discussion area

NETAPP from a different folder(other than root of the share)   

Postby Martin_L » Sat Jun 08, 2013 2:58 pm

Hello friends,

I wanted to use NETAPPS (add-ons such as *.app.bin(s) located in a network share instead of a local drive connected to usb), using the usb port of my home router, with a flash memory.
http://forum.wdlxtv.com/viewtopic.php?f=38&t=2529

Unfortunately, my router forces the content within the flash memory into a subfolder (called usb1_1) within the share, making it impossible to put the apps in the root of the share.

This is how I solved the problem, just in case someone needs to do the same thing.

I needed to hack the file "crazymount" (located in /bin/ folder) to accept a network share with an added path to a folder.
Previously it only accepted:
Code: Select all
crazymount NETMOUNT //192.168.1.1/share
Now it accepts:
Code: Select all
crazymount NETMOUNT //192.168.1.1/share/usb1_1

To that end, copy the file to /conf/, modify it as follows, and with the adecuate instructions in the file net.config(see below) override the original file.
Code: Select all
cp /bin/crazymount /conf/
edit the following lines (278-291 in the original crazymount file):
Code: Select all
elif [ "$1" == "NETMOUNT" ] ; then
    if [ ! -d "$2" ] ; then
        logger -t `basename $0` "server address passed: $2 ?"
        /etc/init.d/S01ipup forcestart
        [ -n "`echo $2 | egrep -o '[0-9]+.[0-9]+.[0-9]+.[0-9]+:/.*'`" ] && /etc/init.d/S10portmap forcestart
        [ -n "$3" ] && OPTIONS="-o $3"
        hash="`echo $2 | md5sum | head -c 32`"
        mkdir /tmp/mnt/$hash
        mount "$2" /tmp/mnt/$hash $OPTIONS
        [ $? -eq 0 ] && _scanLocation "$1" /tmp/mnt/$hash || rmdir /tmp/mnt/$hash
    else
        _scanLocation "$1" "$2"
    fi
else
...to read as follows...
Code: Select all
elif [ "$1" == "NETMOUNT" ] ; then
    if [ ! -d "$2" ] ; then
        logger -t `basename $0` "server address passed: $2 ?"
        /etc/init.d/S01ipup forcestart
        [ -n "`echo $2 | egrep -o '\/?\/?[0-9]+.[0-9]+.[0-9]+.[0-9]+:?/[^/]*'`" ] && /etc/init.d/S10portmap forcestart
        [ -n "$3" ] && OPTIONS="-o $3"
        hash="`echo $2 | egrep -o '\/?\/?[0-9]+.[0-9]+.[0-9]+.[0-9]+:?/[^/]*' | md5sum | head -c 32`"
        mkdir /tmp/mnt/$hash
        mount "`echo $2 | egrep -o '\/?\/?[0-9]+.[0-9]+.[0-9]+.[0-9]+:?/[^/]*'`" /tmp/mnt/$hash $OPTIONS
   subdirectory="`echo $2 | sed -r 's/\/?\/?[0-9]+.[0-9]+.[0-9]+.[0-9]+:?\/[^/]*(.*)/\1/'`"
   logger -t `basename $0` "subdirectory identified: $subdirectory ?"
        [ $? -eq 0 ] && _scanLocation "$1" /tmp/mnt/$hash$subdirectory || rmdir /tmp/mnt/$hash
    else
        _scanLocation "$1" "$2"
    fi
else

Afterwards, create a net.config file with the following contents:
Code: Select all
cp /conf/crazymount /tmp
chmod +x /tmp/crazymount
mount -o bind /tmp/crazymount /bin/crazymount
crazymount NETMOUNT //192.168.1.1/share/usb1_1 user=,pass=
(192.168.1.1/share/usb1_1 must be replaced with YOUR particular share and folder)
Put that file in the root of an USB flash memory or hard drive attached to the WDTV (for first test, as recommended by b-rad) and reboot.
If everything works fine, move that file to /conf/ and reboot.

Congratulations, your app.bin(s) should be working now from a subdirectory of your share.

Enjoy,
Martin

(For reference, my setup: FW Base: 1.05.04 Device: WDLXTV_LIVE Current version: 0.5.1.1)
Martin_L
DLX'er
 
Posts: 67
Joined: Mon Mar 28, 2011 3:11 am

Re: NETAPP from a different folder(other than root of the sh   

Postby mad_ady » Sat Feb 21, 2015 2:09 am

I'm considering adding your patch to the firmware.
I haven't usedd NETAPPs, but I'd like to know if your changes are backwardly compatible with the original code, meaning - would mounting from root share still work without changes? From what I understand of the regexes, it would seem so, but can you confirm?

Also, I am a bit worried you're breaking the code here:
Code: Select all
   subdirectory="`echo $2 | sed -r 's/\/?\/?[0-9]+.[0-9]+.[0-9]+.[0-9]+:?\/[^/]*(.*)/\1/'`"
   logger -t `basename $0` "subdirectory identified: $subdirectory ?"
        [ $? -eq 0 ] && _scanLocation "$1" /tmp/mnt/$hash$subdirectory || rmdir /tmp/mnt/$hash


$? will be the return code of logger, which I doubt will ever fail. Previously it was right after the mount command and it checked if the mount was successful or not.

Can you make the necessary corrections and resubmit this patch for inclusion?
Thanks!
User avatar
mad_ady
Developer
 
Posts: 4522
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: NETAPP from a different folder(other than root of the sh   

Postby Martin_L » Sun Feb 22, 2015 4:44 am

You are right. I will re-order the code and test it. Thank you.

My intention was it to be backwards compatible. I will revise the code... and try to test it. But I have to figure out the setup as I do not have more shares at home at the moment.

Martin
Martin_L
DLX'er
 
Posts: 67
Joined: Mon Mar 28, 2011 3:11 am

Re: NETAPP from a different folder(other than root of the sh   

Postby kroetkroet » Sun Feb 22, 2015 9:15 am

If it may help: in windows you can easily add "File and Printer sharing" protocol on your network interfaces, and start sharing all you want.
If it may help2: run a VMware test image like I do, you can easily switch from linux distros to windows and even cool stuff like XPEnology to simulate Synology NAS - then you have NFS/CIFS shares for free :lol:

Greetz!
KK
WDLXTV-fan! - In case you need further assistance: read our WIKI, search our Forum and most of all: donate 'something' to b-rad for his great efforts!!!
User avatar
kroetkroet
Beta Tester
 
Posts: 1004
Joined: Mon Apr 05, 2010 11:53 pm

Re: NETAPP from a different folder(other than root of the sh   

Postby Martin_L » Sun Feb 22, 2015 2:16 pm

new reordered code:
Code: Select all
    elif [ "$1" == "NETMOUNT" ] ; then
        if [ ! -d "$2" ] ; then
            logger -t `basename $0` "server address passed: $2 ?"
            /etc/init.d/S01ipup forcestart
            [ -n "`echo $2 | egrep -o '\/?\/?[0-9]+.[0-9]+.[0-9]+.[0-9]+:?/[^/]*'`" ] && /etc/init.d/S10portmap forcestart
            [ -n "$3" ] && OPTIONS="-o $3"
            hash="`echo $2 | egrep -o '\/?\/?[0-9]+.[0-9]+.[0-9]+.[0-9]+:?/[^/]*' | md5sum | head -c 32`"
            mkdir /tmp/mnt/$hash
            subdirectory="`echo $2 | sed -r 's/\/?\/?[0-9]+.[0-9]+.[0-9]+.[0-9]+:?\/[^/]*(.*)/\1/'`"
            logger -t `basename $0` "subdirectory identified: $subdirectory ?"
            mount "`echo $2 | egrep -o '\/?\/?[0-9]+.[0-9]+.[0-9]+.[0-9]+:?/[^/]*'`" /tmp/mnt/$hash $OPTIONS
            [ $? -eq 0 ] && _scanLocation "$1" /tmp/mnt/$hash$subdirectory || rmdir /tmp/mnt/$hash
        else
            _scanLocation "$1" "$2"
        fi
    else


I tested de fundamental regex, which is the one that feeds the variable subdirectory. This is empty is the netapp call carries just the share ("//192.168.1.1/share"), thus scanning the right location 3 lines below.

Still need to test it in a real world scenario, but I am afraid that that is going to be delayed do to time constraints on my side.
Last edited by Martin_L on Sun Feb 22, 2015 3:44 pm, edited 1 time in total.
Martin_L
DLX'er
 
Posts: 67
Joined: Mon Mar 28, 2011 3:11 am

Re: NETAPP from a different folder(other than root of the sh   

Postby Martin_L » Sun Feb 22, 2015 3:43 pm

I checked the code in v 5.20 and it was slightly modified. I introduced my changes in the 5.20 file, so it is easyer to test (just copy it in /conf, rename it, and write conf/net.config). The file is here.

I also tested the new code (changed lines order and new 5.20 base). I works well with my regular subfolder setting.

I followed kroetkroet tip and ran a XP virtual machine with a shared folder (apps in the root of the share). The apps were recognized and running as well.
There was a little problem here. I do not know why but the OSD did not start. I would really appreciate some other tester on their regular setup (just replace crazymount), and report if there is any problem. I did not test whether the problem also happened with the unmodified file but I suspect it was something of my XP share in particular.

Regards,
Martin
Martin_L
DLX'er
 
Posts: 67
Joined: Mon Mar 28, 2011 3:11 am

Re: NETAPP from a different folder(other than root of the sh   

Postby mad_ady » Mon Feb 23, 2015 1:52 am

The patch looks better now. I commited it:

Code: Select all
adrianp@frost:~/development/wdtv-1.05/live/trunk/bin$ svn commit -m "Allow NETAPPs to be loaded from a subdirectory instead only from the root of a network share. Patch by Martin_L"
Sending        crazymount
Transmitting file data .
Committed revision 777.

User avatar
mad_ady
Developer
 
Posts: 4522
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania


Return to WDTV G2 & WDTV Live homebrew discussion

Who is online

Users browsing this forum: No registered users and 1 guest