From: Roman Bazalevskiy Date: Mon, 6 Apr 2015 21:23:55 +0000 (+0300) Subject: Tool to monitor ebook device connection and sync remote (webdav) folder to ebook... X-Git-Url: https://git.rvb.name/sync-ebook.git/commitdiff_plain/refs/heads/master?ds=sidebyside Tool to monitor ebook device connection and sync remote (webdav) folder to ebook internal storage. --- d1884749a0d8f9241fe6fc582218a41d0cc32927 diff --git a/ebook.conf b/ebook.conf new file mode 100644 index 0000000..a3bff68 --- /dev/null +++ b/ebook.conf @@ -0,0 +1,7 @@ +USER=user +PASSWD=mystrongpasswd +DAVFS=davs://server/path +EBOOK=/media/rvb/EbookLabel +SRCDIR="Books" +DSTDIR="My Books" +TEMPLATE="*.fb2,*.fb2.zip" diff --git a/mount-gvfs b/mount-gvfs new file mode 100755 index 0000000..58a68a9 --- /dev/null +++ b/mount-gvfs @@ -0,0 +1,10 @@ +#!/usr/bin/expect + +set timeout 10 +spawn gvfs-mount [lindex $argv 0] +expect "User:" +send "[lindex $argv 1]\r" +expect "Password:" +send "[lindex $argv 2]\r" +expect eof + diff --git a/mount-watcher b/mount-watcher new file mode 100755 index 0000000..de64e73 --- /dev/null +++ b/mount-watcher @@ -0,0 +1,15 @@ +#!/bin/bash + +. ~/.config/ebook.conf + +udisksctl monitor | grep --line-buffered MountPoints | while read -r line +do + + MOUNTED=`echo $line | awk '{ print $2 }'` + if [ "$MOUNTED" == "$EBOOK" ]; + then + sleep 5 + sync-ebook + fi + +done diff --git a/sync-ebook b/sync-ebook new file mode 100755 index 0000000..4e9a665 --- /dev/null +++ b/sync-ebook @@ -0,0 +1,22 @@ +#!/bin/sh + +. ~/.config/ebook.conf + +mount-gvfs $DAVFS $USER $PASSWD + +MOUNT=$XDG_RUNTIME_DIR/gvfs/ +DIR=`gvfs-info $DAVFS | grep "id::filesystem" | awk '{ print $2; }'` + +if [ "$DIR" != "" ] +then + +MOUNT=$XDG_RUNTIME_DIR/gvfs/$DIR + +if [ -d $EBOOK ] +then + +rsync -ru --include=$TEMPLATE --exclude=.* "$MOUNT/$SRCDIR/" "$EBOOK/$DSTDIR/" + +fi + +fi \ No newline at end of file