From 34040550ecbd5c2debb981b48fe3f1de2acd7867 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Tue, 11 Mar 2025 18:39:01 +0100
Subject: [PATCH] Fix borg script.

---
 testing/home/desktop/.local/bin/borgplom | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/testing/home/desktop/.local/bin/borgplom b/testing/home/desktop/.local/bin/borgplom
index 95dd580..277fbb3 100755
--- a/testing/home/desktop/.local/bin/borgplom
+++ b/testing/home/desktop/.local/bin/borgplom
@@ -14,6 +14,14 @@ if [ "$1" = "orgpull" ]; then
         fi
         REPO="${NAME_SERVER}:${NAME_REPO}"
         while true; do
+            if [ -z "${BORG_PASSPHRASE}" ]; then
+                stty -echo
+                printf "Borg passphrase: "
+                read passphrase
+                stty echo
+                printf "\n"
+                export BORG_PASSPHRASE="${passphrase}"
+            fi 
             set +e
             ARCHIVES=$(borg list "${REPO}")  # separate step so we may fail early on bad passphrase
             RESULT=$?
@@ -24,12 +32,7 @@ if [ "$1" = "orgpull" ]; then
                 echo "Aborting due to unexpected ${NAME_BORGAPP} error."
                 exit 1
             else
-                stty -echo
-                printf "Borg passphrase: "
-                read passphrase
-                stty echo
-                printf "\n"
-                export BORG_PASSPHRASE="${passphrase}"
+                export BORG_PASSPHRASE=""
             fi
         done
         ARCHIVE=$(echo "${ARCHIVES}" | grep "${NAME_ARCHIVE}" | tail -1 | cut -f1 -d' ')
-- 
2.30.2