aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2021-02-20 09:58:53 -0300
committerSilvio Rhatto <rhatto@riseup.net>2021-02-20 09:58:53 -0300
commitfe8af292595e35c0e01e19a3510500da8f506599 (patch)
treed392393d04c1e360a81fe1cafe13ef68a7ed9dc4
parent70ad3f0be888c8d15f1f4aca899b851f5203cc3b (diff)
downloadscripts-fe8af292595e35c0e01e19a3510500da8f506599.tar.gz
scripts-fe8af292595e35c0e01e19a3510500da8f506599.tar.bz2
Feat: adds tombclose
-rwxr-xr-xtombclose34
-rwxr-xr-xtombopen3
2 files changed, 37 insertions, 0 deletions
diff --git a/tombclose b/tombclose
new file mode 100755
index 0000000..93d35db
--- /dev/null
+++ b/tombclose
@@ -0,0 +1,34 @@
+#/usr/bin/env bash
+#
+# Close 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 "$TOMBS/$TOMB.tomb" ]; then
+ echo "tomb not found: $TOMBS/$TOMB.tomb"
+ exit 1
+#elif ! tomb list $TOMB &> /dev/null; then
+# echo "tomb $TOMB is already closed"
+# exit 1
+fi
+
+# Dispatch
+tomb close $TOMB
+
+# Annex
+if [ -d "$TOMBS/.git/annex" ]; then
+ ( cd $TOMBS && git annex add $TOMB.tomb )
+fi
diff --git a/tombopen b/tombopen
index 9cd492d..506d503 100755
--- a/tombopen
+++ b/tombopen
@@ -17,6 +17,9 @@ elif [ -z "$TOMB" ]; then
echo "usage: $BASENAME <tomb>"
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