small pixel drawing of a pufferfish pa

contrib/pa-pass

#!/bin/sh
#
# migrate passwords from pass to pa
#
# Password dir of pass: export PASSWORD_STORE_DIR=~/.password-store
# Password dir of pa:   export PA_DIR=~/.local/share/pa/passwords

: "${PASSWORD_STORE_DIR:=$HOME/.password-store}"
basedir="${XDG_DATA_HOME:=$HOME/.local/share}/pa"
: "${PA_DIR:=$basedir/passwords}"

# Create pa store if it doesn't exist.
pa list >/dev/null

find "$PASSWORD_STORE_DIR" -name '*.gpg' | while read -r passfile; do
    name="$(printf '%s\n' "${passfile#"$PASSWORD_STORE_DIR/"}" | sed 's/\.gpg$//')"
    mkdir -p "$PA_DIR/$(dirname "$name")"
    gpg2 -d "$passfile" | age -R "$basedir/recipients" -o "$PA_DIR/$name.age"
    printf '%s\n' "Saved '$name' to the store."
done