Download arch utils

This commit is contained in:
斟酌 鵬兄 2022-08-15 22:32:16 +08:00
parent e7562bf01f
commit 1dce4b450c
2 changed files with 28 additions and 4 deletions

View File

@ -15,6 +15,7 @@ RBASH_REMOTE="https://git.k8s.astropenguin.net"
RBASH_REPO="penguin/utils" RBASH_REPO="penguin/utils"
RBASH_PATH="bash" RBASH_PATH="bash"
RBASH_MERGED="$RBASH_SOURCES/merged" RBASH_MERGED="$RBASH_SOURCES/merged"
RBASH_BIN="$RBASH_HOME/bin"
RHOSTNAME="<HOSTNAME>" RHOSTNAME="<HOSTNAME>"
RDOMAIN="<DOMAIN>" RDOMAIN="<DOMAIN>"
@ -90,13 +91,13 @@ function __download {
which curl 2>&1 > /dev/null which curl 2>&1 > /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
curl -s "$1" curl -s "$1"
return return $?
fi fi
which wget 2>&1 > /dev/null which wget 2>&1 > /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
wget -qO- "$1" wget -qO- "$1"
return return $?
fi fi
} }
@ -115,7 +116,7 @@ function rbash_cache {
} }
_RBASH_LOADED= _RBASH_LOADED=
mkdir -p "$RBASH_SOURCES" mkdir -p "$RBASH_SOURCES" "$RBASH_BIN"
if [ ! -f "$RBASH_SOURCES/merged" ]; then if [ ! -f "$RBASH_SOURCES/merged" ]; then
_RBASH_MERGE_START=1 _RBASH_MERGE_START=1
@ -291,6 +292,7 @@ function r2dissource {
export PS1="This is ${RHOSTNAME}\e[1;3${RCOLOR}m${RDOMAIN}\e[0m: \w\n\$ " export PS1="This is ${RHOSTNAME}\e[1;3${RCOLOR}m${RDOMAIN}\e[0m: \w\n\$ "
export EDITOR=vim export EDITOR=vim
export PATH="$RBASH_BIN:$PATH"
# Source for custom bash env, allows overriding # Source for custom bash env, allows overriding
if [ -f "$RBASH_ENV" ]; then if [ -f "$RBASH_ENV" ]; then

View File

@ -30,7 +30,7 @@ function kstore {
update) shift; kstore-update "$@" ;; update) shift; kstore-update "$@" ;;
search) shift; kstore-search $@ ;; search) shift; kstore-search $@ ;;
secret) shift; kstore-secret $@ ;; secret) shift; kstore-secret $@ ;;
upload) shift; kstore-upload $@ ;; sync) shift; kstore-sync $@ ;;
*) *)
__func_head "add [key] [value|file|-] [prop, default: $_KSTORE_DEF_PROP]" __func_head "add [key] [value|file|-] [prop, default: $_KSTORE_DEF_PROP]"
__func_help "update [key] [value|file|-] [prop, default: $_KSTORE_DEF_PROP]" __func_help "update [key] [value|file|-] [prop, default: $_KSTORE_DEF_PROP]"
@ -289,6 +289,28 @@ function kstore-del {
fi fi
} }
function kstore-dl-s3au {
local p tmp
p="https://git.k8s.astropenguin.net/penguin/s3-arch-utils/raw/branch/master"
which "$1" 2>&1 > /dev/null
if [ $? -ne 0 ]; then
tmp=$( mktemp )
__download "$p/$1" > $tmp
sha256sum $tmp | grep -q "$2"
if [ $? -eq 0 ]; then
mv $tmp "$RBASH_BIN/$1"
chmod +x "$RBASH_BIN/$1"
fi
fi
}
function kstore-sync {
kstore-dl-s3au "arch_download_aws4.sh" "f1c2e9c9de380d8e590f46a0cc0c320c711dcff3d7d34a1a86927e61030ae5b8" || return 1
kstore-dl-s3au "arch_upload_aws4.sh" "ca2229a5a7c98e8f5e692129a50b12457f8acbcb366a987cf3d8101cc4b38667" || return 1
}
function kstore-search { function kstore-search {
local _termk _termp _cond local _termk _termp _cond
_termk=`kstore-quote "$1"` _termk=`kstore-quote "$1"`