From 977ca6a54493fba426a0426a90e34080f5cf4508 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 2 Apr 2024 01:37:21 +0200 Subject: [PATCH] Troubleshooting DNS01 --- Dockerfile | 8 +-- config/bash.sh | 3 +- config/zsh.sh | 1 + deploy/sthome-webhook/Chart.yaml | 4 +- .../sthome-webhook/templates/deployment.yaml | 9 +++- deploy/sthome-webhook/values.yaml | 3 +- sthome/solver_local.go | 51 ++++--------------- version.txt | 6 +-- 8 files changed, 33 insertions(+), 52 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3c777e1..fa00b4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ FROM golang:1.21-alpine3.18 AS build_deps ENV RUNNING_IN_DOCKER true ENV DEBIAN_FRONTEND=noninteractive ENV TZ="Africa/Johannesburg" +ENV WEBROOT=/webroot # Set up ZSH and our preferred terminal environment for containers RUN apk add --no-cache git @@ -35,9 +36,10 @@ RUN apk add --no-cache alpine-conf && \ setup-timezone -z Africa/Johannesburg # chmod 0644 /etc/krb5.conf -#RUN mkdir -p /app -#COPY ./config/updatedns.sh /app -#RUN chmod 0744 /app/updatedns.sh +ENV RUNNING_IN_DOCKER true +ENV DEBIAN_FRONTEND=noninteractive +ENV TZ="Africa/Johannesburg" +ENV WEBROOT=/webroot COPY --from=build /workspace/webhook /usr/local/bin/webhook diff --git a/config/bash.sh b/config/bash.sh index 49c7ec4..ce433bd 100644 --- a/config/bash.sh +++ b/config/bash.sh @@ -26,4 +26,5 @@ alias dnsupd=/acme/updatedns.sh # alias mv='mv -i' export PATH=/root/bin:$PATH:/acme export FRONTEND=noninteractive -export TZ=Africa/Johannesburg \ No newline at end of file +export TZ=Africa/Johannesburg +export WEBROOT=/webroot \ No newline at end of file diff --git a/config/zsh.sh b/config/zsh.sh index bc1379d..6a262d5 100644 --- a/config/zsh.sh +++ b/config/zsh.sh @@ -32,3 +32,4 @@ alias dnsupd=/acme/updatedns.sh # alias mv='mv -i' # alias rm='rm -i' export PATH=/root/bin:$PATH +export WEBROOT=/webroot diff --git a/deploy/sthome-webhook/Chart.yaml b/deploy/sthome-webhook/Chart.yaml index 374e0c0..e4d1791 100644 --- a/deploy/sthome-webhook/Chart.yaml +++ b/deploy/sthome-webhook/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 -appVersion: v0.0.4-alpha.86 +appVersion: v0.0.4-alpha.93 description: Cert-Manager webhook for sthome name: sthome-webhook -version: 0.0.4-alpha.86 +version: 0.0.4-alpha.93 diff --git a/deploy/sthome-webhook/templates/deployment.yaml b/deploy/sthome-webhook/templates/deployment.yaml index 4ec0088..1da4b7f 100644 --- a/deploy/sthome-webhook/templates/deployment.yaml +++ b/deploy/sthome-webhook/templates/deployment.yaml @@ -60,6 +60,9 @@ spec: - name: workdir mountPath: /workdir readOnly: false + - name: webroot + mountPath: /webroot + readOnly: false resources: {{ toYaml .Values.resources | indent 12 }} volumes: @@ -71,8 +74,10 @@ spec: path: {{ .Values.host.scriptdir }} - name: workdir hostPath: - path: {{ .Values.host.workdir}} - + path: {{ .Values.host.workdir }} + - name: webroot + hostPath: + path: {{ .Values.host.webrootdir }} {{- with .Values.nodeSelector }} nodeSelector: diff --git a/deploy/sthome-webhook/values.yaml b/deploy/sthome-webhook/values.yaml index ac11491..4b9a173 100644 --- a/deploy/sthome-webhook/values.yaml +++ b/deploy/sthome-webhook/values.yaml @@ -31,7 +31,7 @@ clusterIssuer: image: repository: stuurmcp/cert-manager-webhook-sthome #repository: wstat.sthome.net:5000/cert-manager-webhook-sthome - tag: 0.0.4-alpha.86 + tag: 0.0.4-alpha.93 #pullPolicy should be IfNotPresent. Set to Always for testing purposes pullPolicy: IfNotPresent @@ -50,6 +50,7 @@ pki: host: workdir: /mnt/stpool1/scripts/acme/cert-manager-webhook-sthome scriptdir: /mnt/stpool1/scripts/acme + webrootdir: /mnt/stpool1/apps/static-web-server secret: accessKey: "" diff --git a/sthome/solver_local.go b/sthome/solver_local.go index b047f59..5cb91c4 100644 --- a/sthome/solver_local.go +++ b/sthome/solver_local.go @@ -13,9 +13,9 @@ import ( ) const ( - providerName = "sthome" - shell = "/bin/bash" - dnsUpdaterScriptCmd = "/acme/updatedns.sh" + providerName = "sthome" + shell = "/bin/bash" + acmeAuthCmd = "/acme/acmeauth.sh" dnsserver_net = "10.0.0.15" dnsserver_lan = "192.168.2.1" @@ -86,31 +86,16 @@ func (loc *LocalDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error // shell command settxtcommand := []string{ shell, - dnsUpdaterScriptCmd, - "-set", - ".net", + acmeAuthCmd, + "set", ch.DNSName, - "TXT", + ch.ResolvedFQDN, ch.Key, - "-v", "-l", localip, - } - unsetcnamecommand := []string{ - shell, - dnsUpdaterScriptCmd, - "-unset", - ".net", - ch.DNSName, - "CNAME", - hostserver_net, "-v", - "-l", - localip, } - success, _ := Execute(shell, unsetcnamecommand) - klog.Infof("Execute unset CNAME returned success: %t", success) - success, _ = Execute(shell, settxtcommand) + success, _ := Execute(shell, settxtcommand) klog.Infof("Execute set TXT returned success: %t", success) return nil } @@ -122,37 +107,23 @@ func (loc *LocalDNSProviderSolver) Present(ch *v1alpha1.ChallengeRequest) error // This is in order to facilitate multiple DNS validations for the same domain // concurrently. func (loc *LocalDNSProviderSolver) CleanUp(ch *v1alpha1.ChallengeRequest) error { + //domainName := extractDomainName(ch.ResolvedZone) // TODO: add code that deletes a record from the DNS provider's console localip := getOutboundIP(dnsserver_net) // shell command unsetxtcommand := []string{ shell, - dnsUpdaterScriptCmd, - "-unset", - ".net", + acmeAuthCmd, + "unset", ch.DNSName, - "TXT", + ch.ResolvedFQDN, ch.Key, - "-v", "-l", localip, - } - setcnamecommand := []string{ - shell, - dnsUpdaterScriptCmd, - "-set", - ".net", - ch.DNSName, - "CNAME", - hostserver_net, "-v", - "-l", - localip, } success, _ := Execute(shell, unsetxtcommand) klog.Infof("Execute unset TXT returned success: %t", success) - success, _ = Execute(shell, setcnamecommand) - klog.Infof("Execute set CNAME returned success: %t", success) return nil } diff --git a/version.txt b/version.txt index c828762..819df63 100644 --- a/version.txt +++ b/version.txt @@ -1,3 +1,3 @@ -0.0.4-alpha.86 -20240331-2359 -86 \ No newline at end of file +0.0.4-alpha.93 +20240401-2346 +93 \ No newline at end of file