wagon/back/lib/ns_lookup_send

26 lines
642 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'
[ -f "${CONFIG_FILE}" ] || exit 7
[ "$#" == "1" ] || exit 3
[ -x /usr/bin/nslookup ] || exit 6
source "${CONFIG_FILE}"
res="$(/usr/bin/nslookup ${1} ${DNS_MASTER})"
#printf "${1} ${res}" >>"${LOGFILE}"
if printf "${res}" | grep ';; connection timed out'
then exit 5
elif printf "${res}" | grep "** server can't find "
then exit 4
else
printf "${res}"
fi