forked from Qortal/qortal
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:
parent
70c00a4150
commit
f05cd9ea51
10
tools/qort
10
tools/qort
@ -10,6 +10,8 @@ example_host=node10.qortal.org
|
||||
# called-as name
|
||||
name="${0##*/}"
|
||||
|
||||
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
while [ -n "$*" ]; do
|
||||
case $1 in
|
||||
-p)
|
||||
@ -65,6 +67,12 @@ fi
|
||||
url=$1
|
||||
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
|
||||
base_url=${BASE_URL-localhost:${port}}
|
||||
|
||||
@ -83,5 +91,5 @@ if [ "$#" != 0 ]; then
|
||||
data="--data"
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user