aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2010-09-18 13:27:02 -0300
committerSilvio Rhatto <rhatto@riseup.net>2010-09-18 13:27:02 -0300
commitaccf65eda77b9a6c6edffcca825ddbc32e3cc63b (patch)
tree63fe0a881d27208a7f1f16ae2943036bac18ef1f /share
parentf9e575896519e78788b0bb5cd2eb1f1f4840f88a (diff)
downloadkeyringer-accf65eda77b9a6c6edffcca825ddbc32e3cc63b.tar.gz
keyringer-accf65eda77b9a6c6edffcca825ddbc32e3cc63b.tar.bz2
Making code that checks for command argument as a common function
Diffstat (limited to 'share')
-rwxr-xr-xshare/keyringer/newkeys15
-rwxr-xr-xshare/keyringer/options9
-rwxr-xr-xshare/keyringer/recipients9
-rwxr-xr-xshare/keyringer/recrypt1
4 files changed, 8 insertions, 26 deletions
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