aboutsummaryrefslogtreecommitdiff
path: root/lib/keyringer/functions
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2010-01-04 19:47:59 -0200
committerSilvio Rhatto <rhatto@riseup.net>2010-01-04 19:47:59 -0200
commit6f3ba0425a7d3577f4adde66ee66c2460de8690f (patch)
treec85fedadc4b350394426329762ef813fbda73213 /lib/keyringer/functions
parentb6115dbdc3c7b77be834a474131c9f68bbdd7487 (diff)
downloadkeyringer-6f3ba0425a7d3577f4adde66ee66c2460de8690f.tar.gz
keyringer-6f3ba0425a7d3577f4adde66ee66c2460de8690f.tar.bz2
Major design changes
Diffstat (limited to 'lib/keyringer/functions')
-rw-r--r--lib/keyringer/functions49
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
+}