forked from Qubinode/qubinode-installer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqubinode_dns_configurator.sh
executable file
·65 lines (57 loc) · 1.67 KB
/
qubinode_dns_configurator.sh
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
#!/bin/bash
# Run Script locally on laptop to connect to OpenShift Cluster
# This script is also used to auto configure to the dns server server your qubinode is currently using.
# Tested on Fedora 30
set -xe
read -p 'Enter IDM Server Endpoint: ' idmserver
read -p 'Enter OpenShift Endpoint: ' openshifturl
function check_openshift() {
OCP_STATUS=$(curl --write-out %{http_code} --silent --output /dev/null "${1}" --insecure)
echo $OCP_STATUS
}
function testidmserver() {
ping -q -c5 $1 > /dev/null
if [ $? -eq 0 ]
then
true
else
false
fi
}
function update_resolv_conf(){
if grep -q ${1} /etc/resolv.conf; then
echo "nameserver ${1} found"
cat /etc/resolv.conf
else
sudo sed -i '/search.*/i\nameserver '${1}'' /etc/resolv.conf
fi
}
function final_check() {
OCP_STATUS=$(check_openshift ${1})
if [[ $OCP_STATUS -ne 200 ]]
then
echo "Updable to access OpenShift. Please Check installation of cluster"
exit 1
else
echo "OpenShift is online. Please open your browser and access it via url."
printf "\nCluster login: ${1}\n"
exit 0
fi
}
if testidmserver ${idmserver}; then
echo "IDM Server has been found"
echo "Checking to see if Openshift is online."
OCP_STATUS=$(check_openshift ${openshifturl})
if [[ $OCP_STATUS -ne 200 ]]
then
echo "Updable to access OpenShift. Please Check installation of cluster"
echo "Updating resolv.conf"
update_resolv_conf ${idmserver}
final_check ${openshifturl}
else
echo "OpenShift is online. Please open your browser and access it via url."
printf "\nCluster login: ${openshifturl}\n"
fi
else
echo "IDM Server has not been found will not configure your machine."
fi