OpenWrt: mounting WebDAV cloud storage services (Box.com, Google Drive and others)

I found this post a while ago and it has been on the back of my mind for some time now. Having access to WebDAV cloud storage services (Box.com, Google Drive, Yandex.Disk, 4shared.com) on OpenWrt can be very useful since OpenWrt routers have limited storage but at the same time good connectivity. Applications for such a setup can include downloading torrents directly to the cloud or syncing several cloud services.

 

Box

Box

Google Drive

Google Drive

 

I am assuming that if you are reading this tutorial you already have some expertise with OpenWrt and that at least you have already built it from source. I am going to explain how to compile the davfs2 package needed to mount a WebDAV service on OpenWrt and I will be using backfire 10.03.1. Some background information on how to compile single packages in OpenWrt can be found here.

First we need to download the required packages and as explained in the original post, you need to update your sources. Go to your top level backfire directory and type:

 

boo@thenational:~/trunk$ echo "src-svn rtndev http://wl500g-repo.googlecode.com/svn/feeds/rtndev" >> feeds.conf.default
boo@thenational:~/trunk$ ./scripts/feeds update -a
boo@thenational:~/trunk$ ./scripts/feeds install-a

 

That will download and install some packages, including davfs2. Type make menuconfig and enable davfs2 under Network->FileSystem:

 

Enable davfs2 module

Enable davfs2 module

 

Before compiling the package we need to do some patching. To the Makefile (trunk/feeds/rtndev/davfs2/Makefile)  and to a file called cache.c in trunk/build_dir/target-mips_uClibc-0.9.30.1/davfs2-1.4.7/src/cache.c. The patches are in this file davfs2-patches-openwrt.tar.gz, and apply the patch to the Makefile.

The source code for the module is downloaded at compile time (including cache.c), so you will need to try to compile the package and wait for the error:

 

boo@thenational:~/trunk$ make package/feeds/rtndev/davfs2/compile V=99

 

And you will see the following error:

 

cache.c:58:23: error: sys/xattr.h: No such file or directory

 

Now that you have the file, patch it and compile again and this time the compilation should finish successfully. The patch does two things: removes the include of sys/xattr.h and implements getpwuid(). Surprisingly OpenWrt does not seem to implement this function (since it is not designed as a multi user system) and always returns null. The implementation I have included parses /etc/passwd and returns a passwd struct correctly formated.

Install and index the package:

 

make package/feeds/rtndev/davfs2/install
make package/feeds/rtndev/davfs2/index

 

And you should find it ready in bin/brcm63xx/packages/davfs2_1.4.7-2_brcm63xx.ipk. I have uploaded it here for completeness, if your target is brcm63xx it may save you some time: davfs2_1.4.7-2_brcm63xx.ipk.tar.gz

Now you are ready to upload the package to your router and install it.

 

root@OpenWrt:~# opkg install davfs2_1.4.7-2_brcm63xx.ipk

 

And mount a cloud service, box for instace:

 

root@OpenWrt:~# /opt/sbin/mount.davfs https://www.box.com/dav/ /mnt
 
Please enter the username to authenticate with server
https://www.box.com/dav/ or hit enter for none.
Username: YOUR_EMAIL_ADDRESS
Please enter the password to authenticate user YOUR_EMAIL_ADDRESS with server
https://www.box.com/dav/ or hit enter for none.
Password:  YOUR_PASSWORD
/opt/sbin/mount.davfs: the server certificate is not trusted
issuer:      GeoTrust, Inc., US
subject:     Box.net, Inc., Palo Alto, California, US, ts5jamwzcjWP0oTyh2m74yh0zsB2zyOR
identity:    *.box.com
fingerprint: ca:bd:64:fd:6b:84:5f:5d:35:98:12:fe:a6:1c:4e:55:5e:7f:57:f5
You only should accept this certificate, if you can
verify the fingerprint! The server might be faked
or there might be a man-in-the-middle-attack.
Accept certificate for this session? [y,N] y

 

You can verify that the service is there:

 

root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                13.3M     13.3M         0 100% /rom
tmpfs                     6.5M      1.5M      5.0M  23% /tmp
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/sda1               119.4M     25.8M     87.4M  23% /overlay
mini_fo:/overlay         13.3M     13.3M         0 100% /
https://www.box.com/dav/ 25.4G     12.7G     12.7G  50% /mnt

 

And you can just access your files, as normal:

 

root@OpenWrt:~# ls /mnt/
lost+found   trololo.jpg

 

troloro.jpg

troloro.jpg

 

Cool, right? In the next post I’ll explain how to mount these partitions automatically on boot. In the meantime, enjoy!

 

 

Share on Facebook
Share on Twitter+1Share on LinkedInPin it on Pinteresthttp://www.gotxi.org/ibon/wp-content/uploads/2012/09/davfs2_21-300x179.pngShare via emailShare on MyspaceDigg ThisSubmit to redditShare on TumblrSubmit to StumbleUponShare on XingFlattr this!Add to Buffer