From e3ada79594ff96fc01b083dea48d10b878e4aeae Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 23 Mar 2025 19:25:52 +0100
Subject: [PATCH] Fix.

---
 testing/scripts/_setup_secrets_user.sh | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/testing/scripts/_setup_secrets_user.sh b/testing/scripts/_setup_secrets_user.sh
index 78ffb5b..deb31c5 100644
--- a/testing/scripts/_setup_secrets_user.sh
+++ b/testing/scripts/_setup_secrets_user.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
 set -e
 cd $(dirname "$0")
 
@@ -30,15 +31,28 @@ echo "\nSetting up ~/.ssh"
 PATH_PUBLIC_KEY="${PATH_PRIVATE_KEY}.pub"
 mkdir -p "${PATH_USER_SSH}"
 cp "${PATH_SECRETS}/${FILENAME_KEY}" "${PATH_PRIVATE_KEY}"
-stty -echo
 while [ ! -s "${PATH_PUBLIC_KEY}" ]; do
+    stty -echo
     set +e
     ssh-keygen -y -f "${PATH_PRIVATE_KEY}" > "${PATH_PUBLIC_KEY}"
     set -e
+    stty echo
 done
 echo ''
-eval $(ssh-agent) && ssh-add
-stty echo
+eval $(ssh-agent)
+while true; do
+    stty -echo
+    set +e
+    ssh-add
+    RESULT=$?
+    set -e
+    stty echo
+    if [ "${RESULT}" = 0 ]; then
+        break
+    elif [ "${RESULT}" != 1 ]; then
+        echo "Aborting due to ssh-add error."
+    fi
+done
 
 echo "\n\nSetting up ~/repos"
 REPOS_SITE_LOGIN="${USERNAME}@${REPOS_SITE_DOMAIN}"
-- 
2.30.2