Cygwin support for kstore-secret-auto
This commit is contained in:
parent
9221c199ae
commit
811b56705c
@ -107,12 +107,42 @@ function kstore-dec {
|
||||
function kstore-secret-auto {
|
||||
case $OSTYPE in
|
||||
darwin*) kstore-secret-macos "$@" ;;
|
||||
cygwin) kstore-secret-cygwin "$@" ;;
|
||||
*)
|
||||
echo "$OSTYPE is Not supported yet" >&2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function kstore-secret-cygwin {
|
||||
local _A
|
||||
|
||||
which kstorecred 2>/dev/null > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
kstore-dl-kstorecred
|
||||
fi
|
||||
|
||||
case $1 in
|
||||
get)
|
||||
_A=$( kstorecred get )
|
||||
if [ $? -ne 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
_AUTH_SECRET="$_A"
|
||||
;;
|
||||
set)
|
||||
kstorecred set "$_AUTH_SECRET"
|
||||
;;
|
||||
del)
|
||||
kstorecred del
|
||||
;;
|
||||
*)
|
||||
echo "Unknown action: $1" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function kstore-secret-macos {
|
||||
local _A
|
||||
case $1 in
|
||||
@ -136,14 +166,6 @@ function kstore-secret-macos {
|
||||
esac
|
||||
}
|
||||
|
||||
function kstore-secret-windows {
|
||||
# Not impelemented yet
|
||||
if [ "$1" == "get" ]; then
|
||||
return 1
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
function kstore-secret-config {
|
||||
local _CONFIRM
|
||||
if [ -z "$_AUTH_SECRET" ]; then
|
||||
@ -221,12 +243,8 @@ function kstore-secret-change {
|
||||
}
|
||||
|
||||
function kstore-secret-clear {
|
||||
_AUTH_SECRET=
|
||||
case $OSTYPE in
|
||||
darwin*)
|
||||
security delete-generic-password -a default -s rbash-kstore 2>&1 > /dev/null
|
||||
;;
|
||||
esac
|
||||
unset _AUTH_SECRET
|
||||
kstore-secret-auto del
|
||||
}
|
||||
|
||||
function kstore-update {
|
||||
@ -331,6 +349,26 @@ function kstore-dl-s3au {
|
||||
fi
|
||||
}
|
||||
|
||||
function kstore-dl-kstorecred {
|
||||
local p tmp _NAME
|
||||
|
||||
_NAME="kstorecred"
|
||||
p="https://penguins-workspace.s3.ap-southeast-1.astropenguin.net/keystore/kstorecred.exe"
|
||||
_CSUM="031b4474b8eb8deafbb96df73b79f8b654fd3c2209f041fd34cb6f494791bcd4"
|
||||
|
||||
tmp=$( mktemp )
|
||||
__download "$p" > $tmp
|
||||
sha256sum $tmp | grep -q "$_CSUM"
|
||||
if [ $? -eq 0 ]; then
|
||||
mv $tmp "$RBASH_BIN/$_NAME"
|
||||
chmod +x "$RBASH_BIN/$_NAME"
|
||||
echo "> $RBASH_BIN/$_NAME"
|
||||
else
|
||||
echo "$_NAME: Signature mismatch"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function kstore-init-s3au {
|
||||
kstore-dl-s3au "574d106cdced150fa6e04a9437d356d8688035cb2c63a045fa0d4ead8b3ec941" "arch_delete_aws4.sh" || return 1
|
||||
kstore-dl-s3au "ce04b3f90b7d9a2578587c8ff841186810d977545943fb4a8234a6d6e9f7b568" "arch_delete_many_aws4.sh" || return 1
|
||||
@ -367,13 +405,13 @@ function kstore-download-db {
|
||||
|
||||
_DOMAIN="penguins-workspace.s3.ap-southeast-1.astropenguin.net"
|
||||
|
||||
_T=$( curl -s "https://$_DOMAIN/keystore/latest" )
|
||||
_T=$( __download "https://$_DOMAIN/keystore/latest" )
|
||||
if [ $? -ne 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
_TMP=$( mktemp )
|
||||
curl -s "https://$_DOMAIN/keystore/$_T.enc" | kstore-dec > $_TMP
|
||||
__download "https://$_DOMAIN/keystore/$_T.enc" | kstore-dec > $_TMP
|
||||
if [ $? -ne 0 ]; then
|
||||
return 1
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user