-
Notifications
You must be signed in to change notification settings - Fork 44
/
dns-hostnames
executable file
·74 lines (62 loc) · 2.09 KB
/
dns-hostnames
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
# description: Checks if the api and wildcard DNS entries are correct
[ -z ${UTILSFILE} ] && source $(echo "$(dirname ${0})/../utils")
error=false
BASEDOMAIN=$(yq e '.baseDomain' ${INSTALL_CONFIG_PATH} 2>/dev/null)
if [ -z ${BASEDOMAIN} ]; then
errors=$(("${errors}" + 1))
error=true
msg ".baseDomain not found in ${INSTALL_CONFIG_PATH}"
fi
CLUSTERNAME=$(yq e '.metadata.name' ${INSTALL_CONFIG_PATH} 2>/dev/null)
if [ -z ${CLUSTERNAME} ]; then
errors=$(("${errors}" + 1))
error=true
msg ".metadata.name not found in ${INSTALL_CONFIG_PATH}"
fi
#MASTERS=$(yq e '.platform.baremetal.hosts[] | select(.role == "master") | .name' ${INSTALL_CONFIG_PATH} 2> /dev/null)
#WORKERS=$(yq e '.platform.baremetal.hosts[] | select(.role == "worker") | .name' ${INSTALL_CONFIG_PATH} 2> /dev/null)
# NS1="ns1."${CLUSTERNAME}"."${BASEDOMAIN}
API="api."${CLUSTERNAME}"."${BASEDOMAIN}"."
WILDCARD="foobar.apps."${CLUSTERNAME}"."${BASEDOMAIN}"."
IP_API=$(dig +short ${API})
if [ -z ${IP_API} ]; then
errors=$(("${errors}" + 1))
error=true
msg "${RED}${API} doesn't resolve${NOCOLOR}"
fi
IP_WILDCARD=$(dig +short ${WILDCARD})
if [ -z ${IP_WILDCARD} ]; then
errors=$(("${errors}" + 1))
error=true
msg "${RED}${WILDCARD} doesn't resolve${NOCOLOR}"
fi
IP_API_REVERSE=$(dig +short -x ${IP_API})
if [ -z ${IP_API_REVERSE} ]; then
errors=$(("${errors}" + 1))
error=true
msg "${YELLOW}api reverse not found${NOCOLOR}"
else
if [ ${IP_API_REVERSE} != ${API} ]; then
errors=$(("${errors}" + 1))
error=true
msg "${YELLOW}${API} doesn't match the reverse ${IP_API_REVERSE}${NOCOLOR}"
fi
fi
# Wildcard reverse DNS doesn't seem to be a thing
#IP_WILDCARD_REVERSE=$(dig +short -x ${IP_WILDCARD})
#if [ -z ${IP_WILDCARD_REVERSE} ]; then
# msg "${YELLOW}wildcard reverse not found${NOCOLOR}"
# else
# if [ ${IP_WILDCARD_REVERSE} != ${WILDCARD} ]; then
# msg "${YELLOW}${WILDCARD} doesn't match the reverse ${IP_WILDCARD_REVERSE}${NOCOLOR}"
# fi
#fi
if [ ! -z "${ERRORFILE}" ]; then
echo $errors >${ERRORFILE}
fi
if [[ $error == true ]]; then
exit ${OCERROR}
else
exit ${OCOK}
fi