-
Notifications
You must be signed in to change notification settings - Fork 0
/
usage.sh
29 lines (21 loc) · 813 Bytes
/
usage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
api_host="${DEEPER_API_HOST:-34.34.34.34}"
# Check if all three arguments are provided
if [ $# -ne 2 ]; then
echo "Usage: $0 <username> <password>"
exit 1
fi
# Parse the arguments
username=$1
password=$2
# Run the getToken.sh script and store the output in a variable
token_output=$(/opt/getToken.sh $username $password)
# Extract the Bearer token using grep and cut
bearer_token=$(echo "$token_output" | grep -o '"token":"Bearer[^"]*' | cut -d '"' -f 4)
echo "Token: $bearer_token"
# Build the cURL request command
curl_command="curl -k 'https://$api_host/api/system-info/usage' -X 'GET' -H 'Authorization: $bearer_token' -H 'Content-Type: application/json'"
# Print the cURL command to console
echo "Executing cURL command: $curl_command"
# Execute the cURL command
eval "$curl_command"