Martin Kammerlander
7 years ago
22 changed files with 953 additions and 138 deletions
-
11.travis.yml
-
1Dockerfile
-
12README.md
-
108acme.sh
-
6deploy/keychain.sh
-
1deploy/vault_cli.sh
-
101dnsapi/README.md
-
55dnsapi/dns_acmedns.sh
-
19dnsapi/dns_azure.sh
-
33dnsapi/dns_dnsimple.sh
-
2dnsapi/dns_freedns.sh
-
8dnsapi/dns_gd.sh
-
19dnsapi/dns_he.sh
-
50dnsapi/dns_inwx.sh
-
107dnsapi/dns_kinghost.sh
-
227dnsapi/dns_loopia.sh
-
2dnsapi/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,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