From 6275eb8ee2be8f9250092f775a0085c0561d870a Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Thu, 15 Sep 2022 11:04:17 +0200 Subject: [PATCH] check required jq --- show_ttls.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/show_ttls.sh b/show_ttls.sh index 6fa1125..d24b762 100755 --- a/show_ttls.sh +++ b/show_ttls.sh @@ -6,9 +6,10 @@ # # ---------------------------------------------------------------------- # 2022-09-14 v1.0 <axel.hahn@iml.unibe.ch> initial version +# 2022-09-15 v1.1 <axel.hahn@iml.unibe.ch> check required jq # ====================================================================== -_version="1.0" +_version="1.1" # ---------------------------------------------------------------------- # HELP @@ -22,6 +23,7 @@ Search for hostnames in Infoblox API and show all hosts that have an activated custom ttl value. It uses dns-api.sh and adds the return field for aliases. +The filter functionality of json data requires jq. SYNTAX: dns-search.sh REGEX @@ -41,5 +43,10 @@ mysearch=$1 >&2 echo ";" >&2 echo "; >>>>>>>>>> INFOBLOX DNS HELPER TTL v$_version" >&2 echo ";" + +which jq >/dev/null || exit + "$( dirname $0 )"/dns-api.sh GET "/record:host?name~=${mysearch}&_return_fields%2B=ttl,use_ttl" \ | jq -r '.[] | select ( .use_ttl == true and .ttl != null ) | .name,.ttl' + +# ---------------------------------------------------------------------- \ No newline at end of file -- GitLab