]> git.proxmox.com Git - mirror_acme.sh.git/blobdiff - dnsapi/dns_kappernet.sh
Update dns_kappernet.sh
[mirror_acme.sh.git] / dnsapi / dns_kappernet.sh
index 754505499e5b9117a7b1c5dbe101d49732c8ed2b..0a8951cb5d79151c6862764e3e1be39a2c920bf6 100644 (file)
@@ -5,29 +5,33 @@
 # please report issues here: https://github.com/acmesh-official/acme.sh/issues/2977
 
 #KAPPERNETDNS_Key="yourKAPPERNETapikey"
-#KAPPERNETDNS_Secret="yourKAPPERNETapisecret" 
+#KAPPERNETDNS_Secret="yourKAPPERNETapisecret"
 
-KAPPERNETDNS_Api="https://dnspanel.kapper.net/API/1.1?APIKey=$KAPPERNETDNS_Key&APISecret=$KAPPERNETDNS_Secret"
+KAPPERNETDNS_Api="https://dnspanel.kapper.net/API/1.2?APIKey=$KAPPERNETDNS_Key&APISecret=$KAPPERNETDNS_Secret"
 
 ###############################################################################
-# called with 
+# called with
 # fullhostname: something.example.com
 # txtvalue:     someacmegenerated string
 dns_kappernet_add() {
   fullhostname=$1
   txtvalue=$2
 
+  KAPPERNETDNS_Key="${KAPPERNETDNS_Key:-$(_readaccountconf_mutable KAPPERNETDNS_Key)}"
+  KAPPERNETDNS_Secret="${KAPPERNETDNS_Secret:-$(_readaccountconf_mutable KAPPERNETDNS_Secret)}"
+
   if [ -z "$KAPPERNETDNS_Key" ] || [ -z "$KAPPERNETDNS_Secret" ]; then
     KAPPERNETDNS_Key=""
     KAPPERNETDNS_Secret=""
-    _err "You haven't defined kapper.net api key and secret yet."
-    _err "Please send us mail to support@kapper.net get your key and secret."
+    _err "Please specify your kapper.net api key and secret."
+    _err "If you have not received yours - send your mail to"
+    _err "support@kapper.net to get  your key and secret."
     return 1
   fi
 
   #store the api key and email to the account conf file.
-  _saveaccountconf KAPPERNETDNS_Key "$KAPPERNETDNS_Key"
-  _saveaccountconf KAPPERNETDNS_Secret "$KAPPERNETDNS_Secret"
+  _saveaccountconf_mutable KAPPERNETDNS_Key "$KAPPERNETDNS_Key"
+  _saveaccountconf_mutable KAPPERNETDNS_Secret "$KAPPERNETDNS_Secret"
   _debug "Checking Domain ..."
   if ! _get_root "$fullhostname"; then
     _err "invalid domain"
@@ -41,8 +45,8 @@ dns_kappernet_add() {
   if _kappernet_api GET "action=new&subject=$_domain&data=$data"; then
 
     if _contains "$response" "{\"OK\":true"; then
-      _info "Waiting 120 seconds for DNS to spread the new record"
-      _sleep 120
+      _info "Waiting 1 second for DNS to spread the new record"
+      _sleep 1
       return 0
     else
       _err "Error creating a TXT DNS Record: $fullhostname TXT $txtvalue"
@@ -60,36 +64,40 @@ dns_kappernet_rm() {
   fullhostname=$1
   txtvalue=$2
 
+  KAPPERNETDNS_Key="${KAPPERNETDNS_Key:-$(_readaccountconf_mutable KAPPERNETDNS_Key)}"
+  KAPPERNETDNS_Secret="${KAPPERNETDNS_Secret:-$(_readaccountconf_mutable KAPPERNETDNS_Secret)}"
+
   if [ -z "$KAPPERNETDNS_Key" ] || [ -z "$KAPPERNETDNS_Secret" ]; then
     KAPPERNETDNS_Key=""
     KAPPERNETDNS_Secret=""
-    _err "You haven't defined kapper.net api key and secret yet."
-    _err "Please send us mail to get your key and secret."
+    _err "Please specify your kapper.net api key and secret."
+    _err "If you have not received yours - send your mail to"
+    _err "support@kapper.net to get  your key and secret."
     return 1
   fi
 
   #store the api key and email to the account conf file.
-  _saveaccountconf KAPPERNETDNS_Key "$KAPPERNETDNS_Key"
-  _saveaccountconf KAPPERNETDNS_Secret "$KAPPERNETDNS_Secret"
+  _saveaccountconf_mutable KAPPERNETDNS_Key "$KAPPERNETDNS_Key"
+  _saveaccountconf_mutable KAPPERNETDNS_Secret "$KAPPERNETDNS_Secret"
 
-  _info "Trying to remove the TXT Record: $fullhostname"
-
-  if _kappernet_api GET "action=del&subject=$fullhostname"; then
+  _info "Trying to remove the TXT Record: $fullhostname containing $txtvalue"
+  data="%7B%22name%22%3A%22$fullhostname%22%2C%22type%22%3A%22TXT%22%2C%22content%22%3A%22$txtvalue%22%2C%22ttl%22%3A%223600%22%2C%22prio%22%3A%22%22%7D"
+  if _kappernet_api GET "action=del&subject=$fullhostname&data=$data"; then
     if _contains "$response" "{\"OK\":true"; then
       return 0
     else
-      _err "Error deleting DNS Record: $fullhostname"
+      _err "Error deleting DNS Record: $fullhostname containing $txtvalue"
       _err "Problem: $response"
       return 1
     fi
   fi
-  _err "Problem creating TXT DNS record"
+  _err "Problem deleting TXT DNS record"
 }
 
 ####################  Private functions below ##################################
 # called with hostname
 # e.g._acme-challenge.www.domain.com returns
-# _sub_domain=_acme-challenge.www 
+# _sub_domain=_acme-challenge.www
 # _domain=domain.com
 _get_root() {
   domain=$1
@@ -119,7 +127,7 @@ _get_root() {
 
 ################################################################################
 # calls the kapper.net DNS Panel API
-# with 
+# with
 # method
 # param
 _kappernet_api() {