Esta pagina se ve mejor con JavaScript habilitado

Acceso WebDAV mediante RClone

 ·  🎃 kr0m

En este artículo veremos como acceder a un espacio de almacenamiento WebDAV desde Rclone una versátil herramienta que nos proporcionará acceso transparente ya que nos ofrecerá dicho contenido como sistema de ficheros fuseFS.

Instalamos RClone:

pkg install rclone

Añadimos la configuración de acceso al WebDAV en mi caso se trata del espacio de almacenamiento proporcionado por mi ISP de acceso a internet 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

Probamos manualmente que funcione sin problemas:

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

Podemos ver que el espacio reportado es de 1 Petabyte, pero esta información no es correcta ya que la interfaz web de DIGI indica que disponemos de 50Gb.

df -Th

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

Generamos el script de RC:

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"

Habilitamos el servicio:

sysrc rcloneDIGI_enable=yes

Lo arrancamos:

service rcloneDIGI start

Ya podemos acceder de forma transparente al contenido:

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
Si te ha gustado el artículo puedes invitarme a un RedBull aquí