diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2024-08-20 20:42:43 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2024-08-20 20:42:43 -0300 |
commit | dbabf8bc8ab1ee358ef50d4b8693abefd8d8de30 (patch) | |
tree | 9145b4ef097d53583a7f0330829fac6af6152ac7 /tomb-create | |
download | utils-tomb-main.tar.gz utils-tomb-main.tar.bz2 |
Initial importmain
Diffstat (limited to 'tomb-create')
-rwxr-xr-x | tomb-create | 47 |
1 files changed, 47 insertions, 0 deletions
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 |