diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2024-08-20 20:44:34 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2024-08-20 20:44:34 -0300 |
commit | e851401694daacaf1aba2c87ed557e5dbf00af02 (patch) | |
tree | d772b15f3a5ba9e015936f7162f448a7208a4001 /copy-item-to-kobo | |
parent | d6a4d78d31ffa57e00a7d5b0a87baa38156cee06 (diff) | |
download | scripts-e851401694daacaf1aba2c87ed557e5dbf00af02.tar.gz scripts-e851401694daacaf1aba2c87ed557e5dbf00af02.tar.bz2 |
Move scripts to other repositories
Diffstat (limited to 'copy-item-to-kobo')
-rwxr-xr-x | copy-item-to-kobo | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/copy-item-to-kobo b/copy-item-to-kobo deleted file mode 100755 index aa751fb..0000000 --- a/copy-item-to-kobo +++ /dev/null @@ -1,54 +0,0 @@ -#!/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 <pattern>" - exit 1 -fi - -# Dispatch -show --search "$PATTERN" | while read item; do - dirname="`dirname "$item"`" - - # Check if item has unspported chars in it's file name - if echo "$item" | grep -q ':'; then - echo "$BASENAME: unsupported character ':' in file name '$item'" - echo "$BASENAME: please rename the file and try again" - exit 1 - fi - - echo "Copying $item..." - - silentSsh $REMOTE <<EOC - mkdir -p "$REMOTE_BASE/$dirname" - touch "$REMOTE_BASE/$item" -EOC - - scp "$BASEFOLDER/$item" "$REMOTE:$REMOTE_BASE/$TMPFILE" - silentSsh $REMOTE <<EOS - mv "$REMOTE_BASE/$TMPFILE" "$REMOTE_BASE/$item" -EOS -done |