From aa6636e6a5c98801799a4606dd4ba9e0d66f5e41 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 25 May 2020 15:42:34 +0000 Subject: [PATCH] credentials: redefine SEKRIT_DIR Instead of adding a prefix to all keys. --- bin/credentials.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/credentials.sh b/bin/credentials.sh index 9037e32..f79d568 100644 --- a/bin/credentials.sh +++ b/bin/credentials.sh @@ -33,13 +33,13 @@ clip() get_user() { printf user - sekrit cp "services/$1/user" && printf "\n" + sekrit cp "$1/user" && printf "\n" } get_pass() { printf pass - sekrit cp "services/$1/pass" && printf "\n" + sekrit cp "$1/pass" && printf "\n" } get_2fa() @@ -50,7 +50,7 @@ get_2fa() isnic) otpcli_opts="-H sha512 -d 8" ;; esac - sekrit get "services/$1/2fa" | otpcli $otpcli_opts | clip && printf "\n" + sekrit get "$1/2fa" | otpcli $otpcli_opts | clip && printf "\n" } get_service() @@ -61,25 +61,25 @@ get_service() sfa=$4 if [ $user = no ] && [ $pass = no ] && [ $sfa = no ]; then - sekrit has "services/$service/pass" || + sekrit has "$service/pass" || err "unknown service $service" pass=yes - sekrit has "services/$service/user" && user=yes - sekrit has "services/$service/2fa" && sfa=yes + sekrit has "$service/user" && user=yes + sekrit has "$service/2fa" && sfa=yes fi if [ $user = check ]; then - sekrit has "services/$service/user" || + sekrit has "$service/user" || err "service $service has no user" user=yes fi if [ $pass = check ]; then - sekrit has "services/$service/pass" || + sekrit has "$service/pass" || err "service $service has no pass" pass=yes fi if [ $sfa = check ]; then - sekrit has "services/$service/2fa" || + sekrit has "$service/2fa" || err "service $service has no 2fa" sfa=yes fi @@ -109,4 +109,6 @@ shift $((OPTIND - 1)) [ $# -eq 1 ] && [ -n "$1" ] || usage key=$1 -get_service "$key" $user $pass $sfa +: ${SEKRIT_DIR:=~/keep/sekrit/services} +export SEKRIT_DIR +get_account "$key" $user $pass $mfa