commit: 781250ac786ea489e79dcf8f37f42522be8a6b0e
parent 6ecd112962c6a86e5c92ee990b8086071f5ecb61
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sun, 24 May 2020 16:21:12 +0200
pass2secret: Syntax fixes
Diffstat:
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/pass2secret b/pass2secret
@@ -12,32 +12,36 @@ set -e
touch "$SECRET_FILE"
chmod 700 "$SECRET_FILE"
-echo -n "Passphrase: "
-read passphrase
+printf "Passphrase: "
+read -r passphrase
echo
# Create needed directories
cd "$workdir"
-(cd "$PASSWORD_STORE_DIR" && find -type d | grep -v ./.git) | xargs mkdir -p
+(cd "$PASSWORD_STORE_DIR" && find . -type d | grep -v ./.git) | xargs mkdir -p
# Convert each entry
(
cd "$PASSWORD_STORE_DIR"
- find -type f -name '*.gpg' | sed -e 's;\.gpg$;;' -e 's;^./;;'
-) | while read entry
+ find . -type f -name '*.gpg' | sed -e 's;\.gpg$;;' -e 's;^./;;'
+) | while read -r entry
do
- ( pass "$entry" && echo ) > "$SECRET_FILE"
- if [[ ! -f "$workdir/$entry" ]]; then secret write "$entry" <<<"$passphrase"; fi
- if [[ ! -f "$workdir/$entry.oath" ]] && grep "^otpauth" "$SECRET_FILE"; then
- grep "^otpauth" "$SECRET_FILE" | sed \
- -e 's;^otpauth://totp/totp-secret?secret=q;;' \
- -e 's;^;--base32 ;' \
- | secret write "${entry}.oath" <<<"$passphrase"
+ ( pass show "$entry" && echo ) > "$SECRET_FILE"
+ if [ ! -f "$workdir/$entry" ]
+ then echo "$passphrase" | secret write "$entry"
fi
+
+ if [ ! -f "$workdir/$entry.oath" ] && grep "^otpauth" "$SECRET_FILE"
+ then
+ pass show "$entry" | sed \
+ -e 's;^otpauth://totp/totp-secret?secret=q;;' \
+ -e 's;^;--base32 ;' > "$SECRET_FILE"
+
+ echo "$passphrase" | secret write "${entry}.oath"
else
echo "following entry exists, ignoring: $workdir/$entry"
fi
done
-shred -u "$secret_file"
+shred -u "$SECRET_FILE"
cd "$OLDPWD"