Unverified Commit 47c33d03 authored by Bill Gertz's avatar Bill Gertz Committed by GitHub
Browse files

Cleanup/ removed private function _get_root

Function _get_root() copied from acme.sh and is not needed here. Other cleanup as recommended by acme.sh test bot.
parent f500c7ab
#!/usr/bin/env sh #!/usr/bin/env sh
#Name: dns_miab.sh # Name: dns_miab.sh
# #
#Authors: # Authors:
# Darven Dissek 2018 # Darven Dissek 2018
# William Gertz 2019 # William Gertz 2019
# #
# Thanks to Neil Pang for the code reused from acme.sh from HTTP-01 validation # Thanks to Neil Pang for the code reused from acme.sh from HTTP-01 validation
# used to communicate with the MailintheBox Custom DNS API # used to communicate with the MailintheBox Custom DNS API
#Report Bugs here: # Report Bugs here:
# https://github.com/billgertz/MIAB_dns_api (for dns_miab.sh) # https://github.com/billgertz/MIAB_dns_api (for dns_miab.sh)
# https://github.com/Neilpang/acme.sh (for acme.sh) # https://github.com/Neilpang/acme.sh (for acme.sh)
# #
######## Public functions ##################### ######## Public functions #####################
...@@ -41,9 +41,9 @@ dns_miab_add() { ...@@ -41,9 +41,9 @@ dns_miab_add() {
fi fi
#save the credentials to the account conf file. #save the credentials to the account conf file.
_saveaccountconf_mutable MIAB_Username "$MIAB_Username" _saveaccountconf_mutable MIAB_Username "$MIAB_Username"
_saveaccountconf_mutable MIAB_Password "$MIAB_Password" _saveaccountconf_mutable MIAB_Password "$MIAB_Password"
_saveaccountconf_mutable MIAB_Server "$MIAB_Server" _saveaccountconf_mutable MIAB_Server "$MIAB_Server"
baseurl="https://$MIAB_Server/admin/dns/custom/$fulldomain/txt" baseurl="https://$MIAB_Server/admin/dns/custom/$fulldomain/txt"
...@@ -61,7 +61,6 @@ dns_miab_add() { ...@@ -61,7 +61,6 @@ dns_miab_add() {
_err "$result" _err "$result"
return 1 return 1
fi fi
} }
#Usage: fulldomain txtvalue #Usage: fulldomain txtvalue
...@@ -92,16 +91,16 @@ dns_miab_rm() { ...@@ -92,16 +91,16 @@ dns_miab_rm() {
fi fi
#save the credentials to the account conf file. #save the credentials to the account conf file.
_saveaccountconf_mutable MIAB_Username "$MIAB_Username" _saveaccountconf_mutable MIAB_Username "$MIAB_Username"
_saveaccountconf_mutable MIAB_Password "$MIAB_Password" _saveaccountconf_mutable MIAB_Password "$MIAB_Password"
_saveaccountconf_mutable MIAB_Server "$MIAB_Server" _saveaccountconf_mutable MIAB_Server "$MIAB_Server"
baseurl="https://$MIAB_Server/admin/dns/custom/$fulldomain/txt" baseurl="https://$MIAB_Server/admin/dns/custom/$fulldomain/txt"
#Remove the challenge record #Remove the challenge record
result="$(_miab_post "$txtvalue" "$baseurl" "" "DELETE" "" "$MIAB_Username" "$MIAB_Password")" result="$(_miab_post "$txtvalue" "$baseurl" "" "DELETE" "" "$MIAB_Username" "$MIAB_Password")"
_debug result $result _debug result "$result"
#check if result was good #check if result was good
if _contains "$result" "updated DNS"; then if _contains "$result" "updated DNS"; then
...@@ -115,43 +114,7 @@ dns_miab_rm() { ...@@ -115,43 +114,7 @@ dns_miab_rm() {
} }
#################### Private functions below ################################## #################### Private functions below ##################################
#_acme-challenge.www.domain.com #
#returns
# _sub_domain=_acme-challenge.www
# _domain=domain.com
# _domain_id=sdjkglgdfewsdfg
_get_root() {
domain=$1
i=2
p=1
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 _contains "$response" "\"name\":\"$h\"" >/dev/null; then
_domain_id=$(printf "%s\n" "$response" | _egrep_o "\[.\"id\":\"[^\"]*\"" | head -n 1 | cut -d : -f 2 | tr -d \")
if [ "$_domain_id" ]; then
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p)
_domain=$h
return 0
fi
return 1
fi
p=$i
i=$(_math "$i" + 1)
done
return 1
}
# post changes to MIAB dns (taken from acme.sh) # post changes to MIAB dns (taken from acme.sh)
_miab_post() { _miab_post() {
body="$1" body="$1"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment