78 lines
2.0 KiB
Groovy
78 lines
2.0 KiB
Groovy
#!groovy
|
|
|
|
def repository = "registry.c.test-chamber-13.lan"
|
|
def repositoryCreds = "harbor-repository-creds"
|
|
|
|
def connectivity_test = """#! /usr/bin/env bash
|
|
curl --silent --fail --insecure http://localhost:8112 > /dev/null
|
|
if [[ "\${?}" != "0" ]]; then
|
|
printf '%s\\n' "Deluge not running."
|
|
exit 100
|
|
fi
|
|
|
|
if [[ -z "\${DDNS_HOST}" ]] || [[ "\${DDNS_HOST}" == "" ]]; then
|
|
printf '%s\\n' "Dynamic DNS host is not set."
|
|
exit 100
|
|
fi
|
|
|
|
DIP=\$(dig -4 @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
|
|
|
|
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
|
|
|
|
ping -c 2 google.com > /dev/null
|
|
if [[ "\${?}" != "0" ]]; then
|
|
printf '%s\\n' "No internet connectivity."
|
|
exit 100
|
|
fi
|
|
"""
|
|
|
|
def dockerFile = """FROM ${repository}/linuxserver/linuxserver/deluge:amd64-latest
|
|
LABEL maintainer="The_Spider <spider@smoothnet.org>"
|
|
|
|
COPY connectivity_test.sh /root/connectivity_test.sh
|
|
|
|
RUN apt-get update && \\
|
|
apt-get install -y openvpn iputils-ping dnsutils && \\
|
|
apt-get clean && \\
|
|
rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/* && \\
|
|
chmod +x /root/connectivity_test.sh
|
|
"""
|
|
|
|
def label = "kubernetes-${UUID.randomUUID().toString()}"
|
|
def templateName = "pipeline-worker"
|
|
podTemplate(
|
|
label: label,
|
|
name: templateName,
|
|
yaml: functions.podYaml(
|
|
repo: repository,
|
|
templateName: templateName,
|
|
kaniko: true
|
|
)
|
|
) {
|
|
node (label) {
|
|
def workspace = pwd()
|
|
|
|
writeFile(file: workspace + "/connectivity_test.sh", text: connectivity_test)
|
|
|
|
functions.buildContainer(
|
|
repository: repository,
|
|
imageDest: "${repository}/library/deluge:latest",
|
|
dockerFile: dockerFile,
|
|
repoCreds: repositoryCreds,
|
|
)
|
|
}
|
|
}
|