aur-buildbot/scripts/init-gpg.sh

39 lines
758 B
Bash
Raw Permalink Normal View History

2017-02-19 16:12:46 +02:00
#!/bin/bash
# Go to home directory for sure
pushd $HOME >/dev/null
# Kill gpg-agent
pkill gpg-agent
# Rewrite gpg-agent configuration
cat > ~/.gnupg/gpg-agent.conf <<EOF
keyserver-options auto-key-retrieve
2017-02-19 16:12:46 +02:00
default-cache-ttl 4320000
max-cache-ttl 8640000
allow-loopback-pinentry
EOF
# Start gpg-agent
gpg-agent
# Create dummy file
_dummyfile=`mktemp`
echo "foobar" > "${_dummyfile}"
# Cache password in gpg-agent by signing dummy file
cat ~/passphrase.txt | env -i gpg \
--pinentry-mode loopback --passphrase-fd 0 \
--no-tty --batch --yes \
--detach-sig --output "${_dummyfile}.sig" "${_dummyfile}"
# Verify given signature
env -i gpg --verify \
"${_dummyfile}.sig" "${_dummyfile}"
echo $?
rm "${_dummyfile}" "${_dummyfile}.sig"
popd >/dev/null