feature: now rest of pass result is treated as note; check for awk executable before start script
This commit is contained in:
parent
bc623b0a1b
commit
bb5ea43041
2 changed files with 12 additions and 2 deletions
|
@ -6,6 +6,10 @@ This repository contains some scripts that aims to convert a gpg password wallet
|
|||
### convert_to_csv.sh
|
||||
Simply execute the script. You need `pass` executable installed and ENV var PASSWORD_STORE_DIR set-up. A CSV file will be created in this folder containing key-password fields separated by TAB delimiter.
|
||||
|
||||
#### Dependencies
|
||||
|
||||
* Awk
|
||||
|
||||
```bash
|
||||
# Clone this repository
|
||||
$ git clone https://gitlab.com/unitoo/pass-exporter.git
|
||||
|
|
|
@ -7,6 +7,11 @@ if ! hash $PASS_EXECUTABLE 2> /dev/null; then
|
|||
exit
|
||||
fi
|
||||
|
||||
if ! hash awk 2> /dev/null; then
|
||||
echo "Awk executable not found. Exiting."
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "$PASSWORD_STORE_DIR" ]; then
|
||||
echo "PASSWORD_STORE_DIR is empty or invalid. Please follow pass documentation to understand how configure it."
|
||||
exit
|
||||
|
@ -22,7 +27,7 @@ if [[ -f "$FINAL_FILE_NAME" ]]; then
|
|||
exit
|
||||
else
|
||||
touch $FINAL_FILE_NAME
|
||||
echo "Account${DELIMITER}Password${DELIMITER}Login" >> $FINAL_FILE_NAME
|
||||
echo "Account${DELIMITER}Password${DELIMITER}Login${DELIMITER}Rest" >> $FINAL_FILE_NAME
|
||||
fi
|
||||
|
||||
if [[ -f "$FINAL_FILE_NAME" ]]; then
|
||||
|
@ -33,10 +38,11 @@ if [[ -f "$FINAL_FILE_NAME" ]]; then
|
|||
PASSWORD=$($PASS_EXECUTABLE show "$GPG_FILE_NAME" | head -n1)
|
||||
|
||||
LOGIN_KEY=$($PASS_EXECUTABLE show "$GPG_FILE_NAME" | awk 'BEGIN{IGNORECASE=1} /^login:|ID:|email:|user:/ {ORS=" ";for(i=2; i<=NF; i++) print $i; exit;}')
|
||||
REST=$($PASS_EXECUTABLE show "$GPG_FILE_NAME" | awk '(NR>1)')
|
||||
GPG_FILE_NAME=${GPG_FILE_NAME//\// > }
|
||||
|
||||
echo "Processing $GPG_FILE_NAME";
|
||||
echo "$GPG_FILE_NAME$DELIMITER$PASSWORD$DELIMITER$LOGIN_KEY" >> $FINAL_FILE_NAME
|
||||
echo "$GPG_FILE_NAME$DELIMITER$PASSWORD$DELIMITER$LOGIN_KEY$DELIMITER\"$REST\"" >> $FINAL_FILE_NAME
|
||||
}; done;
|
||||
unset f;
|
||||
|
||||
|
|
Loading…
Reference in a new issue