5 #GD_Key="sdfsdfsdfljlbjkljlkjsdfoiwje"
7 #GD_Secret="asdfsdfsfsdfsdfdfsdf"
9 GD_Api
="https://api.godaddy.com/v1"
11 ######## Public functions #####################
13 #Usage: add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
18 if [ -z "$GD_Key" ] ||
[ -z "$GD_Secret" ]; then
19 _err
"You don't specify godaddy api key and secret yet."
20 _err
"Please create you key and try again."
24 #save the api key and email to the account conf file.
25 _saveaccountconf GD_Key
"$GD_Key"
26 _saveaccountconf GD_Secret
"$GD_Secret"
28 _debug
"First detect the root zone"
29 if ! _get_root
$fulldomain; then
33 _debug _domain_id
"$_domain_id"
34 _debug _sub_domain
"$_sub_domain"
35 _debug _domain
"$_domain"
38 if _gd_rest PUT
"domains/$_domain/records/TXT/$_sub_domain" "[{\"data\":\"$txtvalue\"}]"; then
39 if [ "$response" = "{}" ]; then
40 _info
"Added, sleeping 10 seconds"
42 #todo: check if the record takes effect
45 _err
"Add txt record error."
50 _err
"Add txt record error."
60 #################### Private functions bellow ##################################
61 #_acme-challenge.www.domain.com
63 # _sub_domain=_acme-challenge.www
65 # _domain_id=sdjkglgdfewsdfg
71 h
=$
(printf $domain | cut
-d .
-f $i-100)
77 if ! _gd_rest GET
"domains/$h"; then
81 if printf "$response" |
grep '"code":"NOT_FOUND"' >/dev
/null
; then
84 _sub_domain
=$
(printf $domain | cut
-d .
-f 1-$p)
100 _H1
="Authorization: sso-key $GD_Key:$GD_Secret"
101 _H2
="Content-Type: application/json"
105 response
="$(_post "$data" "$GD_Api/$ep" "" $m)"
107 response
="$(_get "$GD_Api/$ep")"
110 if [ "$?" != "0" ]; then
114 _debug2 response
"$response"