25 lines
603 B
Bash
Executable File
25 lines
603 B
Bash
Executable File
#!/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'
|
|
[ ${#} -eq 1 ] || exit 3
|
|
[ -f "${CONFIG_FILE}" ] || exit 7
|
|
[ -x /usr/bin/nslookup ] || exit 6
|
|
source "${CONFIG_FILE}"
|
|
|
|
res="$(/usr/bin/nslookup "${1}" "${DNS_MASTER}")"
|
|
if <<<"${res}" grep ';; connection timed out'
|
|
then exit 5
|
|
elif <<<"${res}" grep "\*\* server can't find "
|
|
then exit 4
|
|
else printf '%s' "${res}"
|
|
fi
|