From a6d0aeca708c5a6f460ec6b2d62aa3522e00ba53 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 1 Jan 2023 17:07:37 -0300 Subject: Feat: adds copy-item-to-kobo --- copy-annotations-from-kobo | 2 +- copy-item-to-kobo | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100755 copy-item-to-kobo diff --git a/copy-annotations-from-kobo b/copy-annotations-from-kobo index 19c894c..3e10275 100755 --- a/copy-annotations-from-kobo +++ b/copy-annotations-from-kobo @@ -1,6 +1,6 @@ #!/bin/bash # -# A mini-wrapper to copu a remote kobo annotation into a local one. +# A mini-wrapper to copy a remote kobo annotation into a local one. # # Parameters diff --git a/copy-item-to-kobo b/copy-item-to-kobo new file mode 100755 index 0000000..0650a52 --- /dev/null +++ b/copy-item-to-kobo @@ -0,0 +1,47 @@ +#!/bin/bash +# +# A mini-wrapper to copy a local item to kobo. +# + +# Parameters +BASENAME="`basename $0`" +BASEFOLDER="$HOME/data/doc" +REMOTE_BASE="/mnt/sd" +REMOTE="kobo" +PATTERN="$1" +TMPFILE="tmpwork" + +# Thanks https://serverfault.com/a/764403 +# https://serverfault.com/questions/36421/stop-ssh-login-from-printing-motd-from-the-client#38160 +function silentSsh { + local connectionString="$1" + shift + local commands="$*" + if [ -z "$commands" ]; then + commands=`cat` + fi + ssh -T $connectionString "$commands" +} + +# Check +if [ -z "$PATTERN" ]; then + echo "usage: $BASENAME " + exit 1 +fi + +# Dispatch +show --search "$PATTERN" | while read item; do + dirname="`dirname "$item"`" + + echo "Copying $item..." + + silentSsh $REMOTE <