wagon/back/lib/ns_lookup_send

25 lines
606 B
Plaintext
Raw Normal View History

2022-09-06 20:57:41 -06:00
#!/bin/bash
# FILE: wagon:back/lib/ns_lookup_send
2022-09-06 20:57:41 -06:00
# DESCRIPTION: Send nslookup command to DNS master server
2022-10-03 10:45:30 -06:00
# USAGE: send [option] cmd
2022-09-06 20:57:41 -06:00
# ERRORS:
# 3: not found
# 4: server down
# 5: other nslookup error
# 6: nslookup refused
2022-09-06 20:57:41 -06:00
source /etc/wagon/config
2022-09-08 21:15:30 -06:00
# Ignore SC2068 and leave ${@} unquoted so it can expand
2022-10-03 10:45:30 -06:00
if ! res="$(/usr/bin/nslookup ${@} "${DNS_MASTER}")"
then exit 5
2022-09-11 17:13:22 -06:00
fi
2022-09-10 11:00:58 -06:00
if <<<"${res}" grep ';; .* timed out'
2022-09-06 20:57:41 -06:00
then exit 4
elif <<<"${res}" grep "\*\* .*: NXDOMAIN\|\*\*\* .*: No answer"
then exit 3
2022-10-03 10:45:30 -06:00
elif <<<"${res}" grep "\*\* .*: REFUSED"
then exit 6
2022-09-08 21:15:30 -06:00
else printf '%s' "${res}"
2022-09-06 20:57:41 -06:00
fi