Skip to content

Commit 4405460

Browse files
committed
verify dns script
1 parent 9baa506 commit 4405460

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

README.md

+5-20
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,13 @@ microk8s status --wait-ready
2929
#
3030
#
3131
MY_EMAIL_ADDRESS="[email protected]" # REPLACE - used for Let's Encrypt
32-
APPSEC_TOKEN=cp-67c2... # REPLACE WITH REAL TOKEN from Infinity Portal - Docker simple MANAGED profile token
32+
# REPLACE WITH REAL TOKEN from Infinity Portal - Docker simple MANAGED profile token
33+
APPSEC_TOKEN=cp-67c2...
3334
APPSEC_HOSTNAME=appsec1493.klaud.online # REPLACE
3435

35-
# prepare DNS
36-
function verifyDns {
37-
sudo resolvectl flush-caches
38-
VMPUBLICIP=$(curl -s ip.iol.cz/ip/)
39-
DNSIP=$(dig +short $APPSEC_HOSTNAME)
40-
echo "Checking that DNS recort for $APPSEC_HOSTNAME points to $VMPUBLICIP"
41-
if [ "$VMPUBLICIP" == "$DNSIP" ]; then
42-
echo "Success: DNS points to this VM."
43-
else
44-
if [ -z "$DNSIP" ]; then
45-
echo "DNS record not defined"
46-
else
47-
echo "DNS record points to ***wrong*** IP: $DNSIP"
48-
fi
49-
echo "Failed: please setup DNS record for $APPSEC_HOSTNAME"
50-
fi
51-
}
52-
# run (and rerun after DNS changes)
53-
verifyDns
36+
# prepare DNS record for the service
37+
# check DNS util properly configured
38+
verify-dns
5439

5540
# ready to install
5641
helm install appsec https://github.com/mkol5222/appsec-chart/releases/download/appsec-0.1.1/appsec-0.1.1.tgz --set cptoken=$APPSEC_TOKEN --set hostname=$APPSEC_HOSTNAME --set letsencrypt.email=$MY_EMAIL_ADDRESS

cloud-init.yml

+19
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,24 @@ write_files:
3131
alias k='kubectl'
3232
alias h='helm'
3333
append: true
34+
- path: /usr/local/bin/verify-dns
35+
content: |
36+
#!/bin/bash
37+
# Verify DNS resolution
38+
sudo resolvectl flush-caches
39+
VMPUBLICIP=$(curl -s ip.iol.cz/ip/)
40+
DNSIP=$(dig +short $APPSEC_HOSTNAME)
41+
echo "Checking that DNS recort for $APPSEC_HOSTNAME points to $VMPUBLICIP"
42+
if [ "$VMPUBLICIP" == "$DNSIP" ]; then
43+
echo "SUCCESS: DNS points to this VM."
44+
else
45+
if [ -z "$DNSIP" ]; then
46+
echo "DNS record not defined. Create: $APPSEC_HOSTNAME IN A $VMPUBLICIP"
47+
else
48+
echo "DNS record points to ***wrong*** IP: $DNSIP, but it should be $VMPUBLICIP"
49+
fi
50+
echo "!!! FAILED !!!: please setup DNS record for $APPSEC_HOSTNAME"
51+
fi
52+
permissions: '0755'
3453

3554
final_message: "The system is finally up, after $UPTIME seconds"

0 commit comments

Comments
 (0)