Added API key support to qort script

Currently needs to be run from either the qortal directory or the tools directory in order to pick up the API key
This commit is contained in:
CalDescent 2022-01-14 11:45:40 +00:00
parent 70c00a4150
commit f05cd9ea51

View File

@ -10,6 +10,8 @@ example_host=node10.qortal.org
# called-as name # called-as name
name="${0##*/}" name="${0##*/}"
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
while [ -n "$*" ]; do while [ -n "$*" ]; do
case $1 in case $1 in
-p) -p)
@ -65,6 +67,12 @@ fi
url=$1 url=$1
shift shift
if [ -f "apikey.txt" ]; then
apikey=$(cat "apikey.txt")
elif [ -f "${script_dir}/../apikey.txt" ]; then
apikey=$(cat "${script_dir}/../apikey.txt")
fi
if [ "${url:0:4}" != "http" ]; then if [ "${url:0:4}" != "http" ]; then
base_url=${BASE_URL-localhost:${port}} base_url=${BASE_URL-localhost:${port}}
@ -83,5 +91,5 @@ if [ "$#" != 0 ]; then
data="--data" data="--data"
fi fi
curl --silent --insecure --connect-timeout 5 ${content_type:+--header} "${content_type}" ${method} ${src} --url ${url} ${data} "$@" | ${postproc} curl --silent --insecure --connect-timeout 5 -H "X-API-KEY: ${apikey}" ${content_type:+--header} "${content_type}" ${method} ${src} --url ${url} ${data} "$@" | ${postproc}
echo echo