commit: 5258be221145a6b3a8128766c455234214ff9c99
parent c7c9537232dc11f7c60725f9a29a8e1d877c574b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sun, 24 May 2020 17:29:34 +0200
secret: Add init command
Diffstat:
1 file changed, 14 insertions(+), 0 deletions(-)
diff --git a/secret b/secret
@@ -6,6 +6,16 @@ basepath="$HOME/.secret-storage"
set -e
+secret_init() {
+ set -x
+
+ test -f "${basepath}.pub" -a -f "${basepath}.priv" || reop -G -p "${basepath}.pub" -s "${basepath}.priv"
+ chmod 0400 "${basepath}.pub" "${basepath}.priv"
+
+ test -d "$basepath/.git" || git init "${basepath}"
+ chmod 0700 "$basepath"
+}
+
secret_list() {
( cd "$basepath" && find . -type f -name '*.reop' "$@" | sed -e 's;^./;;' -e 's;.reop$;;') | sort | column
}
@@ -70,6 +80,9 @@ secret_usage() {
secret [command] [command-arguments...]
Replacement to pass(1) based on reop(1)
+secret init
+ Initializes secret keys and git storage repo.
+
secret ls [arguments...]
List the entries. Passes arguments to find(1), ls(1)-style output.
secret tree [arguments...]
@@ -97,6 +110,7 @@ command="$1"
shift || secret_usage "$@"
case "$command" in
+ init) secret_init "$@" ;;
ls) secret_list "$@" ;;
tree) secret_tree "$@" ;;
read) secret_read "$@" ;;