break out monkeysphere-{host,authentication} subcommands into seperate
[monkeysphere.git] / src / subcommands / ma / remove-certifier
1 #!/usr/bin/env bash
2
3 # Monkeysphere authentication remove-certifier subcommand
4 #
5 # The monkeysphere scripts are written by:
6 # Jameson Rollins <jrollins@fifthhorseman.net>
7 # Jamie McClelland <jm@mayfirst.org>
8 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
9 #
10 # They are Copyright 2008, and are all released under the GPL, version 3
11 # or later.
12
13 # delete a certifiers key from the host keyring
14
15 local keyID
16 local fingerprint
17
18 keyID="$1"
19 if [ -z "$keyID" ] ; then
20     failure "You must specify the key ID of a key to remove."
21 fi
22
23 if gpg_authentication "--no-options --list-options show-uid-validity --keyring ${GNUPGHOME_AUTHENTICATION}/pubring.gpg --list-key 0x${keyID}!" ; then
24     read -p "Really remove above listed identity certifier? (y/N) " OK; OK=${OK:-N}
25     if [ "${OK/y/Y}" != 'Y' ] ; then
26         failure "Identity certifier not removed."
27     fi
28 else
29     failure
30 fi
31
32 # delete the requested key
33 if gpg_authentication "--delete-key --batch --yes 0x${keyID}!" ; then
34     # delete key from host keyring as well
35     gpg_host --delete-key --batch --yes "0x${keyID}!"
36
37     # update the trustdb for the authentication keyring
38     gpg_authentication "--check-trustdb"
39
40     echo
41     echo "Identity certifier removed."
42 else
43     failure "Problem removing identity certifier."
44 fi
45