feat: support custom DATA_DIR (fixed #17)

This commit is contained in:
ttionya
2021-03-03 00:02:54 +08:00
parent 5f9035422a
commit b406a37ddf
3 changed files with 65 additions and 12 deletions
+10 -1
View File
@@ -77,8 +77,16 @@ function restore_config() {
function restore_attachments() {
color blue "restore bitwarden_rs attachments"
# When customizing the attachments folder, the root directory of the tar file
# is the directory name at the time of packing
local RESTORE_FILE_ATTACHMENTS_DIRNAME=$(tar -tf "${DATA_ATTACHMENTS}" | head -n 1 | xargs basename)
local DATA_ATTACHMENTS_EXTRACT="${DATA_ATTACHMENTS}.extract"
rm -rf "${DATA_ATTACHMENTS}"
tar -x -C "${DATA_DIR}" -f "${RESTORE_FILE_ATTACHMENTS}"
mkdir "${DATA_ATTACHMENTS_EXTRACT}"
tar -x -C "${DATA_ATTACHMENTS_EXTRACT}" -f "${RESTORE_FILE_ATTACHMENTS}"
mv "${DATA_ATTACHMENTS_EXTRACT}/${RESTORE_FILE_ATTACHMENTS_DIRNAME}" "${DATA_ATTACHMENTS}"
rf -rf "${DATA_ATTACHMENTS_EXTRACT}"
if [[ $? == 0 ]]; then
color green "restore bitwarden_rs attachments successful"
@@ -187,6 +195,7 @@ function restore() {
esac
done
init_env_dir
check_empty_input
check_data_dir_exist