This page looks best with JavaScript enabled

WebDAV Access through RClone

 ·  🎃 kr0m

In this article, we will see how to access a WebDAV storage space from Rclone, a versatile tool that will provide us with transparent access since it will offer us said content as a fuseFS file system.

We install RClone:

pkg install rclone

We add the WebDAV access configuration, in my case it is the storage space provided by my internet access ISP DIGI:

rclone config

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> n
name> DIGI

Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
42 / Webdav
   \ (webdav)
Storage> 42

Option url.
URL of http host to connect to.
E.g. https://example.com.
Enter a value.
url> https://digistorage.es:443/dav/DIGIstorage

Option vendor.
Name of the Webdav site/service/software you are using.
Choose a number from below, or type in your own value.
Press Enter to leave empty.
 5 / Other site/service or software
   \ (other)
vendor> 5

Option user.
User name.
In case NTLM authentication is used, the username should be in the format 'Domain\User'.
Enter a value. Press Enter to leave empty.
user> jjivarspoquet@gmail.com

Option pass.
Password.
Choose an alternative below. Press Enter for the default (n).
y) Yes, type in my own password
g) Generate random password
n) No, leave this optional password blank (default)
y/g/n> y
Enter the password:
password: XXXXX
Confirm the password:
password: XXXXX

Option bearer_token.
Bearer token instead of user/pass (e.g. a Macaroon).
Enter a value. Press Enter to leave empty.
bearer_token> 
Edit advanced config?
y) Yes
n) No (default)
y/n> n

--------------------
[DIGI]
type = webdav
url = https://digistorage.es:443/dav/DIGIstorage
vendor = other
user = jjivarspoquet@gmail.com
pass = *** ENCRYPTED ***
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y

Current remotes:

Name                 Type
====                 ====
DIGI                 webdav

We manually test that it works without problems:

rclone mount DIGI: /mnt/DIGI –vfs-cache-mode full –allow-other –config /root/.config/rclone/rclone.conf

We can see that the reported space is 1 Petabyte, but this information is not correct since the DIGI web interface indicates that we have 50GB available.

df -Th

Filesystem                               Type             Size    Used   Avail Capacity  Mounted on
/dev/fuse                                fusefs.rclone    1.0P      0B    1.0P     0%    /mnt/DIGI

We generate the RC script:

vi /usr/local/etc/rc.d/rcloneDIGI

#! /bin/sh
#
# $FreeBSD$
#

# PROVIDE: rcloneDIGI
# REQUIRE: DAEMON
# KEYWORD: shutdown 

. /etc/rc.subr

name="rcloneDIGI"
rcvar="${name}_enable"
extra_commands="status"

start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"

rcloneDIGI_start(){
    echo "Starting service: ${name}"
    /usr/sbin/daemon -S -p /var/run/${name}.pid -T rclone -u root /usr/local/bin/rclone mount DIGI: /mnt/DIGI --vfs-cache-mode full --allow-other --config /root/.config/rclone/rclone.conf
}

rcloneDIGI_stop(){
    if [ -f /var/run/${name}.pid ]; then
        echo "Stopping service: ${name}"
        kill -s INT $(cat /var/run/${name}.pid)
        sleep 3
    else
        echo "It appears ${name} is not running."
    fi
}

rcloneDIGI_status(){
    if [ -f /var/run/${name}.pid ]; then
        echo "${name} running with PID: $(cat /var/run/${name}.pid)"
    else
        echo "It appears ${name} is not running."
    fi
}


load_rc_config ${name}
run_rc_command "$1"

We enable the service:

sysrc rcloneDIGI_enable=yes

We start it:

service rcloneDIGI start

We can now access the content transparently:

ls -la /mnt/DIGI/

total 2876
drwxr-xr-x  1 root  wheel        0 Sep  1 09:35 .
drwxr-xr-x  5 root  wheel        5 Jul 16 17:37 ..
-rw-r--r--  1 root  wheel   116692 Jul 23 14:21 61441e4ecbb7f6c60d7ecaeb0534f9ca.jpg
drwxr-xr-x  1 root  wheel        0 Jul 16 18:07 Backups
-rw-r--r--  1 root  wheel  2827078 Jul 20 06:06 Guia_rapida_Digi_Storage.pdf
If you liked the article, you can treat me to a RedBull here