diff options
author | Christian Pointner <equinox@ffgraz.net> | 2017-05-30 00:16:55 +0200 |
---|---|---|
committer | Christian Pointner <equinox@ffgraz.net> | 2017-05-30 00:16:55 +0200 |
commit | 8cb754dacac0864f6b112e39fd6e7eaf3a339756 (patch) | |
tree | 623278e2d9f0cdfc7bf9efb0b11dfbca015e8cd0 /gpg/set-vault-pass.sh |
inital commit
Diffstat (limited to 'gpg/set-vault-pass.sh')
-rwxr-xr-x | gpg/set-vault-pass.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gpg/set-vault-pass.sh b/gpg/set-vault-pass.sh new file mode 100755 index 0000000..1fb3426 --- /dev/null +++ b/gpg/set-vault-pass.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +keyids=$("${BASH_SOURCE%/*}/gpg2.sh" --list-keys --with-colons --fast-list-mode 2>/dev/null | awk -F: '/^pub/{printf "%s\n", $5}') +if [ -z "$keyids" ]; then + echo "ERROR: no keys to encrypt to, is the keyring empty?" + exit 1 +fi + +receipients="" +for keyid in $keyids; do + receipients="$receipients -r $keyid" +done + + +"${BASH_SOURCE%/*}/gpg2.sh" --yes --trust-model always --encrypt -a -o "${BASH_SOURCE%/*}/vault-pass.gpg.$$" $receipients +if [ $? -ne 0 ]; then + rm -f "${BASH_SOURCE%/*}/vault-pass.gpg.$$" + exit 1 +fi +mv "${BASH_SOURCE%/*}/vault-pass.gpg.$$" "${BASH_SOURCE%/*}/vault-pass.gpg" |