wagon/back/lib/ns_lookup_send

25 lines
611 B
Plaintext
Raw Normal View History

2022-09-06 20:57:41 -06:00
#!/bin/bash
# FILE: wgapi:back/lib/ns/lookup/send
# DESCRIPTION: Send nslookup command to DNS master server
# USAGE: send cmd
# ERRORS:
# 3: bad usage
# 4: not found
# 5: server down
# 6: nslookup not found
# 7: config file not found
CONFIG_FILE='/etc/wgapi/config'
2022-09-08 21:15:30 -06:00
[ ${#} -eq 1 ] || exit 3
2022-09-06 20:57:41 -06:00
[ -f "${CONFIG_FILE}" ] || exit 7
[ -x /usr/bin/nslookup ] || exit 6
source "${CONFIG_FILE}"
2022-09-08 21:15:30 -06:00
res="$(/usr/bin/nslookup "${1}" "${DNS_MASTER}")"
2022-09-10 11:00:58 -06:00
if <<<"${res}" grep ';; .* timed out'
2022-09-06 20:57:41 -06:00
then exit 5
2022-09-10 14:51:22 -06:00
elif <<<"${res}" grep "\*\* .*: NXDOMAIN\|\*\*\* .*: No answer"
2022-09-06 20:57:41 -06:00
then exit 4
2022-09-08 21:15:30 -06:00
else printf '%s' "${res}"
2022-09-06 20:57:41 -06:00
fi