]> gitweb.fluxo.info Git - scripts.git/commitdiff
Adds receive-from-kobo
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 10 May 2020 17:04:24 +0000 (14:04 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 10 May 2020 17:04:24 +0000 (14:04 -0300)
receive-from-kobo [new file with mode: 0755]

diff --git a/receive-from-kobo b/receive-from-kobo
new file mode 100755 (executable)
index 0000000..74b89ef
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# A mini-wrapper to sync a kobo folder into a local one.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+BASEFOLDER="$HOME/data/doc"
+COLLECTION="$1"
+
+# Check
+if [ -z "$COLLECTION" ]; then
+  echo "usage: $BASENAME <colletion>"
+  echo "available collections:"
+  echo ""
+  ls $BASEFOLDER
+  exit 1
+fi
+
+# Ensure collection exists
+if [ ! -d "$BASEFOLDER/$COLLECTION" ]; then
+  echo "error: no such collection $COLLECTION at $BASEFOLDER"
+  exit 1
+fi
+
+# Setup origin
+if [ "$COLLECTION" == "clipboard" ]; then
+  ORIGIN="/mnt/onboard/.adds/koreader/clipboard"
+else
+  ORIGIN="/mnt/sd/$COLLECTION"
+fi
+
+# Dispatch
+lftp -c "open sftp://kobo && mirror -L $ORIGIN $BASEFOLDER/$COLLECTION"