Browse Source

Detect SERVER and set default PORT

tags/v0.2.0
Silke 3 years ago
parent
commit
a7250d3d0f
1 changed files with 16 additions and 0 deletions
  1. +16
    -0
      pdns_api.sh

+ 16
- 0
pdns_api.sh View File

@@ -121,6 +121,11 @@ setup() {
# Header with the api key
headers="X-API-Key: $KEY"

# Default port
if [[ -z "${PORT:-}" ]]; then
PORT="8081"
fi

# Add the host and port to the url
url="http://${HOST}:${PORT}${url}"

@@ -140,6 +145,17 @@ setup() {
url="${url}/api/v${VERSION}"
fi

# Detect the server
if [[ -z "${SERVER:-}" ]]; then
request "GET" "${url}/servers" ""
SERVER=$(<<< "$res" get_json_string_value id)
fi

# Fallback to localhost
if [[ "$SERVER" = "" ]]; then
SERVER="localhost"
fi

# Zone endpoint on the API
url="${url}/servers/${SERVER}/zones"


Loading…
Cancel
Save