aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2021-02-21 17:40:09 -0300
committerSilvio Rhatto <rhatto@riseup.net>2021-02-21 17:40:09 -0300
commita95760dc4b5a4c6985c8babfac05000c7307918f (patch)
tree248942657275bd6dfea1d47a1dce11c6f63a6925
parent635f8de8df667872eab76536e02861171fa63fe4 (diff)
downloadscripts-a95760dc4b5a4c6985c8babfac05000c7307918f.tar.gz
scripts-a95760dc4b5a4c6985c8babfac05000c7307918f.tar.bz2
Feat: adds tomb-create
-rwxr-xr-xtomb-close (renamed from tombclose)4
-rwxr-xr-xtomb-create47
-rwxr-xr-xtomb-open (renamed from tombopen)4
3 files changed, 51 insertions, 4 deletions
diff --git a/tombclose b/tomb-close
index 711af86..3ee08dd 100755
--- a/tombclose
+++ b/tomb-close
@@ -4,10 +4,10 @@
#
# Parameters
-BASENAME="`basename $0`"
-TOMB="$1"
TOMBS="$HOME/data/tombs"
KEYS="$HOME/.tombs"
+BASENAME="`basename $0`"
+TOMB="$1"
# Check
if [ ! -d "$TOMBS" ]; then
diff --git a/tomb-create b/tomb-create
new file mode 100755
index 0000000..aa211c2
--- /dev/null
+++ b/tomb-create
@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+#
+# Create a Tomb.
+#
+
+# Parameters
+TOMBS="$HOME/data/tombs"
+KEYS="$HOME/.tombs"
+BASENAME="`basename $0`"
+TOMB="$1"
+SIZE="$2"
+
+# Check
+if [ ! -d "$TOMBS" ]; then
+ echo "error: no cemetery available at $TOMBS"
+ exit 1
+elif [ -z "$TOMB" ]; then
+ echo "usage: $BASENAME <tomb>"
+ exit 1
+elif [ -e "$TOMBS/$TOMB.tomb" ]; then
+ echo "tomb already exists: $TOMBS/$TOMB.tomb"
+ exit 1
+elif [ ! -e "$KEYS/$TOMB.tomb.key" ]; then
+ echo "missing keyfile $KEYS/$TOMB.tomb.key"
+ exit 1
+fi
+
+# Set
+if [ -z "$SIZE" ]; then
+ SIZE="16"
+fi
+
+# Create password
+keyringer default pwgen tombs/$TOMB.tomb.key.passwd
+
+# Dispatch
+tomb dig $TOMBS/$TOMB.tomb -s $SIZE
+tomb forge $KEYS/$TOMB.tomb.key
+tomb lock $TOMBS/$TOMB.tomb -k $KEYS/$TOMB.tomb.key
+
+# Add key into keyringer
+keyringer default encrypt tombs/$TOMB.tomb.key $KEYS/$TOMB.tomb.key
+
+# Annex
+#if [ -d "$TOMBS/.git/annex" ] && [ -h "$TOMBS/$TOMB.tomb" ]; then
+# ( cd $TOMBS && git annex unlock $TOMB.tomb )
+#fi
diff --git a/tombopen b/tomb-open
index 0de4e81..5154215 100755
--- a/tombopen
+++ b/tomb-open
@@ -4,10 +4,10 @@
#
# Parameters
-BASENAME="`basename $0`"
-TOMB="$1"
TOMBS="$HOME/data/tombs"
KEYS="$HOME/.tombs"
+BASENAME="`basename $0`"
+TOMB="$1"
# Check
if [ ! -d "$TOMBS" ]; then