penguin/utils

my env utils

commit 9a9425b1e4280bbe6ec8f4de66c3cb67356787ee

author斟酌 鵬兄 <tgckpg@gmail.com>
date2024-07-10T23:22:43Z
subjectUse file as a global bool
commit 9a9425b1e4280bbe6ec8f4de66c3cb67356787ee
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2024-07-10T23:22:43Z

    Use file as a global bool
---
 bash/sources/16_keystore | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/bash/sources/16_keystore b/bash/sources/16_keystore
index f8bb249..3d3c223 100644
--- a/bash/sources/16_keystore
+++ b/bash/sources/16_keystore
@@ -15,11 +15,13 @@ fi
 _AUTH_DB=$RBASH_HOME/keystore.db
 _AUTH_SECRET=
 _KSTORE_DEF_PROP=${_KSTORE_DEF_PROP:-val}
+_KSTORE_DEC_FAILED="$RBASH_HOME/.decypt-failed"
 
 if [ -f "$RBASH_HOME/keystore.secret" ]; then
 	_AUTH_SECRET=$( cat "$RBASH_HOME/keystore.secret" )
 fi
 
+
 function kstore {
 	case $1 in
 		add) shift; _kstoreadd "$@" ;;
@@ -130,7 +132,7 @@ function _kstoredec {
 	openssl enc -d -aes-256-cbc -pbkdf2 -k "$_AUTH_SECRET" -a -A
 	_code=$?
 	if [ $_code -ne 0 ]; then
-		_AUTH_SECRET=
+		touch $_KSTORE_DEC_FAILED
 		return $_code
 	fi
 }
@@ -199,6 +201,10 @@ function _kstoresecret-macos {
 
 function _kstoresecret-config {
 	local _CONFIRM
+	if [ -f "$_KSTORE_DEC_FAILED" ]; then
+		rm $_KSTORE_DEC_FAILED
+		_AUTH_SECRET=
+	fi
 	if [ -z "$_AUTH_SECRET" ]; then
 
 		_kstoresecret-auto get