Skip to content

Commit

Permalink
Merge pull request acmesh-official#6117 from qupfer/technitum
Browse files Browse the repository at this point in the history
add dns_api for Technitum dns server
  • Loading branch information
Neilpang authored Nov 28, 2024
2 parents 48ccaa8 + 6d30288 commit fca53a0
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions dnsapi/dns_technitium.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env sh
# shellcheck disable=SC2034
dns_Technitium_info='Technitium DNS Server
Site: https://technitium.com/dns/
Docs: github.com/acmesh-official/acme.sh/wiki/dnsapi2#dns_technitium
Options:
Technitium_Server Server Address
Technitium_Token API Token
Issues:https://github.com/acmesh-official/acme.sh/issues/6116
Author: Henning Reich <acmesh@qupfer.de>
'

dns_technitium_add() {
_info "add txt Record using Technitium"
_Technitium_account
fulldomain=$1
txtvalue=$2
response="$(_get "$Technitium_Server/api/zones/records/add?token=$Technitium_Token&domain=$fulldomain&type=TXT&text=${txtvalue}")"
if _contains "$response" '"status":"ok"'; then
return 0
fi
_err "Could not add txt record."
return 1
}

dns_technitium_rm() {
_info "remove txt record using Technitium"
_Technitium_account
fulldomain=$1
txtvalue=$2
response="$(_get "$Technitium_Server/api/zones/records/delete?token=$Technitium_Token&domain=$fulldomain&type=TXT&text=${txtvalue}")"
if _contains "$response" '"status":"ok"'; then
return 0
fi
_err "Could not remove txt record"
return 1
}

#################### Private functions below ##################################

_Technitium_account() {
Technitium_Server="${Technitium_Server:-$(_readaccountconf_mutable Technitium_Server)}"
Technitium_Token="${Technitium_Token:-$(_readaccountconf_mutable Technitium_Token)}"
if [ -z "$Technitium_Server" ] || [ -z "$Technitium_Token" ]; then
Technitium_Server=""
Technitium_Token=""
_err "You don't specify Technitium Server and Token yet."
_err "Please create your Token and add server address and try again."
return 1
fi

#save the credentials to the account conf file.
_saveaccountconf_mutable Technitium_Server "$Technitium_Server"
_saveaccountconf_mutable Technitium_Token "$Technitium_Token"
}

0 comments on commit fca53a0

Please sign in to comment.