fix: fix the inability to write the unpacked file when restoring the folder read-only (fixed #18)
This commit is contained in:
2 files changed
+14
-21
No files matched your search
+1
-1
@@ -7,7 +7,7 @@ DATA_CONFIG="${DATA_DIR}/config.json"
|
|||||||
DATA_ATTACHMENTS="${DATA_DIR}/attachments"
|
DATA_ATTACHMENTS="${DATA_DIR}/attachments"
|
||||||
BACKUP_DIR="/bitwarden/backup"
|
BACKUP_DIR="/bitwarden/backup"
|
||||||
RESTORE_DIR="/bitwarden/restore"
|
RESTORE_DIR="/bitwarden/restore"
|
||||||
RESTORE_EXTRACT_DIR="${RESTORE_DIR}/extract"
|
RESTORE_EXTRACT_DIR="/bitwarden/extract"
|
||||||
|
|
||||||
#################### Function ####################
|
#################### Function ####################
|
||||||
########################################
|
########################################
|
||||||
|
|||||||
+13
-20
@@ -6,6 +6,7 @@ RESTORE_FILE_DB=""
|
|||||||
RESTORE_FILE_CONFIG=""
|
RESTORE_FILE_CONFIG=""
|
||||||
RESTORE_FILE_ATTACHMENTS=""
|
RESTORE_FILE_ATTACHMENTS=""
|
||||||
RESTORE_FILE_ZIP=""
|
RESTORE_FILE_ZIP=""
|
||||||
|
RESTORE_FILE_DIR="${RESTORE_DIR}"
|
||||||
ZIP_PASSWORD=""
|
ZIP_PASSWORD=""
|
||||||
|
|
||||||
function clear_extract_dir() {
|
function clear_extract_dir() {
|
||||||
@@ -33,27 +34,19 @@ function restore_zip() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# get restore db file
|
# get restore db file
|
||||||
RESTORE_FILE_DB=""
|
FIND_FILE_DB="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/db.*.sqlite3) 2>/dev/null" )"
|
||||||
FIND_FILE_DB="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/db.*.sqlite3)" )"
|
RESTORE_FILE_DB="${FIND_FILE_DB:-}"
|
||||||
if [[ -n "${FIND_FILE_DB}" ]]; then
|
|
||||||
RESTORE_FILE_DB="extract/${FIND_FILE_DB}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# get restore config file
|
# get restore config file
|
||||||
RESTORE_FILE_CONFIG=""
|
FIND_FILE_CONFIG="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/config.*.json) 2>/dev/null" )"
|
||||||
FIND_FILE_CONFIG="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/config.*.json)" )"
|
RESTORE_FILE_CONFIG="${FIND_FILE_CONFIG:-}"
|
||||||
if [[ -n "${FIND_FILE_CONFIG}" ]]; then
|
|
||||||
RESTORE_FILE_CONFIG="extract/${FIND_FILE_CONFIG}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# get restore attachments file
|
# get restore attachments file
|
||||||
RESTORE_FILE_ATTACHMENTS=""
|
FIND_FILE_ATTACHMENTS="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/attachments.*.tar) 2>/dev/null" )"
|
||||||
FIND_FILE_ATTACHMENTS="$( basename "$(ls ${RESTORE_EXTRACT_DIR}/attachments.*.tar)" )"
|
RESTORE_FILE_ATTACHMENTS="${FIND_FILE_ATTACHMENTS:-}"
|
||||||
if [[ -n "${FIND_FILE_ATTACHMENTS}" ]]; then
|
|
||||||
RESTORE_FILE_ATTACHMENTS="extract/${FIND_FILE_ATTACHMENTS}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
RESTORE_FILE_ZIP=""
|
RESTORE_FILE_ZIP=""
|
||||||
|
RESTORE_FILE_DIR="${RESTORE_EXTRACT_DIR}"
|
||||||
restore_file
|
restore_file
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +88,7 @@ function restore_attachments() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function check_restore_file_exist() {
|
function check_restore_file_exist() {
|
||||||
if [[ ! -f "${RESTORE_DIR}/$1" ]]; then
|
if [[ ! -f "${RESTORE_FILE_DIR}/$1" ]]; then
|
||||||
color red "$2: cannot access $1: No such file"
|
color red "$2: cannot access $1: No such file"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -105,7 +98,7 @@ function restore_file() {
|
|||||||
if [[ -n "${RESTORE_FILE_ZIP}" ]]; then
|
if [[ -n "${RESTORE_FILE_ZIP}" ]]; then
|
||||||
check_restore_file_exist "${RESTORE_FILE_ZIP}" "--zip-file"
|
check_restore_file_exist "${RESTORE_FILE_ZIP}" "--zip-file"
|
||||||
|
|
||||||
RESTORE_FILE_ZIP="${RESTORE_DIR}/${RESTORE_FILE_ZIP}"
|
RESTORE_FILE_ZIP="${RESTORE_FILE_DIR}/${RESTORE_FILE_ZIP}"
|
||||||
|
|
||||||
clear_extract_dir
|
clear_extract_dir
|
||||||
restore_zip
|
restore_zip
|
||||||
@@ -114,19 +107,19 @@ function restore_file() {
|
|||||||
if [[ -n "${RESTORE_FILE_DB}" ]]; then
|
if [[ -n "${RESTORE_FILE_DB}" ]]; then
|
||||||
check_restore_file_exist "${RESTORE_FILE_DB}" "--db-file"
|
check_restore_file_exist "${RESTORE_FILE_DB}" "--db-file"
|
||||||
|
|
||||||
RESTORE_FILE_DB="${RESTORE_DIR}/${RESTORE_FILE_DB}"
|
RESTORE_FILE_DB="${RESTORE_FILE_DIR}/${RESTORE_FILE_DB}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${RESTORE_FILE_CONFIG}" ]]; then
|
if [[ -n "${RESTORE_FILE_CONFIG}" ]]; then
|
||||||
check_restore_file_exist "${RESTORE_FILE_CONFIG}" "--config-file"
|
check_restore_file_exist "${RESTORE_FILE_CONFIG}" "--config-file"
|
||||||
|
|
||||||
RESTORE_FILE_CONFIG="${RESTORE_DIR}/${RESTORE_FILE_CONFIG}"
|
RESTORE_FILE_CONFIG="${RESTORE_FILE_DIR}/${RESTORE_FILE_CONFIG}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${RESTORE_FILE_ATTACHMENTS}" ]]; then
|
if [[ -n "${RESTORE_FILE_ATTACHMENTS}" ]]; then
|
||||||
check_restore_file_exist "${RESTORE_FILE_ATTACHMENTS}" "--attachments-file"
|
check_restore_file_exist "${RESTORE_FILE_ATTACHMENTS}" "--attachments-file"
|
||||||
|
|
||||||
RESTORE_FILE_ATTACHMENTS="${RESTORE_DIR}/${RESTORE_FILE_ATTACHMENTS}"
|
RESTORE_FILE_ATTACHMENTS="${RESTORE_FILE_DIR}/${RESTORE_FILE_ATTACHMENTS}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${RESTORE_FILE_DB}" ]]; then
|
if [[ -n "${RESTORE_FILE_DB}" ]]; then
|
||||||
|
|||||||
Reference in new issue
Block a user