From 41454ff914ffbb5a68716f54470764c10be8f4d9 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Fri, 21 Oct 2022 14:29:09 +0200
Subject: [PATCH] init vars of backup tool

---
 restore.sh | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/restore.sh b/restore.sh
index 99fce00..2ed932e 100755
--- a/restore.sh
+++ b/restore.sh
@@ -22,6 +22,7 @@
 # 2018-08-27  ah,ds  v1.2  fix restore target with a given selection; handle '*' placeholder
 # 2019-06-05  ah,ds  v1.3  add custom cache dir
 # 2021-05-19  ah,ds, v2.0  plugin driven 
+# 2022-10-21  ah     v2.1  init vars
 # ================================================================================
 
 
@@ -225,6 +226,9 @@ function doRestore(){
     enterBackupDir
   fi
 
+  # init vars of the backup tool
+  t_getParamDefault >/dev/null
+
 
 # ----- menu and loop
 
@@ -246,22 +250,26 @@ function doRestore(){
     # echo " C - show file changes"
     # echo " S - search file"
     # echo " V - verify"
-    # echo " B - Bash (Shell)"
     # echo
     echo " R - start restore with $STORAGE_BIN"
     echo
     echo "     restore from         : $STORAGE_TARGETPATH"
     echo "     restore to           : $RESTORE_TARGETPATH"
     echo -n "                            "
-    ls -d $RESTORE_TARGETPATH >/dev/null 2>&1
-    if [ $? -eq 0 ]; then
-      color error
-      echo "WARNING: directory already exists! Backup will fail."
-      color reset
+    if [ -n "$RESTORE_TARGETPATH" ]; then
+      ls -d $RESTORE_TARGETPATH >/dev/null 2>&1
+      if [ $? -eq 0 ]; then
+        color error
+        echo "WARNING: directory already exists! Backup will fail."
+        color reset
+      else
+        echo "OK, it does not exist yet"
+      fi
     else
-      echo "OK, it does not exist yet"
+      echo "(not set)"
     fi
     echo
+    echo " B - Bash (Shell)"
     echo " X - exit"
     echo
 
@@ -291,14 +299,15 @@ function doRestore(){
         read filefilter
         test -z "${filefilter}" || t_restoreDoSearchFile "${filefilter}"
         ;;
-      v|V)
-        verify
-        ;;
+      # v|V)
+      #   t_backupDoVerify
+      #   ;;
       b|B)
         h2 "Shell"
-        echo type exit to return...
-        export PS1="[`basename $0` \u@\h \w]\$ "
-        bash
+        echo "HINT: type exit in the subshell to return to the menu."
+        echo
+        export PS1="RESTIC [`basename $0` \u@\h \w]\$ "
+        bash --noprofile
         ;;
       f|F)
         h2 "Filter restore items"
-- 
GitLab