diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..afed073 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.csv diff --git a/README.md b/README.md index 814f262..b34b019 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ $ ./SCRIPT.sh ## Todo * Create a script to convert into KeePassX format +* Use pass executable only one time and use content +* Write file only at the end of the script ## Credits diff --git a/convert_to_csv.sh b/convert_to_csv.sh index 701169e..a8d34b9 100755 --- a/convert_to_csv.sh +++ b/convert_to_csv.sh @@ -2,7 +2,7 @@ PASS_EXECUTABLE=pass -if ! hash pass 2> /dev/null; then +if ! hash $PASS_EXECUTABLE 2> /dev/null; then echo "Pass executable not found. This script use pass to convert gpg password wallet. Exiting." exit fi @@ -21,7 +21,7 @@ if [[ -f "$FINAL_FILE_NAME" ]]; then exit else touch $FINAL_FILE_NAME - echo "\"Account\";\"Password\"" >> $FINAL_FILE_NAME + echo "\"Account\";\"Password\";\"Login\"" >> $FINAL_FILE_NAME fi if [[ -f "$FINAL_FILE_NAME" ]]; then @@ -29,13 +29,14 @@ if [[ -f "$FINAL_FILE_NAME" ]]; then GPG_FILE_NAME="${f:${#PASSWORD_STORE_DIR}+1}" GPG_FILE_NAME=${GPG_FILE_NAME/\.gpg/} - PASSWORD=$(pass show "$GPG_FILE_NAME" | head -n1) + PASSWORD=$($PASS_EXECUTABLE show "$GPG_FILE_NAME" | head -n1) PASSWORD=${PASSWORD/\"/\\\"} + LOGIN_KEY=$($PASS_EXECUTABLE show "$GPG_FILE_NAME" | awk '/login/ || /ID/ || /email/ {print $2}') GPG_FILE_NAME=${GPG_FILE_NAME//\// > } echo "Processing ${GPG_FILE_NAME}"; - echo "\"$GPG_FILE_NAME\";\"$PASSWORD\"" >> $FINAL_FILE_NAME + echo "\"$GPG_FILE_NAME\";\"$PASSWORD\";\"$LOGIN_KEY\"" >> $FINAL_FILE_NAME }; done; unset f;