Use file as a global bool

This commit is contained in:
斟酌 鵬兄 2024-07-11 07:22:43 +08:00
parent ec489a9530
commit 9a9425b1e4

View File

@ -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