#!/bin/bash # # A mini-wrapper to copy a remote kobo annotation into a local one. # # Parameters BASENAME="`basename $0`" DIRNAME="`dirname $0`" BASEFOLDER="$HOME/data/doc" REMOTE_BASE="/mnt/sd" REMOTE="kobo" PATTERN="$1" # 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 $DIRNAME/docshower --search "$PATTERN" | while read item; do #sdr="`echo $item | sed -e 's/\.pdf$//' -e 's/\.epub$//' -e 's/\.djvuf$//'`.sdr" basename="`echo $item | sed -e 's/\.[^.]*$//'`" extension="$(echo $item | sed -e "s|$basename.||")" sdr="$basename.sdr" # Check if remote file exists silentSsh $REMOTE <"$BASEFOLDER/$sdr/metadata.$extension.lua" <