From 27e0e0256f91455f809eb91d3bea0ad8fb5f4180 Mon Sep 17 00:00:00 2001 From: lelgenio Date: Sat, 17 Oct 2020 14:29:17 -0300 Subject: [PATCH] add rclone --- config.yaml | 3 +++ dotfiles/rclone.conf | 6 ++++++ funcs.py | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 dotfiles/rclone.conf diff --git a/config.yaml b/config.yaml index ea607a2..01bcdae 100644 --- a/config.yaml +++ b/config.yaml @@ -163,6 +163,9 @@ dotfiles: # {{{ dst: ~/.config actions: - vdirsyncer + rclone: + src: rclone.conf + dst: ~/.config/rclone/rclone.conf mutt: src: neomutt/ dst: ~/.config/neomutt/ diff --git a/dotfiles/rclone.conf b/dotfiles/rclone.conf new file mode 100644 index 0000000..338a6cb --- /dev/null +++ b/dotfiles/rclone.conf @@ -0,0 +1,6 @@ +[{{@@ mail.strip("mail.").split(".")[0] @@}}] +type = webdav +vendor = nextcloud +user = {{@@ username @@}} +pass = {{@@ rclone_obscure(mail) @@}} +url = https://cloud.{{@@ mail @@}}/remote.php/webdav/ diff --git a/funcs.py b/funcs.py index 789ca77..70bb64b 100644 --- a/funcs.py +++ b/funcs.py @@ -1,4 +1,6 @@ import os +from subprocess import check_output +import re def parent_dir(path): @@ -31,3 +33,20 @@ def hex2rgb(e): b = e[4:6] return ", ".join([h2r(i) for i in (r, g, b)]) + + +def rclone_obscure(pass_name): + try: + fPath = os.path.expanduser("~/.config/rclone/rclone.conf") + t = open(fPath, 'r').read() + + PASSWORD_PATTERN = r'^pass *= *(.*)$' + password = re.search(PASSWORD_PATTERN, t, re.M).group(1) + return password + except Exception: + pass + + def sh(*args): + return check_output(args).decode().strip() + + return sh("rclone", "obscure", sh("_get-pass", pass_name))