aboutsummaryrefslogtreecommitdiff
path: root/tombopen
blob: 9cd492d872165decb586f3120b3e720c1842d623 (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
#/usr/bin/env bash
#
# Open a Tomb.
#

# Parameters
BASENAME="`basename $0`"
TOMB="$1"
TOMBS="$HOME/data/tombs"
KEYS="$HOME/.tombs"

# Check
if [ ! -d "$TOMBS" ]; then
  echo "error: no cemetery available at $TOMBS"
  exit 1
elif [ -z "$TOMB" ]; then
  echo "usage: $BASENAME <tomb>"
  echo "available tombs: `ls $TOMBS | xargs basename -a -s .tomb | xargs echo`"
  exit 1
elif [ ! -e "$KEYS/$TOMB.tomb.key" ]; then
  echo "missing keyfile $KEYS/$TOMB.tomb.key"
  exit 1
fi

# Unnanex
if [ -d "$TOMBS/.git/annex" ] && [ -h "$TOMBS/$TOMB.tomb" ]; then
  ( cd $TOMBS && git annex unlock $TOMB.tomb )
fi

# Dispatch
tomb open $TOMBS/$TOMB.tomb -k $KEYS/$TOMB.tomb.key