renaming m-h update_gpg_pub_file to update_pgp_pub_file
[monkeysphere.git] / src / share / mh / set_expire
1 # -*-shell-script-*-
2 # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
3
4 # Monkeysphere host set-expire subcommand
5 #
6 # This is a function to set the expiration date of the monkeysphere
7 # host key.
8 #
9 # The monkeysphere scripts are written by:
10 # Jameson Rollins <jrollins@finestructure.net>
11 # Jamie McClelland <jm@mayfirst.org>
12 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
13 #
14 # They are Copyright 2008-2010, and are all released under the GPL,
15 # version 3 or later.
16
17 set_expire() {
18
19 local extendBy
20 local keyID
21
22 if [ -z "$1" ] ; then
23     cat <<EOF >&2
24 Must specify expiration.  The possibilities are:
25     0 = key does not expire
26  <n>  = key expires in n days
27  <n>w = key expires in n weeks
28  <n>m = key expires in n months
29  <n>y = key expires in n years
30 EOF
31     failure
32 fi
33 extendBy="$1"
34 shift
35
36 keyID=$(check_key_input "$@")
37
38 if [ "$PROMPT" = "true" ] ; then
39     printf "Are you sure you want to change the expiration on key '$keyID' by '%s'? (Y/n) " "$extendBy" >&2
40     read OK; OK=${OK:-Y}
41     if [ "${OK/y/Y}" != 'Y' ] ; then
42         failure "expiration not set."
43     fi
44 else
45     log debug "extending without prompting."
46 fi
47
48 log info "setting key expiration to ${extendBy}."
49
50 log debug "executing key expire script..."
51 gpg_host_edit "0x${keyID}!" expire <<EOF
52 $extendBy
53 save
54 EOF
55
56 update_pgp_pub_file
57
58 log info <<EOF
59 NOTE: Key expiration date adjusted, but not yet published.
60 Run '$PGRM publish-key' to publish the new expiration date.
61 EOF
62
63 }