From 29ab2c11a33ce96ef2878369061be4b0271453d2 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Fri, 27 Mar 2020 02:59:17 -0600 Subject: [PATCH] derive restorePath abs path Fixes the touch.test removal error and is more robust in commands. --- borghelper.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/borghelper.sh b/borghelper.sh index 7ff4c02..5a73bba 100755 --- a/borghelper.sh +++ b/borghelper.sh @@ -274,6 +274,12 @@ if [ "$restoreOptions" ]; then restoreOptions=${restoreOptions##[[:space:]]}; fi # check/create restore path if [ "$operation" = 'restore' ]; then if [ -d "$restorePath" ]; then + # convert to absolute path + restorePath=$( + cd "$restorePath" || \ + consoleError 5 'Cannot access specified restore directory.'; \ + pwd -P + ) if ! touch "${restorePath}/touch.test" > /dev/null 2>&1; then consoleError 5 'Cannot write to specified restore directory.' fi @@ -281,6 +287,12 @@ if [ "$operation" = 'restore' ]; then if ! mkdir -p "${restorePath}" > /dev/null 2>&1; then consoleError 5 'Cannot create specified restore directory.' else + # convert to absolute path + restorePath=$( + cd "$restorePath" || \ + consoleError 5 'Cannot access specified restore directory.'; \ + pwd -P + ) if ! touch "${restorePath}/touch.test" > /dev/null 2>&1; then consoleError 5 'Cannot write to specified restore directory.' fi @@ -398,6 +410,6 @@ exit 0 # 2: parameter missing/invalid in .borgvars file # 3: could not create/remove borg tmp directory # 4: could not write sample borgvars file (permissions?) -# 5: cannot create/write to restore path or could not remove touch.test file +# 5: cannot access/create/write to restore path or could not remove test file #EOF \ No newline at end of file