From eeebfbab6310974802edd525fe277fa7312bef22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Rigo?= Date: Wed, 10 Feb 2021 21:09:55 +0100 Subject: [PATCH 1/6] quote some argument --- host/repush.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/repush.sh b/host/repush.sh index 5c6f615..f1c2716 100755 --- a/host/repush.sh +++ b/host/repush.sh @@ -268,7 +268,7 @@ function uuid_of_root_file { for metadata_path in $matches_by_name; do - metadata="$(ssh -S remarkable-ssh root@"$SSH_ADDRESS" "cat $metadata_path")" + metadata="$(ssh -S remarkable-ssh root@"$SSH_ADDRESS" "cat \"$metadata_path\"")" if echo "$metadata" | grep -qF '"parent": ""' && echo "$metadata" | grep -qF '"deleted": false'; then RET_UUID="$(basename "$metadata_path" .metadata)" From b3f702d99f1ffe11c65f916513f7b47acb772cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Rigo?= Date: Wed, 10 Feb 2021 21:10:24 +0100 Subject: [PATCH 2/6] Fixes for reMarkable 2, from issue #31 --- host/repush.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/repush.sh b/host/repush.sh index f1c2716..2fe5f7a 100755 --- a/host/repush.sh +++ b/host/repush.sh @@ -335,7 +335,7 @@ function push { directory="" fi - placeholder_basename="$(basename "$1")" + placeholder_basename="$(basename "$1" ".$extension")" # Since the WebUI doesn't accept directories, we're creating a PDF placeholder # fs entry, who's metadata we'll then alter to that of a directory fs entry @@ -525,7 +525,7 @@ fi # Check if file with same name already exists in the root directory for f in "$@"; do - uuid_of_root_file "$(basename "$f")" + uuid_of_root_file "$(basename "$f" "${f##*.}")" if [ ! -z $RET_UUID ]; then echo "repush: Cannot push '$f': File already exists in root directory" From d8b577292a62fe6cb21f0d420fa3d4154408a7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Rigo?= Date: Wed, 10 Feb 2021 21:10:40 +0100 Subject: [PATCH 3/6] use ssh ControlPath for scp too --- host/repush.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/repush.sh b/host/repush.sh index 2fe5f7a..df124fe 100755 --- a/host/repush.sh +++ b/host/repush.sh @@ -378,7 +378,7 @@ function push { # Replace placeholder with document retry="" while true; do - scp "$(realpath "$1")" root@"$SSH_ADDRESS":"/home/root/.local/share/remarkable/xochitl/$RET_UUID.$extension" + scp -oControlPath=remarkable-ssh "$(realpath "$1")" root@"$SSH_ADDRESS":"/home/root/.local/share/remarkable/xochitl/$RET_UUID.$extension" if [ $? -ne 0 ]; then read -r -p "Failed to replace placeholder! Retry? [Y/n]: " retry From eff8f5243c6548e46efe4786cfc2eca6181a1a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Rigo?= Date: Thu, 18 Feb 2021 19:17:51 +0100 Subject: [PATCH 4/6] Support uploading symlinks --- host/repush.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/repush.sh b/host/repush.sh index df124fe..f421de7 100755 --- a/host/repush.sh +++ b/host/repush.sh @@ -284,7 +284,7 @@ function uuid_of_root_file { # $? - 1: file valid | 0: file invalid function check_file { - file_cmd_output="$(file -F '|' "$1")" + file_cmd_output="$(file -LF '|' "$1")" if echo "$file_cmd_output" | grep -q "| directory"; then local is_directory="true" @@ -318,7 +318,7 @@ function check_file { function push { ((TOTAL++)) - file_cmd_output="$(file -F '|' "$1")" + file_cmd_output="$(file -LF '|' "$1")" # If file is directory, set extension to PDF for placeholder file if echo "$file_cmd_output" | grep -q "| \(PDF\|directory\)"; then From 8d05db45ea60d6ac96ffdbf8f2817912eace9ab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Rigo?= Date: Thu, 18 Feb 2021 19:18:12 +0100 Subject: [PATCH 5/6] Make sure files with dots in their name work --- host/repush.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/host/repush.sh b/host/repush.sh index f421de7..78b9677 100755 --- a/host/repush.sh +++ b/host/repush.sh @@ -335,7 +335,8 @@ function push { directory="" fi - placeholder_basename="$(basename "$1" ".$extension")" + placeholder_basename="$(basename "$1")" + placeholder_basename_no_ext="$(basename "$1" ".$extension")" # Since the WebUI doesn't accept directories, we're creating a PDF placeholder # fs entry, who's metadata we'll then alter to that of a directory fs entry @@ -357,7 +358,7 @@ function push { # Wait for metadata to be generated while true; do - uuid_of_root_file "$placeholder_basename" + uuid_of_root_file "$placeholder_basename_no_ext" if [ ! -z "$RET_UUID" ]; then break fi From 77d03a23d9062ffcfe67920c5621f2baec1fc0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Rigo?= Date: Fri, 4 Jun 2021 09:59:02 +0200 Subject: [PATCH 6/6] Mute nc --- host/repush.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/repush.sh b/host/repush.sh index 78b9677..9b05bcc 100755 --- a/host/repush.sh +++ b/host/repush.sh @@ -505,7 +505,7 @@ done # Establish remote connection if [ "$REMOTE" ]; then - if nc -z localhost "$PORT" > /dev/null; then + if nc -z localhost "$PORT" 2&>1 > /dev/null; then echo "repush: Port $PORT is already used by a different process!" exit -1 fi