Move tool scripts into a separate dir

This commit is contained in:
Eike Kettner
2021-01-22 22:32:02 +01:00
parent e6d67c368b
commit 189f202b21
9 changed files with 94 additions and 74 deletions

View File

@ -6,6 +6,10 @@
set -e
CURL_CMD="curl"
JQ_CMD="jq"
BASE_URL="${1:-http://localhost:7880}"
LOGIN_URL="$BASE_URL/api/v1/open/auth/login"
TRIGGER_URL="$BASE_URL/api/v1/sec/collective/previews"
@ -18,11 +22,11 @@ echo -n "Password: "
read -s PASS
echo
auth=$(curl --fail -XPOST --silent --data-binary "{\"account\":\"$USER\", \"password\":\"$PASS\"}" "$LOGIN_URL")
auth=$("$CURL_CMD" --fail -XPOST --silent --data-binary "{\"account\":\"$USER\", \"password\":\"$PASS\"}" "$LOGIN_URL")
if [ "$(echo $auth | jq .success)" == "true" ]; then
if [ "$(echo $auth | $JQ_CMD .success)" == "true" ]; then
echo "Login successful"
auth_token=$(echo $auth | jq -r .token)
auth_token=$(echo $auth | "$JQ_CMD" -r .token)
curl --fail -XPOST -H "X-Docspell-Auth: $auth_token" "$TRIGGER_URL"
else
echo "Login failed."