aboutsummaryrefslogtreecommitdiff
path: root/lib/keyringer/actions/recipients
blob: 3c185160566b93fb5429219b047fe3ae575c6cef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
#
# Recipient management.
#

# Load functions
LIB="`dirname $0`/../functions"
source "$LIB" maintenance $* || exit 1

# Command parser
keyringer_get_command "$2"

# Set recipients file
keyringer_set_new_recipients "$3"

# Syntax check and dispatcher
if [ "$COMMAND" == "ls" ]; then
  if [ ! -z "$3" ]; then
    if [ -e "$RECIPIENTS_FILE" ]; then
      cat "$RECIPIENTS_FILE"
    else
      echo "Recipients file not found: $RECIPIENTS_FILE_BASE"
      exit 1
    fi
  else
    for recipients in `ls $RECIPIENTS`; do
      echo "In recipients file $recipients:"
      echo "-----------------------------------------------------------------------------------"
      cat $RECIPIENTS/$recipients
      echo ""
    done
  fi
elif [ "$COMMAND" == "edit" ]; then
  if [ ! -z "$3" ]; then
    keyringer_create_new_recipients $RECIPIENTS_FILE
    $EDITOR "$RECIPIENTS_FILE"
    keyringer_check_recipients
    keyringer_exec git "$BASEDIR" add "$RECIPIENTS_FILE_BASE"
  else
    echo "Please specify one recipient to edit among the available:"
    ls $RECIPIENTS | sed -e 's/^/\t/'
    exit 1
  fi
else
  printf "%s: No such command %s\n" "$BASENAME" "$COMMAND"
  exit 1
fi