Adde kstore upload
This commit is contained in:
@@ -33,9 +33,11 @@ function kstore {
|
|||||||
update) shift; _kstoreupdate "$@" ;;
|
update) shift; _kstoreupdate "$@" ;;
|
||||||
search) shift; _kstoresearch $@ ;;
|
search) shift; _kstoresearch $@ ;;
|
||||||
secret) shift; _kstoresecret $@ ;;
|
secret) shift; _kstoresecret $@ ;;
|
||||||
|
upload) shift; _kstoreupload $@ ;;
|
||||||
*)
|
*)
|
||||||
__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]"
|
||||||
|
__func_help "upload [DIR]"
|
||||||
__func_help "get [key] [prop, default: $_KSTORE_DEF_PROP]"
|
__func_help "get [key] [prop, default: $_KSTORE_DEF_PROP]"
|
||||||
__func_help "del [key] [prop, default: $_KSTORE_DEF_PROP]"
|
__func_help "del [key] [prop, default: $_KSTORE_DEF_PROP]"
|
||||||
__func_help "list"
|
__func_help "list"
|
||||||
@@ -58,12 +60,15 @@ function _kstore {
|
|||||||
|
|
||||||
case "$SCOPE" in
|
case "$SCOPE" in
|
||||||
kstore)
|
kstore)
|
||||||
COMPREPLY=( $(compgen -W "add del get list query update search secret" -- $CUR) )
|
COMPREPLY=( $(compgen -W "add del get list query update upload search secret" -- $CUR) )
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
get|update)
|
get|update)
|
||||||
COMPREPLY=( $(compgen -W "$( _kstorequery "SELECT DISTINCT key FROM $_KSTORE_TABLE" )" -- $CUR) )
|
COMPREPLY=( $(compgen -W "$( _kstorequery "SELECT DISTINCT key FROM $_KSTORE_TABLE" )" -- $CUR) )
|
||||||
;;
|
;;
|
||||||
|
upload)
|
||||||
|
COMPREPLY=( $(compgen -f -- "$CUR") )
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
t=${COMP_WORDS[COMP_CWORD-2]}
|
t=${COMP_WORDS[COMP_CWORD-2]}
|
||||||
@@ -283,6 +288,42 @@ function _kstoresecret-change {
|
|||||||
_AUTH_SECRET=$_NEW_SECRET
|
_AUTH_SECRET=$_NEW_SECRET
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _kstoreupload {
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
__func_head "[DIR]"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_kstoreinit || return 1
|
||||||
|
|
||||||
|
which arch-upload-aws4 2>&1 > /dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
_kstoreinit-s3au
|
||||||
|
fi
|
||||||
|
|
||||||
|
local _TARGET _FNAME _TEMP
|
||||||
|
|
||||||
|
_TARGET="$1"
|
||||||
|
|
||||||
|
if [ ! -r "$_TARGET" ]; then
|
||||||
|
echo "\"$_TARGET\" is not readable"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
_FNAME=$( basename "$_TARGET" )
|
||||||
|
_TEMP="$( mktemp ).tar.gz"
|
||||||
|
|
||||||
|
tar zcf "$_TEMP" "$_TARGET"
|
||||||
|
_kstoreenc "$_TEMP" > "${_TEMP}.enc"
|
||||||
|
|
||||||
|
echo "Size: $(du -sh "${_TEMP}.enc")"
|
||||||
|
|
||||||
|
arch-upload-aws4 "uploads/$_TARGET.enc" "${_TEMP}.enc"
|
||||||
|
|
||||||
|
rm "${_TEMP}"
|
||||||
|
rm "${_TEMP}.enc"
|
||||||
|
}
|
||||||
|
|
||||||
function _kstoresecret-clear {
|
function _kstoresecret-clear {
|
||||||
unset _AUTH_SECRET
|
unset _AUTH_SECRET
|
||||||
_kstoresecret-auto del
|
_kstoresecret-auto del
|
||||||
|
|||||||
Reference in New Issue
Block a user