add rclone

This commit is contained in:
lelgenio 2020-10-17 14:29:17 -03:00
parent 80e5f59cf7
commit 27e0e0256f
3 changed files with 28 additions and 0 deletions

View File

@ -163,6 +163,9 @@ dotfiles: # {{{
dst: ~/.config
actions:
- vdirsyncer
rclone:
src: rclone.conf
dst: ~/.config/rclone/rclone.conf
mutt:
src: neomutt/
dst: ~/.config/neomutt/

6
dotfiles/rclone.conf Normal file
View File

@ -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/

View File

@ -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))