From dbabf8bc8ab1ee358ef50d4b8693abefd8d8de30 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 20 Aug 2024 20:42:43 -0300 Subject: Initial import --- tomb-open | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tomb-open (limited to 'tomb-open') diff --git a/tomb-open b/tomb-open new file mode 100755 index 0000000..5154215 --- /dev/null +++ b/tomb-open @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Open a Tomb. +# + +# Parameters +TOMBS="$HOME/data/tombs" +KEYS="$HOME/.tombs" +BASENAME="`basename $0`" +TOMB="$1" + +# Check +if [ ! -d "$TOMBS" ]; then + echo "error: no cemetery available at $TOMBS" + exit 1 +elif [ -z "$TOMB" ]; then + echo "usage: $BASENAME " + echo "available tombs: `ls $TOMBS | xargs basename -a -s .tomb | xargs echo`" + exit 1 +elif [ ! -e "$TOMBS/$TOMB.tomb" ]; then + echo "tomb not found: $TOMBS/$TOMB.tomb" + 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 -- cgit v1.2.3