diff options
-rw-r--r-- | lib/keyringer/functions | 27 | ||||
-rwxr-xr-x | share/keyringer/newkeys | 15 | ||||
-rwxr-xr-x | share/keyringer/options | 9 | ||||
-rwxr-xr-x | share/keyringer/recipients | 9 | ||||
-rwxr-xr-x | share/keyringer/recrypt | 1 |
5 files changed, 24 insertions, 37 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions index 96ca7e6..630f519 100644 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -192,16 +192,6 @@ function keyringer_set_env { fi } -# Get a single argument -function keyringer_get_arg { - if [ -z "$1" ]; then - keyringer_action_usage - exit 1 - fi - - echo $1 -} - # Get a file argument function keyringer_get_file { FILE="`keyringer_filename $1`" @@ -222,6 +212,21 @@ function keyringer_action_usage { keyringer_usage_$BASENAME else # Default usage - echo "Usage: keyringer <keyring> $BASENAME <file>" + if [ "$1" == "command" ]; then + echo "Usage: keyringer <keyring> $BASENAME <command> [arguments]" + else + echo "Usage: keyringer <keyring> $BASENAME <file>" + fi + fi +} + +# Get a command argument +function keyringer_get_command { + # Aditional parameters + COMMAND="$1" + + if [ -z "$COMMAND" ]; then + keyringer_action_usage command + exit 1 fi } diff --git a/share/keyringer/newkeys b/share/keyringer/newkeys index c7eb562..eff529e 100755 --- a/share/keyringer/newkeys +++ b/share/keyringer/newkeys @@ -3,14 +3,6 @@ # Create keys for new nodes. # -# Load functions -LIB="`dirname $0`/../../lib/keyringer/functions" -source $LIB -keyringer_set_env $* - -# Aditional parameters -COMMAND="$2" - function newkeys_nodes { # See http://www.mail-archive.com/puppet-users@googlegroups.com/msg01615.html grep ^node $* | sed -e 's/^node //' | awk -F, '{for(i=1;i<=NF;i++) {print $i}}' | cut -d "'" -f2 @@ -45,11 +37,10 @@ function newkeys_puppet { # Load functions LIB="`dirname $0`/../../lib/keyringer" source $LIB/functions +keyringer_set_env $* -if [ -z "$COMMAND" ]; then - echo "Usage: keyringer <keyring> `basename $0` <command> [arguments]" - exit 1 -fi +# Command parser +keyringer_get_command $2 source $OPTIONS keyringer_config_load_preferences diff --git a/share/keyringer/options b/share/keyringer/options index 4fe8092..6708b54 100755 --- a/share/keyringer/options +++ b/share/keyringer/options @@ -8,13 +8,8 @@ LIB="`dirname $0`/../../lib/keyringer" source $LIB/functions keyringer_set_env $* -# Aditional parameters -COMMAND="$2" - -if [ -z "$COMMAND" ]; then - echo "Usage: keyringer <keyring> `basename $0` <command> [arguments]" - exit 1 -fi +# Command parser +keyringer_get_command $2 # Create options file if old repository if [ ! -e "$OPTIONS" ]; then diff --git a/share/keyringer/recipients b/share/keyringer/recipients index 3410b3d..36eefcc 100755 --- a/share/keyringer/recipients +++ b/share/keyringer/recipients @@ -8,13 +8,8 @@ LIB="`dirname $0`/../../lib/keyringer" source $LIB/functions keyringer_set_env $* -# Aditional parameters -COMMAND="$2" - -if [ -z "$COMMAND" ]; then - echo "Usage: keyringer <keyring> `basename $0` <command> [arguments]" - exit 1 -fi +# Command parser +keyringer_get_command $2 if [ "$COMMAND" == "ls" ]; then cat $RECIPIENTS diff --git a/share/keyringer/recrypt b/share/keyringer/recrypt index 92afa99..a45efa1 100755 --- a/share/keyringer/recrypt +++ b/share/keyringer/recrypt @@ -11,4 +11,5 @@ keyringer_set_env $* # Get file keyringer_get_file $2 +# Recrypt gpg --use-agent -d $KEYDIR/$FILE | gpg --use-agent --armor -e -s $(keyringer_recipients $RECIPIENTS) > $KEYDIR/$FILE |