From 7f90b79b2f66a5cbd93f203bac439c016643e44e Mon Sep 17 00:00:00 2001 From: yousaywhatiswhat <76113851+yousaywhatiswhat@users.noreply.github.com> Date: Tue, 27 Jul 2021 17:19:47 +0800 Subject: [PATCH] Create dns_ls.sh --- dnsapi/dns_ls.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 dnsapi/dns_ls.sh diff --git a/dnsapi/dns_ls.sh b/dnsapi/dns_ls.sh new file mode 100644 index 00000000..54af299a --- /dev/null +++ b/dnsapi/dns_ls.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +#Report Bugs here: https://github.com/acmesh-official/acme.sh +# +LS_API="http://www.icdn.hk:5050/api/drsd" +######## Public functions ##################### + +# Please Read this guide first: https://github.com/acmesh-official/acme.sh/wiki/DNS-API-Dev-Guide + +#Usage: dns_myapi_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" +dns_ls_add() { + fulldomain=$1 + txtvalue=$2 + + LS_Key="${LS_Key:-$(_readaccountconf_mutable LS_Key)}" + if [ -z "$LS_Key" ]; then + _err "You don't specify ls api key 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 LS_Key "$LS_Key" + + _info "Adding TXT record to ${fulldomain}" + response="$(_post "secretkey=${LS_Key}&domain=${fulldomain}&rval=${txtvalue}" "$LS_API")" + if ! _contains "${response}" 'success'; then + _err "Could not create resource record, check logs" + _err "${response}" + return 1 + else + return 0 + fi +} + +#Usage: fulldomain txtvalue +#Remove the txt record after validation. +dns_ls_rm() { + fulldomain=$1 + txtvalue=$2 + LS_Key="${LS_Key:-$(_readaccountconf_mutable LS_Key)}" + if [ -z "$LS_Key" ]; then + _err "You don't specify ls api key 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 LS_Key "$LS_Key" + + _info "Adding TXT record to ${fulldomain}" + response="$(_post "secretkey=${LS_Key}&domain=${fulldomain}&rval=${txtvalue}&option=del" "$LS_API")" + if ! _contains "${response}" 'success'; then + _err "Could not create resource record, check logs" + _err "${response}" + return 1 + else + return 0 + fi +} +#################### Private functions below ##################################