diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2010-09-16 14:23:42 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2010-09-16 14:23:42 -0300 |
commit | a490a1bf3e668674760cdda4e46f2e472fc3460c (patch) | |
tree | 4feb42b5478cff407d37824c6c68f55a121eed7a | |
parent | ae2c26a64065e48bc2f863d9f7648b7a49b072f7 (diff) | |
download | keyringer-a490a1bf3e668674760cdda4e46f2e472fc3460c.tar.gz keyringer-a490a1bf3e668674760cdda4e46f2e472fc3460c.tar.bz2 |
Code cleanup
-rw-r--r-- | lib/keyringer/functions | 15 | ||||
-rwxr-xr-x | share/keyringer/append | 8 | ||||
-rwxr-xr-x | share/keyringer/decrypt | 5 | ||||
-rwxr-xr-x | share/keyringer/del | 6 | ||||
-rwxr-xr-x | share/keyringer/edit | 8 | ||||
-rwxr-xr-x | share/keyringer/encrypt | 8 | ||||
-rwxr-xr-x | share/keyringer/genpair | 7 | ||||
-rwxr-xr-x | share/keyringer/git | 7 | ||||
-rwxr-xr-x | share/keyringer/ls | 8 | ||||
-rwxr-xr-x | share/keyringer/newkeys | 11 | ||||
-rwxr-xr-x | share/keyringer/options | 11 | ||||
-rwxr-xr-x | share/keyringer/recipients | 10 | ||||
-rwxr-xr-x | share/keyringer/recrypt | 7 |
13 files changed, 57 insertions, 54 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions index 22f16f8..7545a52 100644 --- a/lib/keyringer/functions +++ b/lib/keyringer/functions @@ -156,3 +156,18 @@ function keyringer_git_ignore { fi fi } + +# Set needed environment variables. +function keyringer_set_env { + if [ -z "$1" ]; then + echo "Error: missing arguments for keyringer_set_env" + exit 1 + fi + + ACTIONS="`dirname $0`" + BASENAME="`basename $0`" + BASEDIR="$1" + KEYDIR="$BASEDIR/keys" + RECIPIENTS="$BASEDIR/config/recipients" + OPTIONS="$BASEDIR/config/options" +} diff --git a/share/keyringer/append b/share/keyringer/append index 4422e29..2b3eb27 100755 --- a/share/keyringer/append +++ b/share/keyringer/append @@ -6,14 +6,10 @@ # Load functions LIB="`dirname $0`/../../lib/keyringer/functions" source $LIB +keyringer_set_env $* -# Config -ACTIONS="`dirname $0`" -BASEDIR="$1" +# Aditional parameters FILE="`keyringer_filename $2`" -KEYDIR="$BASEDIR/keys" -RECIPIENTS="$BASEDIR/config/recipients" -BASENAME="`basename $0`" if [ -z "$FILE" ]; then echo "Usage: keyringer <keyring> `basename $0` <file>" diff --git a/share/keyringer/decrypt b/share/keyringer/decrypt index ac4e25d..4a3ca8b 100755 --- a/share/keyringer/decrypt +++ b/share/keyringer/decrypt @@ -6,11 +6,10 @@ # Load functions LIB="`dirname $0`/../../lib/keyringer/functions" source $LIB +keyringer_set_env $* -BASEDIR="$1" +# Aditional parameters FILE="`keyringer_filename $2`" -KEYDIR="$BASEDIR/keys" -BASENAME="`basename $0`" if [ -z "$FILE" ]; then echo "Usage: keyringer <keyring> `basename $0` <file>" diff --git a/share/keyringer/del b/share/keyringer/del index e032b7c..c699394 100755 --- a/share/keyringer/del +++ b/share/keyringer/del @@ -6,12 +6,10 @@ # Load functions LIB="`dirname $0`/../../lib/keyringer/functions" source $LIB +keyringer_set_env $* -# Config -BASEDIR="$1" +# Aditional parameters FILE="`keyringer_filename $2`" -KEYDIR="$BASEDIR/keys" -BASENAME="`basename $0`" # Setup if [ -z "$FILE" ]; then diff --git a/share/keyringer/edit b/share/keyringer/edit index b5cc4ae..264c75f 100755 --- a/share/keyringer/edit +++ b/share/keyringer/edit @@ -6,14 +6,10 @@ # Load functions LIB="`dirname $0`/../../lib/keyringer/functions" source $LIB +keyringer_set_env $* -# Config -ACTIONS="`dirname $0`" -BASEDIR="$1" +# Aditional parameters FILE="`keyringer_filename $2`" -KEYDIR="$BASEDIR/keys" -RECIPIENTS="$BASEDIR/config/recipients" -BASENAME="`basename $0`" if [ -z "$FILE" ]; then echo "Usage: keyringer <keyring> `basename $0` <file>" diff --git a/share/keyringer/encrypt b/share/keyringer/encrypt index 396ad4d..d1218ae 100755 --- a/share/keyringer/encrypt +++ b/share/keyringer/encrypt @@ -6,14 +6,10 @@ # Load functions LIB="`dirname $0`/../../lib/keyringer/functions" source $LIB +keyringer_set_env $* -# Config -ACTIONS="`dirname $0`" -BASEDIR="$1" +# Aditional parameters FILE="`keyringer_filename $2`" -KEYDIR="$BASEDIR/keys" -RECIPIENTS="$BASEDIR/config/recipients" -BASENAME="`basename $0`" # Setup if [ -z "$FILE" ]; then diff --git a/share/keyringer/genpair b/share/keyringer/genpair index ee870b1..6de4b4e 100755 --- a/share/keyringer/genpair +++ b/share/keyringer/genpair @@ -113,16 +113,13 @@ function genpair_ssl { # Load functions LIB="`dirname $0`/../../lib/keyringer" source $LIB/functions +keyringer_set_env $* -# Config -ACTIONS="`dirname $0`" -BASEDIR="$1" -KEYDIR="$BASEDIR/keys" +# Aditional parameters KEYTYPE="$2" FILE="$3" NODE="$4" OUTFILE="$5" -BASENAME="`basename $0`" CWD="`pwd`" # Verify diff --git a/share/keyringer/git b/share/keyringer/git index 67d4d0f..76437ac 100755 --- a/share/keyringer/git +++ b/share/keyringer/git @@ -3,7 +3,12 @@ # Git wrapper. # -BASEDIR="$1" +# Load functions +LIB="`dirname $0`/../../lib/keyringer/functions" +source $LIB +keyringer_set_env $* + +# Aditional parameters CWD="`pwd`" if [ -z "$BASEDIR" ]; then diff --git a/share/keyringer/ls b/share/keyringer/ls index 418babb..2a198e8 100755 --- a/share/keyringer/ls +++ b/share/keyringer/ls @@ -3,8 +3,12 @@ # List keys. # -BASEDIR="$1" -KEYDIR="$BASEDIR/keys" +# Load functions +LIB="`dirname $0`/../../lib/keyringer/functions" +source $LIB +keyringer_set_env $* + +# Aditional parameters CWD="`pwd`" if [ -z "$KEYDIR" ]; then diff --git a/share/keyringer/newkeys b/share/keyringer/newkeys index 95b052b..531cf42 100755 --- a/share/keyringer/newkeys +++ b/share/keyringer/newkeys @@ -3,12 +3,13 @@ # Create keys for new nodes. # -# Config -ACTIONS="`dirname $0`" -BASEDIR="$1" +# Load functions +LIB="`dirname $0`/../../lib/keyringer/functions" +source $LIB +keyringer_set_env $* + +# Aditional parameters COMMAND="$2" -BASENAME="`basename $0`" -OPTIONS="$BASEDIR/config/options" function newkeys_nodes { # See http://www.mail-archive.com/puppet-users@googlegroups.com/msg01615.html diff --git a/share/keyringer/options b/share/keyringer/options index 20a9891..4fe8092 100755 --- a/share/keyringer/options +++ b/share/keyringer/options @@ -3,16 +3,13 @@ # Recipient management. # -# Config -ACTIONS="`dirname $0`" -BASEDIR="$1" -COMMAND="$2" -BASENAME="`basename $0`" -OPTIONS="$BASEDIR/config/options" - # Load functions 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]" diff --git a/share/keyringer/recipients b/share/keyringer/recipients index 46eb969..7048211 100755 --- a/share/keyringer/recipients +++ b/share/keyringer/recipients @@ -3,11 +3,13 @@ # Recipient management. # -# Config -BASEDIR="$1" +# Load functions +LIB="`dirname $0`/../../lib/keyringer" +source $LIB/functions +keyringer_set_env $* + +# Aditional parameters COMMAND="$2" -BASENAME="`basename $0`" -RECIPIENTS="$BASEDIR/config/recipients" if [ -z "$COMMAND" ]; then echo "Usage: keyringer <keyring> `basename $0` <command> [arguments]" diff --git a/share/keyringer/recrypt b/share/keyringer/recrypt index cfe3534..f0e15a3 100755 --- a/share/keyringer/recrypt +++ b/share/keyringer/recrypt @@ -6,13 +6,10 @@ # Load functions LIB="`dirname $0`/../../lib/keyringer/functions" source $LIB +keyringer_set_env $* -# Config -BASEDIR="$1" +# Aditional parameters FILE="`keyringer_filename $2`" -KEYDIR="$BASEDIR/keys" -RECIPIENTS="$BASEDIR/config/recipients" -BASENAME="`basename $0`" if [ -z "$FILE" ]; then echo "Usage: keyringer <keyring> `basename $0` <file>" |