[PATCH tlstunnel] contrib: Add acme_dns_command hooks for DigitalOcean and Scaleway
Export this patch
---
contrib/dehydrated/dehydrated-digitalocean.sh | 40 +++++++++++++++++++
contrib/dehydrated/dehydrated-scaleway.sh | 34 ++++++++++++++++
2 files changed, 74 insertions(+)
create mode 100755 contrib/dehydrated/dehydrated-digitalocean.sh
create mode 100755 contrib/dehydrated/dehydrated-scaleway.sh
diff --git a/contrib/dehydrated/dehydrated-digitalocean.sh b/contrib/dehydrated/dehydrated-digitalocean.sh
new file mode 100755
index 0000000..72e82e1
--- /dev/null
+++ b/contrib/dehydrated/dehydrated-digitalocean.sh
@@ -0,0 +1,40 @@
+#!/bin/sh -eu
+
+cmd=$1
+domain=$2
+token=$4
+
+find_zone() {
+ doctl compute domain list --no-header --format Domain | while read name; do
+ if [ "$domain" = "$name" ] || [ "${domain%.$name}" != "$domain" ]; then
+ echo "$name"
+ fi
+ done
+}
+
+zone=$(find_zone)
+if [ -z "$zone" ]; then
+ echo >&2 "Cannot find apprioriate zone for $domain"
+ exit 1
+fi
+
+challenge_domain="_acme-challenge.$domain"
+
+case "$cmd" in
+deploy_challenge)
+ doctl compute domain records create "$zone" --record-name "$challenge_domain." --record-ttl 300 --record-type TXT --record-data "$token"
+ ;;
+clean_challenge)
+ doctl compute domain records list "$zone" --no-header --format ID,Type,Name,Data | while read rec_id rec_type rec_name rec_data; do
+ if [ "$rec_type" = TXT ] && [ "$rec_name.$zone" = "$challenge_domain" ] && [ "$rec_data" = "$token" ]; then
+ echo "Deleting record $rec_id"
+ doctl compute domain records delete --force "$zone" "$rec_id"
+ break
+ fi
+ done
+ ;;
+*)
+ echo >&2 "Unrecognized subcommand"
+ exit 1
+ ;;
+esac
diff --git a/contrib/dehydrated/dehydrated-scaleway.sh b/contrib/dehydrated/dehydrated-scaleway.sh
new file mode 100755
index 0000000..b709743
--- /dev/null
+++ b/contrib/dehydrated/dehydrated-scaleway.sh
@@ -0,0 +1,34 @@
+#!/bin/sh -eu
+
+cmd=$1
+domain=$2
+token=$4
+
+find_zone() {
+ scw dns zone list -o json | jq -r 'map(.domain) | join ("\n")' | while read name; do
+ if [ "$domain" = "$name" ] || [ "${domain%.$name}" != "$domain" ]; then
+ echo "$name"
+ fi
+ done
+}
+
+zone=$(find_zone)
+if [ -z "$zone" ]; then
+ echo >&2 "Cannot find apprioriate zone for $domain"
+ exit 1
+fi
+
+challenge_domain="_acme-challenge.$domain"
+
+case "$cmd" in
+deploy_challenge)
+ scw dns record set "$zone" "name=$challenge_domain." ttl=300 type=TXT "values.0=$token" >/dev/null
+ ;;
+clean_challenge)
+ scw dns record delete "$zone" type=TXT "name=${challenge_domain%.$zone}" 'data="'"$token"'"'
+ ;;
+*)
+ echo >&2 "Unrecognized subcommand"
+ exit 1
+ ;;
+esac
base-commit: 78349a65197b0eaf15604f34b3fa737ee130553b
--
2.46.1
tlstunnel/patches/.build.yml: SUCCESS in 31s
[contrib: Add acme_dns_command hooks for DigitalOcean and Scaleway][0] from [delthas][1]
[0]: https://lists.sr.ht/~emersion/public-inbox/patches/55075
[1]: mailto:delthas@dille.cc
✓ #1329918 SUCCESS tlstunnel/patches/.build.yml https://builds.sr.ht/~emersion/job/1329918