adds connectivity test script
This commit is contained in:
parent
2d24dbee08
commit
35ac0be1b5
@ -44,8 +44,51 @@ spec:
|
||||
|
||||
stage('Build Container') {
|
||||
container('kaniko') {
|
||||
def connectivity_test = """
|
||||
#! /usr/bin/env bash
|
||||
if [[ -z "${DDNS_HOST}" ]] || [[ "${DDNS_HOST}" == "" ]]; then
|
||||
printf '%s\n' "Dynamic DNS host is not set."
|
||||
exit 100
|
||||
fi
|
||||
|
||||
printf '%s\n' "Detecting public IP"
|
||||
DIP=$(dig @ns1.google.com TXT o-o.myaddr.l.google.com +short | sed -e 's/"//g')
|
||||
if [[ -z "${DIP+x}" ]] || [[ "${DIP}" == "" ]]; then
|
||||
printf '%s\n' "Unable to detect real-world IP."
|
||||
exit 100
|
||||
fi
|
||||
|
||||
printf '%s\n' "Getting known IP"
|
||||
KIP=$(dig ${DDNS_HOST} +short)
|
||||
if [[ -z "${KIP+x}" ]] || [[ "${KIP}" == "" ]]; then
|
||||
printf '%s\n' "Unable to get known IP."
|
||||
exit 100
|
||||
fi
|
||||
|
||||
if [[ "${DIP}" == "${KIP}" ]]; then
|
||||
printf '%s\n' "VPN is not functional."
|
||||
exit 100
|
||||
fi
|
||||
|
||||
printf '%s\n' "Checking connectivity (1 of 2)"
|
||||
ping -c 2 google.com > /dev/null
|
||||
if [[ "${?}" != "0" ]]; then
|
||||
printf '%s\n' "No internet connectivity."
|
||||
exit 100
|
||||
fi
|
||||
|
||||
printf '%s\n' "Checking connectivity (2 of 2)"
|
||||
curl --silent --fail --insecure https://www.msftncsi.com/ncsi.txt > /dev/null
|
||||
if [[ "${?}" != "0" ]]; then
|
||||
printf '%s\n' "No internet connectivity."
|
||||
exit 100
|
||||
fi
|
||||
"""
|
||||
|
||||
|
||||
def dockerfile = """FROM linuxserver/deluge:amd64-latest
|
||||
COPY connectivity_test.sh /root
|
||||
|
||||
RUN apt-get update && \\
|
||||
apt-get install -y openvpn iputils-ping dnsutils && \\
|
||||
apt-get clean && \\
|
||||
@ -53,6 +96,8 @@ RUN apt-get update && \\
|
||||
"""
|
||||
|
||||
writeFile file: workspace + '/Dockerfile', text: dockerfile
|
||||
writeFile file: workspace + '/connectivity_test.sh', text: connectivity_test
|
||||
sh "chmod +x \"${workspace}/connectivity_test.sh\""
|
||||
sh "/kaniko/executor --context \"${workspace}\" -f \"${workspace}/Dockerfile\" --destination \"${repository}/nhyatt/deluge:latest\""
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user