committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 1403 additions and 384 deletions
-
11.travis.yml
-
1Dockerfile
-
61README.md
-
234acme.sh
-
18deploy/cpanel_uapi.sh
-
6deploy/keychain.sh
-
1deploy/vault_cli.sh
-
131dnsapi/README.md
-
55dnsapi/dns_acmedns.sh
-
27dnsapi/dns_azure.sh
-
8dnsapi/dns_cf.sh
-
184dnsapi/dns_da.sh
-
30dnsapi/dns_dgon.sh
-
33dnsapi/dns_dnsimple.sh
-
132dnsapi/dns_freedns.sh
-
12dnsapi/dns_gd.sh
-
19dnsapi/dns_he.sh
-
50dnsapi/dns_inwx.sh
-
4dnsapi/dns_ispconfig.sh
-
107dnsapi/dns_kinghost.sh
-
227dnsapi/dns_loopia.sh
-
73dnsapi/dns_namecom.sh
-
7dnsapi/dns_nsupdate.sh
-
68dnsapi/dns_pdns.sh
-
69dnsapi/dns_tele3.sh
-
6dnsapi/dns_yandex.sh
-
139dnsapi/dns_zilore.sh
@ -0,0 +1,55 @@ |
|||||
|
#!/usr/bin/env sh |
||||
|
# |
||||
|
#Author: Wolfgang Ebner |
||||
|
#Report Bugs here: https://github.com/webner/acme.sh |
||||
|
# |
||||
|
######## Public functions ##################### |
||||
|
|
||||
|
#Usage: dns_acmedns_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" |
||||
|
dns_acmedns_add() { |
||||
|
fulldomain=$1 |
||||
|
txtvalue=$2 |
||||
|
_info "Using acme-dns" |
||||
|
_debug fulldomain "$fulldomain" |
||||
|
_debug txtvalue "$txtvalue" |
||||
|
|
||||
|
ACMEDNS_UPDATE_URL="${ACMEDNS_UPDATE_URL:-$(_readaccountconf_mutable ACMEDNS_UPDATE_URL)}" |
||||
|
ACMEDNS_USERNAME="${ACMEDNS_USERNAME:-$(_readaccountconf_mutable ACMEDNS_USERNAME)}" |
||||
|
ACMEDNS_PASSWORD="${ACMEDNS_PASSWORD:-$(_readaccountconf_mutable ACMEDNS_PASSWORD)}" |
||||
|
ACMEDNS_SUBDOMAIN="${ACMEDNS_SUBDOMAIN:-$(_readaccountconf_mutable ACMEDNS_SUBDOMAIN)}" |
||||
|
|
||||
|
if [ "$ACMEDNS_UPDATE_URL" = "" ]; then |
||||
|
ACMEDNS_UPDATE_URL="https://auth.acme-dns.io/update" |
||||
|
fi |
||||
|
|
||||
|
_saveaccountconf_mutable ACMEDNS_UPDATE_URL "$ACMEDNS_UPDATE_URL" |
||||
|
_saveaccountconf_mutable ACMEDNS_USERNAME "$ACMEDNS_USERNAME" |
||||
|
_saveaccountconf_mutable ACMEDNS_PASSWORD "$ACMEDNS_PASSWORD" |
||||
|
_saveaccountconf_mutable ACMEDNS_SUBDOMAIN "$ACMEDNS_SUBDOMAIN" |
||||
|
|
||||
|
export _H1="X-Api-User: $ACMEDNS_USERNAME" |
||||
|
export _H2="X-Api-Key: $ACMEDNS_PASSWORD" |
||||
|
data="{\"subdomain\":\"$ACMEDNS_SUBDOMAIN\", \"txt\": \"$txtvalue\"}" |
||||
|
|
||||
|
_debug data "$data" |
||||
|
response="$(_post "$data" "$ACMEDNS_UPDATE_URL" "" "POST")" |
||||
|
_debug response "$response" |
||||
|
|
||||
|
if ! echo "$response" | grep "\"$txtvalue\"" >/dev/null; then |
||||
|
_err "invalid response of acme-dns" |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
} |
||||
|
|
||||
|
#Usage: fulldomain txtvalue |
||||
|
#Remove the txt record after validation. |
||||
|
dns_acmedns_rm() { |
||||
|
fulldomain=$1 |
||||
|
txtvalue=$2 |
||||
|
_info "Using acme-dns" |
||||
|
_debug fulldomain "$fulldomain" |
||||
|
_debug txtvalue "$txtvalue" |
||||
|
} |
||||
|
|
||||
|
#################### Private functions below ################################## |
||||
@ -0,0 +1,184 @@ |
|||||
|
#!/usr/bin/env sh |
||||
|
# -*- mode: sh; tab-width: 2; indent-tabs-mode: s; coding: utf-8 -*- |
||||
|
# vim: et ts=2 sw=2 |
||||
|
# |
||||
|
# DirectAdmin 1.41.0 API |
||||
|
# The DirectAdmin interface has it's own Let's encrypt functionality, but this |
||||
|
# script can be used to generate certificates for names which are not hosted on |
||||
|
# DirectAdmin |
||||
|
# |
||||
|
# User must provide login data and URL to DirectAdmin incl. port. |
||||
|
# You can create login key, by using the Login Keys function |
||||
|
# ( https://da.example.com:8443/CMD_LOGIN_KEYS ), which only has access to |
||||
|
# - CMD_API_DNS_CONTROL |
||||
|
# - CMD_API_SHOW_DOMAINS |
||||
|
# |
||||
|
# See also https://www.directadmin.com/api.php and |
||||
|
# https://www.directadmin.com/features.php?id=1298 |
||||
|
# |
||||
|
# Report bugs to https://github.com/TigerP/acme.sh/issues |
||||
|
# |
||||
|
# Values to export: |
||||
|
# export DA_Api="https://remoteUser:remotePassword@da.example.com:8443" |
||||
|
# export DA_Api_Insecure=1 |
||||
|
# |
||||
|
# Set DA_Api_Insecure to 1 for insecure and 0 for secure -> difference is |
||||
|
# whether ssl cert is checked for validity (0) or whether it is just accepted |
||||
|
# (1) |
||||
|
# |
||||
|
######## Public functions ##################### |
||||
|
|
||||
|
# Usage: dns_myapi_add _acme-challenge.www.example.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" |
||||
|
# Used to add txt record |
||||
|
dns_da_add() { |
||||
|
fulldomain="${1}" |
||||
|
txtvalue="${2}" |
||||
|
_debug "Calling: dns_da_add() '${fulldomain}' '${txtvalue}'" |
||||
|
_DA_credentials && _DA_getDomainInfo && _DA_addTxt |
||||
|
} |
||||
|
|
||||
|
# Usage: dns_da_rm _acme-challenge.www.example.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" |
||||
|
# Used to remove the txt record after validation |
||||
|
dns_da_rm() { |
||||
|
fulldomain="${1}" |
||||
|
txtvalue="${2}" |
||||
|
_debug "Calling: dns_da_rm() '${fulldomain}' '${txtvalue}'" |
||||
|
_DA_credentials && _DA_getDomainInfo && _DA_rmTxt |
||||
|
} |
||||
|
|
||||
|
#################### Private functions below ################################## |
||||
|
# Usage: _DA_credentials |
||||
|
# It will check if the needed settings are available |
||||
|
_DA_credentials() { |
||||
|
DA_Api="${DA_Api:-$(_readaccountconf_mutable DA_Api)}" |
||||
|
DA_Api_Insecure="${DA_Api_Insecure:-$(_readaccountconf_mutable DA_Api_Insecure)}" |
||||
|
if [ -z "${DA_Api}" ] || [ -z "${DA_Api_Insecure}" ]; then |
||||
|
DA_Api="" |
||||
|
DA_Api_Insecure="" |
||||
|
_err "You haven't specified the DirectAdmin Login data, URL and whether you want check the DirectAdmin SSL cert. Please try again." |
||||
|
return 1 |
||||
|
else |
||||
|
_saveaccountconf_mutable DA_Api "${DA_Api}" |
||||
|
_saveaccountconf_mutable DA_Api_Insecure "${DA_Api_Insecure}" |
||||
|
# Set whether curl should use secure or insecure mode |
||||
|
export HTTPS_INSECURE="${DA_Api_Insecure}" |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
# Usage: _get_root _acme-challenge.www.example.com |
||||
|
# Split the full domain to a domain and subdomain |
||||
|
#returns |
||||
|
# _sub_domain=_acme-challenge.www |
||||
|
# _domain=example.com |
||||
|
_get_root() { |
||||
|
domain=$1 |
||||
|
i=2 |
||||
|
p=1 |
||||
|
# Get a list of all the domains |
||||
|
# response will contain "list[]=example.com&list[]=example.org" |
||||
|
_da_api CMD_API_SHOW_DOMAINS "" "${domain}" |
||||
|
while true; do |
||||
|
h=$(printf "%s" "$domain" | cut -d . -f $i-100) |
||||
|
_debug h "$h" |
||||
|
if [ -z "$h" ]; then |
||||
|
# not valid |
||||
|
_debug "The given domain $h is not valid" |
||||
|
return 1 |
||||
|
fi |
||||
|
if _contains "$response" "$h" >/dev/null; then |
||||
|
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) |
||||
|
_domain=$h |
||||
|
return 0 |
||||
|
fi |
||||
|
p=$i |
||||
|
i=$(_math "$i" + 1) |
||||
|
done |
||||
|
_debug "Stop on 100" |
||||
|
return 1 |
||||
|
} |
||||
|
|
||||
|
# Usage: _da_api CMD_API_* data example.com |
||||
|
# Use the DirectAdmin API and check the result |
||||
|
# returns |
||||
|
# response="error=0&text=Result text&details=" |
||||
|
_da_api() { |
||||
|
cmd=$1 |
||||
|
data=$2 |
||||
|
domain=$3 |
||||
|
_debug "$domain; $data" |
||||
|
response="$(_post "$data" "$DA_Api/$cmd" "" "POST")" |
||||
|
|
||||
|
if [ "$?" != "0" ]; then |
||||
|
_err "error $cmd" |
||||
|
return 1 |
||||
|
fi |
||||
|
_debug response "$response" |
||||
|
|
||||
|
case "${cmd}" in |
||||
|
CMD_API_DNS_CONTROL) |
||||
|
# Parse the result in general |
||||
|
# error=0&text=Records Deleted&details= |
||||
|
# error=1&text=Cannot View Dns Record&details=No domain provided |
||||
|
err_field="$(_getfield "$response" 1 '&')" |
||||
|
txt_field="$(_getfield "$response" 2 '&')" |
||||
|
details_field="$(_getfield "$response" 3 '&')" |
||||
|
error="$(_getfield "$err_field" 2 '=')" |
||||
|
text="$(_getfield "$txt_field" 2 '=')" |
||||
|
details="$(_getfield "$details_field" 2 '=')" |
||||
|
_debug "error: ${error}, text: ${text}, details: ${details}" |
||||
|
if [ "$error" != "0" ]; then |
||||
|
_err "error $response" |
||||
|
return 1 |
||||
|
fi |
||||
|
;; |
||||
|
CMD_API_SHOW_DOMAINS) ;; |
||||
|
esac |
||||
|
return 0 |
||||
|
} |
||||
|
|
||||
|
# Usage: _DA_getDomainInfo |
||||
|
# Get the root zone if possible |
||||
|
_DA_getDomainInfo() { |
||||
|
_debug "First detect the root zone" |
||||
|
if ! _get_root "$fulldomain"; then |
||||
|
_err "invalid domain" |
||||
|
return 1 |
||||
|
else |
||||
|
_debug "The root domain: $_domain" |
||||
|
_debug "The sub domain: $_sub_domain" |
||||
|
fi |
||||
|
return 0 |
||||
|
} |
||||
|
|
||||
|
# Usage: _DA_addTxt |
||||
|
# Use the API to add a record |
||||
|
_DA_addTxt() { |
||||
|
curData="domain=${_domain}&action=add&type=TXT&name=${_sub_domain}&value=\"${txtvalue}\"" |
||||
|
_debug "Calling _DA_addTxt: '${curData}' '${DA_Api}/CMD_API_DNS_CONTROL'" |
||||
|
_da_api CMD_API_DNS_CONTROL "${curData}" "${_domain}" |
||||
|
_debug "Result of _DA_addTxt: '$response'" |
||||
|
if _contains "${response}" 'error=0'; then |
||||
|
_debug "Add TXT succeeded" |
||||
|
return 0 |
||||
|
fi |
||||
|
_debug "Add TXT failed" |
||||
|
return 1 |
||||
|
} |
||||
|
|
||||
|
# Usage: _DA_rmTxt |
||||
|
# Use the API to remove a record |
||||
|
_DA_rmTxt() { |
||||
|
curData="domain=${_domain}&action=select&txtrecs0=name=${_sub_domain}&value=\"${txtvalue}\"" |
||||
|
_debug "Calling _DA_rmTxt: '${curData}' '${DA_Api}/CMD_API_DNS_CONTROL'" |
||||
|
if _da_api CMD_API_DNS_CONTROL "${curData}" "${_domain}"; then |
||||
|
_debug "Result of _DA_rmTxt: '$response'" |
||||
|
else |
||||
|
_err "Result of _DA_rmTxt: '$response'" |
||||
|
fi |
||||
|
if _contains "${response}" 'error=0'; then |
||||
|
_debug "RM TXT succeeded" |
||||
|
return 0 |
||||
|
fi |
||||
|
_debug "RM TXT failed" |
||||
|
return 1 |
||||
|
} |
||||
@ -0,0 +1,107 @@ |
|||||
|
#!/usr/bin/env sh |
||||
|
|
||||
|
############################################################ |
||||
|
# KingHost API support # |
||||
|
# http://api.kinghost.net/doc/ # |
||||
|
# # |
||||
|
# Author: Felipe Keller Braz <felipebraz@kinghost.com.br> # |
||||
|
# Report Bugs here: https://github.com/kinghost/acme.sh # |
||||
|
# # |
||||
|
# Values to export: # |
||||
|
# export KINGHOST_Username="email@provider.com" # |
||||
|
# export KINGHOST_Password="xxxxxxxxxx" # |
||||
|
############################################################ |
||||
|
|
||||
|
KING_Api="https://api.kinghost.net/acme" |
||||
|
|
||||
|
# Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" |
||||
|
# Used to add txt record |
||||
|
dns_kinghost_add() { |
||||
|
fulldomain=$1 |
||||
|
txtvalue=$2 |
||||
|
|
||||
|
KINGHOST_Username="${KINGHOST_Username:-$(_readaccountconf_mutable KINGHOST_Username)}" |
||||
|
KINGHOST_Password="${KINGHOST_Password:-$(_readaccountconf_mutable KINGHOST_Password)}" |
||||
|
if [ -z "$KINGHOST_Username" ] || [ -z "$KINGHOST_Password" ]; then |
||||
|
KINGHOST_Username="" |
||||
|
KINGHOST_Password="" |
||||
|
_err "You don't specify KingHost api password and email yet." |
||||
|
_err "Please create you key and try again." |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
#save the credentials to the account conf file. |
||||
|
_saveaccountconf_mutable KINGHOST_Username "$KINGHOST_Username" |
||||
|
_saveaccountconf_mutable KINGHOST_Password "$KINGHOST_Password" |
||||
|
|
||||
|
_debug "Getting txt records" |
||||
|
_kinghost_rest GET "dns" "name=$fulldomain&content=$txtvalue" |
||||
|
|
||||
|
#This API call returns "status":"ok" if dns record does not exists |
||||
|
#We are creating a new txt record here, so we expect the "ok" status |
||||
|
if ! echo "$response" | grep '"status":"ok"' >/dev/null; then |
||||
|
_err "Error" |
||||
|
_err "$response" |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
_kinghost_rest POST "dns" "name=$fulldomain&content=$txtvalue" |
||||
|
if ! echo "$response" | grep '"status":"ok"' >/dev/null; then |
||||
|
_err "Error" |
||||
|
_err "$response" |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
return 0 |
||||
|
} |
||||
|
|
||||
|
# Usage: fulldomain txtvalue |
||||
|
# Used to remove the txt record after validation |
||||
|
dns_kinghost_rm() { |
||||
|
fulldomain=$1 |
||||
|
txtvalue=$2 |
||||
|
|
||||
|
KINGHOST_Password="${KINGHOST_Password:-$(_readaccountconf_mutable KINGHOST_Password)}" |
||||
|
KINGHOST_Username="${KINGHOST_Username:-$(_readaccountconf_mutable KINGHOST_Username)}" |
||||
|
if [ -z "$KINGHOST_Password" ] || [ -z "$KINGHOST_Username" ]; then |
||||
|
KINGHOST_Password="" |
||||
|
KINGHOST_Username="" |
||||
|
_err "You don't specify KingHost api key and email yet." |
||||
|
_err "Please create you key and try again." |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
_kinghost_rest DELETE "dns" "name=$fulldomain&content=$txtvalue" |
||||
|
if ! echo "$response" | grep '"status":"ok"' >/dev/null; then |
||||
|
_err "Error" |
||||
|
_err "$response" |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
return 0 |
||||
|
} |
||||
|
|
||||
|
#################### Private functions below ################################## |
||||
|
_kinghost_rest() { |
||||
|
method=$1 |
||||
|
uri="$2" |
||||
|
data="$3" |
||||
|
_debug "$uri" |
||||
|
|
||||
|
export _H1="X-Auth-Email: $KINGHOST_Username" |
||||
|
export _H2="X-Auth-Key: $KINGHOST_Password" |
||||
|
|
||||
|
if [ "$method" != "GET" ]; then |
||||
|
_debug data "$data" |
||||
|
response="$(_post "$data" "$KING_Api/$uri.json" "" "$method")" |
||||
|
else |
||||
|
response="$(_get "$KING_Api/$uri.json?$data")" |
||||
|
fi |
||||
|
|
||||
|
if [ "$?" != "0" ]; then |
||||
|
_err "error $uri" |
||||
|
return 1 |
||||
|
fi |
||||
|
_debug2 response "$response" |
||||
|
return 0 |
||||
|
} |
||||
@ -0,0 +1,227 @@ |
|||||
|
#!/usr/bin/env sh |
||||
|
|
||||
|
# |
||||
|
#LOOPIA_User="username" |
||||
|
# |
||||
|
#LOOPIA_Password="password" |
||||
|
|
||||
|
LOOPIA_Api="https://api.loopia.se/RPCSERV" |
||||
|
|
||||
|
######## Public functions ##################### |
||||
|
|
||||
|
#Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" |
||||
|
dns_loopia_add() { |
||||
|
fulldomain=$1 |
||||
|
txtvalue=$2 |
||||
|
|
||||
|
LOOPIA_User="${LOOPIA_User:-$(_readaccountconf_mutable LOOPIA_User)}" |
||||
|
LOOPIA_Password="${LOOPIA_Password:-$(_readaccountconf_mutable LOOPIA_Password)}" |
||||
|
if [ -z "$LOOPIA_User" ] || [ -z "$LOOPIA_Password" ]; then |
||||
|
LOOPIA_User="" |
||||
|
LOOPIA_Password="" |
||||
|
_err "You don't specify loopia user and password yet." |
||||
|
_err "Please create you key and try again." |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
#save the api key and email to the account conf file. |
||||
|
_saveaccountconf_mutable LOOPIA_User "$LOOPIA_User" |
||||
|
_saveaccountconf_mutable LOOPIA_Password "$LOOPIA_Password" |
||||
|
|
||||
|
_debug "First detect the root zone" |
||||
|
if ! _get_root "$fulldomain"; then |
||||
|
_err "invalid domain" |
||||
|
return 1 |
||||
|
fi |
||||
|
_debug _sub_domain "$_sub_domain" |
||||
|
_debug _domain "$_domain" |
||||
|
|
||||
|
_info "Adding record" |
||||
|
|
||||
|
_loopia_add_record "$_domain" "$_sub_domain" |
||||
|
_loopia_update_record "$_domain" "$_sub_domain" "$txtvalue" |
||||
|
|
||||
|
} |
||||
|
|
||||
|
dns_loopia_rm() { |
||||
|
fulldomain=$1 |
||||
|
txtvalue=$2 |
||||
|
|
||||
|
LOOPIA_User="${LOOPIA_User:-$(_readaccountconf_mutable LOOPIA_User)}" |
||||
|
LOOPIA_Password="${LOOPIA_Password:-$(_readaccountconf_mutable LOOPIA_Password)}" |
||||
|
if [ -z "$LOOPIA_User" ] || [ -z "$LOOPIA_Password" ]; then |
||||
|
LOOPIA_User="" |
||||
|
LOOPIA_Password="" |
||||
|
_err "You don't specify LOOPIA user and password yet." |
||||
|
_err "Please create you key and try again." |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
#save the api key and email to the account conf file. |
||||
|
_saveaccountconf_mutable LOOPIA_User "$LOOPIA_User" |
||||
|
_saveaccountconf_mutable LOOPIA_Password "$LOOPIA_Password" |
||||
|
|
||||
|
_debug "First detect the root zone" |
||||
|
if ! _get_root "$fulldomain"; then |
||||
|
_err "invalid domain" |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
xml_content=$(printf '<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<methodCall> |
||||
|
<methodName>removeSubdomain</methodName> |
||||
|
<params> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
</params> |
||||
|
</methodCall>' $LOOPIA_User $LOOPIA_Password "$_domain" "$_sub_domain") |
||||
|
|
||||
|
response="$(_post "$xml_content" "$LOOPIA_Api" "" "POST")" |
||||
|
|
||||
|
if ! _contains "$response" "OK"; then |
||||
|
_err "Error could not get txt records" |
||||
|
return 1 |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
#################### Private functions below ################################## |
||||
|
|
||||
|
_get_root() { |
||||
|
domain=$1 |
||||
|
_debug "get root" |
||||
|
|
||||
|
domain=$1 |
||||
|
i=2 |
||||
|
p=1 |
||||
|
|
||||
|
xml_content=$(printf '<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<methodCall> |
||||
|
<methodName>getDomains</methodName> |
||||
|
<params> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
</params> |
||||
|
</methodCall>' $LOOPIA_User $LOOPIA_Password) |
||||
|
|
||||
|
response="$(_post "$xml_content" "$LOOPIA_Api" "" "POST")" |
||||
|
while true; do |
||||
|
h=$(echo "$domain" | cut -d . -f $i-100) |
||||
|
if [ -z "$h" ]; then |
||||
|
#not valid |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
if _contains "$response" "$h"; then |
||||
|
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) |
||||
|
_domain="$h" |
||||
|
return 0 |
||||
|
fi |
||||
|
p=$i |
||||
|
i=$(_math "$i" + 1) |
||||
|
done |
||||
|
return 1 |
||||
|
|
||||
|
} |
||||
|
|
||||
|
_loopia_update_record() { |
||||
|
domain=$1 |
||||
|
sub_domain=$2 |
||||
|
txtval=$3 |
||||
|
|
||||
|
xml_content=$(printf '<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<methodCall> |
||||
|
<methodName>updateZoneRecord</methodName> |
||||
|
<params> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
<param> |
||||
|
<struct> |
||||
|
<member> |
||||
|
<name>type</name> |
||||
|
<value><string>TXT</string></value> |
||||
|
</member> |
||||
|
<member> |
||||
|
<name>priority</name> |
||||
|
<value><int>0</int></value> |
||||
|
</member> |
||||
|
<member> |
||||
|
<name>ttl</name> |
||||
|
<value><int>60</int></value> |
||||
|
</member> |
||||
|
<member> |
||||
|
<name>rdata</name> |
||||
|
<value><string>%s</string></value> |
||||
|
</member> |
||||
|
<member> |
||||
|
<name>record_id</name> |
||||
|
<value><int>0</int></value> |
||||
|
</member> |
||||
|
</struct> |
||||
|
</param> |
||||
|
</params> |
||||
|
</methodCall>' $LOOPIA_User $LOOPIA_Password "$domain" "$sub_domain" "$txtval") |
||||
|
|
||||
|
response="$(_post "$xml_content" "$LOOPIA_Api" "" "POST")" |
||||
|
|
||||
|
if ! _contains "$response" "OK"; then |
||||
|
_err "Error" |
||||
|
return 1 |
||||
|
fi |
||||
|
return 0 |
||||
|
} |
||||
|
|
||||
|
_loopia_add_record() { |
||||
|
domain=$1 |
||||
|
sub_domain=$2 |
||||
|
|
||||
|
xml_content=$(printf '<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<methodCall> |
||||
|
<methodName>addSubdomain</methodName> |
||||
|
<params> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
<param> |
||||
|
<value><string>%s</string></value> |
||||
|
</param> |
||||
|
</params> |
||||
|
</methodCall>' $LOOPIA_User $LOOPIA_Password "$domain" "$sub_domain") |
||||
|
|
||||
|
response="$(_post "$xml_content" "$LOOPIA_Api" "" "POST")" |
||||
|
|
||||
|
if ! _contains "$response" "OK"; then |
||||
|
_err "Error" |
||||
|
return 1 |
||||
|
fi |
||||
|
return 0 |
||||
|
} |
||||
@ -0,0 +1,69 @@ |
|||||
|
#!/usr/bin/env sh |
||||
|
# |
||||
|
# tele3.cz DNS API |
||||
|
# |
||||
|
# Author: Roman Blizik |
||||
|
# Report Bugs here: https://github.com/par-pa/acme.sh |
||||
|
# |
||||
|
# -- |
||||
|
# export TELE3_Key="MS2I4uPPaI..." |
||||
|
# export TELE3_Secret="kjhOIHGJKHg" |
||||
|
# -- |
||||
|
|
||||
|
TELE3_API="https://www.tele3.cz/acme/" |
||||
|
|
||||
|
######## Public functions ##################### |
||||
|
|
||||
|
dns_tele3_add() { |
||||
|
_info "Using TELE3 DNS" |
||||
|
data="\"ope\":\"add\", \"domain\":\"$1\", \"value\":\"$2\"" |
||||
|
if ! _tele3_call; then |
||||
|
_err "Publish zone failed" |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
_info "Zone published" |
||||
|
} |
||||
|
|
||||
|
dns_tele3_rm() { |
||||
|
_info "Using TELE3 DNS" |
||||
|
data="\"ope\":\"rm\", \"domain\":\"$1\", \"value\":\"$2\"" |
||||
|
if ! _tele3_call; then |
||||
|
_err "delete TXT record failed" |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
_info "TXT record successfully deleted" |
||||
|
} |
||||
|
|
||||
|
#################### Private functions below ################################## |
||||
|
|
||||
|
_tele3_init() { |
||||
|
TELE3_Key="${TELE3_Key:-$(_readaccountconf_mutable TELE3_Key)}" |
||||
|
TELE3_Secret="${TELE3_Secret:-$(_readaccountconf_mutable TELE3_Secret)}" |
||||
|
if [ -z "$TELE3_Key" ] || [ -z "$TELE3_Secret" ]; then |
||||
|
TELE3_Key="" |
||||
|
TELE3_Secret="" |
||||
|
_err "You must export variables: TELE3_Key and TELE3_Secret" |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
#save the config variables to the account conf file. |
||||
|
_saveaccountconf_mutable TELE3_Key "$TELE3_Key" |
||||
|
_saveaccountconf_mutable TELE3_Secret "$TELE3_Secret" |
||||
|
} |
||||
|
|
||||
|
_tele3_call() { |
||||
|
_tele3_init |
||||
|
data="{\"key\":\"$TELE3_Key\", \"secret\":\"$TELE3_Secret\", $data}" |
||||
|
|
||||
|
_debug data "$data" |
||||
|
|
||||
|
response="$(_post "$data" "$TELE3_API" "" "POST")" |
||||
|
_debug response "$response" |
||||
|
|
||||
|
if [ "$response" != "success" ]; then |
||||
|
_err "$response" |
||||
|
return 1 |
||||
|
fi |
||||
|
} |
||||
@ -0,0 +1,139 @@ |
|||||
|
#!/usr/bin/env sh |
||||
|
|
||||
|
Zilore_API="https://api.zilore.com/dns/v1" |
||||
|
# Zilore_Key="YOUR-ZILORE-API-KEY" |
||||
|
|
||||
|
######## Public functions ##################### |
||||
|
|
||||
|
dns_zilore_add() { |
||||
|
fulldomain=$1 |
||||
|
txtvalue=$2 |
||||
|
|
||||
|
_info "Using Zilore" |
||||
|
_debug fulldomain "$fulldomain" |
||||
|
_debug txtvalue "$txtvalue" |
||||
|
|
||||
|
Zilore_Key="${Zilore_Key:-$(_readaccountconf_mutable Zilore_Key)}" |
||||
|
if [ -z "$Zilore_Key" ]; then |
||||
|
Zilore_Key="" |
||||
|
_err "Please define Zilore API key" |
||||
|
return 1 |
||||
|
fi |
||||
|
_saveaccountconf_mutable Zilore_Key "$Zilore_Key" |
||||
|
|
||||
|
if ! _get_root "$fulldomain"; then |
||||
|
_err "Unable to determine root domain" |
||||
|
return 1 |
||||
|
else |
||||
|
_debug _domain "$_domain" |
||||
|
fi |
||||
|
|
||||
|
if _zilore_rest POST "domains/$_domain/records?record_type=TXT&record_ttl=600&record_name=$fulldomain&record_value=\"$txtvalue\""; then |
||||
|
if _contains "$response" '"added"' >/dev/null; then |
||||
|
_info "Added TXT record, waiting for validation" |
||||
|
return 0 |
||||
|
else |
||||
|
_debug response "$response" |
||||
|
_err "Error while adding DNS records" |
||||
|
return 1 |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
return 1 |
||||
|
} |
||||
|
|
||||
|
dns_zilore_rm() { |
||||
|
fulldomain=$1 |
||||
|
txtvalue=$2 |
||||
|
|
||||
|
_info "Using Zilore" |
||||
|
_debug fulldomain "$fulldomain" |
||||
|
_debug txtvalue "$txtvalue" |
||||
|
|
||||
|
Zilore_Key="${Zilore_Key:-$(_readaccountconf_mutable Zilore_Key)}" |
||||
|
if [ -z "$Zilore_Key" ]; then |
||||
|
Zilore_Key="" |
||||
|
_err "Please define Zilore API key" |
||||
|
return 1 |
||||
|
fi |
||||
|
_saveaccountconf_mutable Zilore_Key "$Zilore_Key" |
||||
|
|
||||
|
if ! _get_root "$fulldomain"; then |
||||
|
_err "Unable to determine root domain" |
||||
|
return 1 |
||||
|
else |
||||
|
_debug _domain "$_domain" |
||||
|
fi |
||||
|
|
||||
|
_debug "Getting TXT records" |
||||
|
_zilore_rest GET "domains/${_domain}/records?search_text=$txtvalue&search_record_type=TXT" |
||||
|
_debug response "$response" |
||||
|
|
||||
|
if ! _contains "$response" '"ok"' >/dev/null; then |
||||
|
_err "Error while getting records list" |
||||
|
return 1 |
||||
|
else |
||||
|
_record_id=$(printf "%s\n" "$response" | _egrep_o "\"record_id\":\"[^\"]+\"" | cut -d : -f 2 | tr -d \" | _head_n 1) |
||||
|
if [ -z "$_record_id" ]; then |
||||
|
_err "Cannot determine _record_id" |
||||
|
return 1 |
||||
|
else |
||||
|
_debug _record_id "$_record_id" |
||||
|
fi |
||||
|
if ! _zilore_rest DELETE "domains/${_domain}/records?record_id=$_record_id"; then |
||||
|
_err "Error while deleting chosen record" |
||||
|
return 1 |
||||
|
fi |
||||
|
_contains "$response" '"ok"' |
||||
|
fi |
||||
|
} |
||||
|
|
||||
|
#################### Private functions below ################################## |
||||
|
|
||||
|
_get_root() { |
||||
|
domain=$1 |
||||
|
i=2 |
||||
|
while true; do |
||||
|
h=$(printf "%s" "$domain" | cut -d . -f $i-100) |
||||
|
_debug h "$h" |
||||
|
if [ -z "$h" ]; then |
||||
|
#not valid |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
if ! _zilore_rest GET "domains?search_text=$h"; then |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
if _contains "$response" "\"$h\"" >/dev/null; then |
||||
|
_domain=$h |
||||
|
return 0 |
||||
|
else |
||||
|
_debug "$h not found" |
||||
|
fi |
||||
|
i=$(_math "$i" + 1) |
||||
|
done |
||||
|
return 1 |
||||
|
} |
||||
|
|
||||
|
_zilore_rest() { |
||||
|
method=$1 |
||||
|
param=$2 |
||||
|
data=$3 |
||||
|
|
||||
|
export _H1="X-Auth-Key: $Zilore_Key" |
||||
|
|
||||
|
if [ "$method" != "GET" ]; then |
||||
|
response="$(_post "$data" "$Zilore_API/$param" "" "$method")" |
||||
|
else |
||||
|
response="$(_get "$Zilore_API/$param")" |
||||
|
fi |
||||
|
|
||||
|
if [ "$?" != "0" ]; then |
||||
|
_err "error $param" |
||||
|
return 1 |
||||
|
fi |
||||
|
|
||||
|
_debug2 response "$response" |
||||
|
return 0 |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue