diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2010-01-04 19:47:59 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2010-01-04 19:47:59 -0200 |
commit | 6f3ba0425a7d3577f4adde66ee66c2460de8690f (patch) | |
tree | c85fedadc4b350394426329762ef813fbda73213 /lib/keyringer/functions | |
parent | b6115dbdc3c7b77be834a474131c9f68bbdd7487 (diff) | |
download | keyringer-6f3ba0425a7d3577f4adde66ee66c2460de8690f.tar.gz keyringer-6f3ba0425a7d3577f4adde66ee66c2460de8690f.tar.bz2 |
Major design changes
Diffstat (limited to 'lib/keyringer/functions')
-rw-r--r-- | lib/keyringer/functions | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions new file mode 100644 index 0000000..f0c4e0f --- /dev/null +++ b/lib/keyringer/functions @@ -0,0 +1,49 @@ +#!/bin/bash +# +# Common functions. +# + +function keyringer_config { + if [ -z "$CONFIG" ]; then + echo "Your have to set CONFIG variable in the code" + exit 1 + elif [ -e "$CONFIG" ]; then + grep -e "^$1=" $CONFIG | tail -n 1 | cut -d = -f 2 | sed -e 's/"//g' -e "s/'//g" | sed -e 's/ *#.*$//' + else + echo "Config file not found: $CONFIG" + exit 1 + fi +} + +function keyringer_recipients { + grep -v '^#' $1 | grep -v '^$' | awk '{ print "-r " $2 }' | xargs +} + +function keyringer_has_action { + if [ -z "$ACTIONS" ]; then + echo "Your have to set ACTIONS variable in the code" + exit 1 + fi + + if [ -e "$ACTIONS/$1" ]; then + true + else + false + fi +} + +function keyringer_exec { + # Setup + action="$1" + basedir="$2" + shift 2 + + # Dispatch + if keyringer_has_action $action; then + $ACTIONS/$action $basedir $* + fi +} + +function keyringer_filename { + echo `dirname $1`/`basename $1 .gpg`.gpg +} |