]> gitweb.fluxo.info Git - scripts.git/commitdiff
Feat: adds tomb-create
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 21 Feb 2021 20:40:09 +0000 (17:40 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 21 Feb 2021 20:40:09 +0000 (17:40 -0300)
tomb-close [moved from tombclose with 100% similarity]
tomb-create [new file with mode: 0755]
tomb-open [moved from tombopen with 100% similarity]

similarity index 100%
rename from tombclose
rename to tomb-close
index 711af86fd18135b1ae40a880c22f3b41ebddbc60..3ee08ddad36f1a9a99e69fae226f361b9740aab4 100755 (executable)
--- a/tombclose
@@ -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 (executable)
index 0000000..aa211c2
--- /dev/null
@@ -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
similarity index 100%
rename from tombopen
rename to tomb-open
index 0de4e8145a1a8ad1c181a9c90ab5bafcaf2eac8b..5154215beeb66115cd91b39b2e11e4911f196628 100755 (executable)
--- 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