diff --git a/bin/pdns-rr-del.sh b/bin/pdns-rr-del.sh index 6fc358d..979e36f 100755 --- a/bin/pdns-rr-del.sh +++ b/bin/pdns-rr-del.sh @@ -57,7 +57,7 @@ if [[ -z $type ]]; then fi # first query to see if zone already exists -zone_status=$(/usr/bin/curl --silent --output /tmp/$zone --write-out "%{http_code}" -H "X-API-Key: $api_key" "$api_base_url/zones/$zone") +zone_status=$(/usr/bin/curl --silent --output /dev/null --write-out "%{http_code}" -H "X-API-Key: $api_key" "$api_base_url/zones/$zone?rrsets=false") if [[ $zone_status = 200 ]]; then # verified zone exists, delete record @@ -65,7 +65,7 @@ if [[ $zone_status = 200 ]]; then data="{\"rrsets\":[{\"name\":\"$name\",\"type\":\"$type\",\"changetype\":\"DELETE\",\"records\":[]}]}" # delete record(s) - zone_status=$(/usr/bin/curl --silent --request PATCH --output "/tmp/$zone" --write-out "%{http_code}" --header "X-API-Key: $api_key" --data "$data" "$api_base_url/zones/$zone") + zone_status=$(/usr/bin/curl --silent --request PATCH --output /dev/null --write-out "%{http_code}" --header "X-API-Key: $api_key" --data "$data" "$api_base_url/zones/$zone") if [[ $zone_status = 204 ]]; then echo "Success. Record(s) for $zone deleted." @@ -78,5 +78,3 @@ elif [[ $zone_status = 404 ]]; then else echo "Unexpected http response checking for Zone $zone: $zone_status" fi - -rm /tmp/$zone diff --git a/bin/pdns-rr-rep.sh b/bin/pdns-rr-rep.sh index e9e6ac0..53a8aab 100755 --- a/bin/pdns-rr-rep.sh +++ b/bin/pdns-rr-rep.sh @@ -82,7 +82,7 @@ if [[ -z $ttl ]]; then fi # first query to see if zone already exists -zone_status=$(/usr/bin/curl --silent --output /tmp/$zone --write-out "%{http_code}" -H "X-API-Key: $api_key" "$api_base_url/zones/$zone") +zone_status=$(/usr/bin/curl --silent --output /dev/null --write-out "%{http_code}" -H "X-API-Key: $api_key" "$api_base_url/zones/$zone?rrsets=false") if [[ $zone_status = 200 ]]; then # verified zone exists, add record(s) @@ -146,7 +146,7 @@ if [[ $zone_status = 200 ]]; then data="$data}]}" # add record(s) - zone_status=$(/usr/bin/curl --silent --request PATCH --output "/tmp/$zone" --write-out "%{http_code}" --header "X-API-Key: $api_key" --data "$data" "$api_base_url/zones/$zone") + zone_status=$(/usr/bin/curl --silent --request PATCH --output /dev/null --write-out "%{http_code}" --header "X-API-Key: $api_key" --data "$data" "$api_base_url/zones/$zone") if [[ $zone_status = 204 ]]; then echo "Success. Record(s) for $zone created/updated." @@ -161,5 +161,3 @@ elif [[ $zone_status = 404 ]]; then else echo "Unexpected http response checking for Zone $zone: $zone_status" fi - -rm /tmp/$zone diff --git a/bin/pdns-zone-add.sh b/bin/pdns-zone-add.sh index 828d4ec..71d7247 100755 --- a/bin/pdns-zone-add.sh +++ b/bin/pdns-zone-add.sh @@ -32,7 +32,7 @@ if [[ -z $zone ]]; then fi # first query to see if zone already exists -zone_status=$(/usr/bin/curl --silent --output /tmp/$zone.output --write-out "%{http_code}" -H "X-API-Key: $api_key" "$api_base_url/zones/$zone") +zone_status=$(/usr/bin/curl --silent --output /dev/null --write-out "%{http_code}" -H "X-API-Key: $api_key" "$api_base_url/zones/$zone?rrsets=false") if [[ $zone_status = 200 ]]; then echo Zone $zone already exists. @@ -145,7 +145,7 @@ elif [[ $zone_status = 404 ]]; then data="$data]}" # add zone - zone_status=$(/usr/bin/curl --silent --request POST --output "/tmp/$zone.output" --write-out "%{http_code}" --header "X-API-Key: $api_key" --data "$data" "$api_base_url/zones") + zone_status=$(/usr/bin/curl --silent --request POST --output /dev/null --write-out "%{http_code}" --header "X-API-Key: $api_key" --data "$data" "$api_base_url/zones") if [[ $zone_status = 201 ]]; then echo Success. Zone $zone created. @@ -156,5 +156,3 @@ elif [[ $zone_status = 404 ]]; then else echo Unexpected http response checking for Zone $zone: $zone_status fi - -rm /tmp/$zone.output diff --git a/bin/pdns-zone-del.sh b/bin/pdns-zone-del.sh index f6ef122..6fb7980 100755 --- a/bin/pdns-zone-del.sh +++ b/bin/pdns-zone-del.sh @@ -30,9 +30,7 @@ fi if [[ -n $execute ]] || pdns::yesno "Delete $zone now?"; then echo - zone_status=$(/usr/bin/curl --silent --output /tmp/$zone --write-out "%{http_code}" --request DELETE --header "X-API-Key: $api_key" $api_base_url/zones/$zone) - rm /tmp/$zone - + zone_status=$(/usr/bin/curl --silent --output /dev/null --write-out "%{http_code}" --request DELETE --header "X-API-Key: $api_key" $api_base_url/zones/$zone) if [[ $zone_status = 204 ]]; then echo Zone $zone deleted. elif [[ $zone_status = 404 ]]; then diff --git a/bin/pdns-zone-exp.sh b/bin/pdns-zone-exp.sh index fe29f0c..d728c0e 100755 --- a/bin/pdns-zone-exp.sh +++ b/bin/pdns-zone-exp.sh @@ -27,21 +27,20 @@ if [[ -z $zone ]]; then exit fi -TMPDIR=$(mktemp -d -p /tmp) +tmpfile=$(mktemp) # export zone and check http status -zone_status=$(/usr/bin/curl --silent --output "$TMPDIR/$zone" --write-out "%{http_code}" -H "X-API-Key: $api_key" $api_base_url/zones/$zone/export) +zone_status=$(/usr/bin/curl --silent --output "$tmpfile" --write-out "%{http_code}" -H "X-API-Key: $api_key" $api_base_url/zones/$zone/export) if [[ $zone_status = 200 ]]; then # return zone level records - sed -e 's/\t/|/g' $TMPDIR/$zone|column -t -s \| |grep ^$zone. + sed -e 's/\t/|/g' $tmpfile|column -t -s \| |grep ^$zone. # return subdomain records - sed -e 's/\t/|/g' $TMPDIR/$zone|column -t -s \| |grep -v ^$zone. + sed -e 's/\t/|/g' $tmpfile|column -t -s \| |grep -v ^$zone. elif [[ $zone_status = 404 ]]; then echo 404 Not Found, $zone does not exist else echo Unexecpted http response checking for existence of zone $zone: $zone_status fi -rm $TMPDIR/$zone -rmdir $TMPDIR +rm $tmpfile