0
0
mirror of https://github.com/keepassxreboot/keepassxc.git synced 2024-09-20 04:12:15 +02:00
keepassxc/utils/keepassxc-keychain
Vijay Aravamudhan f7735afcd6
Allow for homebrew prefix location to handle both x64 and arm macs (#8593)
Allow for Homebrew prefix location to handle both x64 and arm macs
2022-10-17 22:21:50 +02:00

30 lines
776 B
Bash
Executable File

#!/usr/bin/env bash
# fetch KeePass database passwords from keychain
### change the path to suit your installation or set KDBX_SEARCH before calling ###
: ${KDBX_SEARCH:=~/.KeePass/*.kdbx}
PROG=$(basename "$0")
KeePassXC=$(ls -f {/usr/local,/opt/homebrew,/Applications}/KeePassXC.app/Contents/MacOS/KeePassXC 2>/dev/null | head -1)
daemon_main() {
declare -A DBs
for DBPATH in $KDBX_SEARCH; do
DBs[$(python -c "import os; print os.path.realpath('$DBPATH')")]=$(security find-generic-password -a $USER -s "${DBPATH##*/}" -w)
done
# launch keepassxc
IFS=$'\n\n\n'
$KeePassXC --pw-stdin "${!DBs[@]}" <<<"${DBs[*]}" &
}
if [[ $1 == '-d' ]]; then
exec >&~/tmp/$PROG.log
set -vx
daemon_main
else
cd /
daemon_main </dev/null >&/dev/null &
disown
fi