Browse Source

getdnsconf

neil 6 years ago
parent
commit
bc2642f6d4
2 changed files with 27 additions and 6 deletions
  1. 20 0
      acme.sh
  2. 7 6
      dnsapi/dns_cf.sh

+ 20 - 0
acme.sh

@@ -2100,6 +2100,26 @@ _getdeployconf() {
   eval "export $_rac_key=$_saved"
   eval "export $_rac_key=$_saved"
 }
 }
 
 
+#key
+_getdnsapiconf() {
+  _rac_key="$1"
+  _rac_value="$(eval echo \$"$_rac_key")"
+  if [ "$_rac_value" ]; then
+    if _startswith "$_rac_value" '"' && _endswith "$_rac_value" '"'; then
+      _debug2 "trim quotation marks"
+      eval "export $_rac_key=$_rac_value"
+    fi
+    return 0 # do nothing
+  fi
+  _saved=$(_readaccountconf_mutable "$_rac_key")
+  eval "export $_rac_key=$_saved"
+}
+
+#key  value base64encode
+_savednsapiconf() {
+  _saveaccountconf_mutable "$@"
+}
+
 #_saveaccountconf  key  value  base64encode
 #_saveaccountconf  key  value  base64encode
 _saveaccountconf() {
 _saveaccountconf() {
   _save_conf "$ACCOUNT_CONF_PATH" "$@"
   _save_conf "$ACCOUNT_CONF_PATH" "$@"

+ 7 - 6
dnsapi/dns_cf.sh

@@ -14,8 +14,9 @@ dns_cf_add() {
   fulldomain=$1
   fulldomain=$1
   txtvalue=$2
   txtvalue=$2
 
 
-  CF_Key="${CF_Key:-$(_readaccountconf_mutable CF_Key)}"
-  CF_Email="${CF_Email:-$(_readaccountconf_mutable CF_Email)}"
+  _getdnsapiconf CF_Key
+  _getdnsapiconf CF_Email
+
   if [ -z "$CF_Key" ] || [ -z "$CF_Email" ]; then
   if [ -z "$CF_Key" ] || [ -z "$CF_Email" ]; then
     CF_Key=""
     CF_Key=""
     CF_Email=""
     CF_Email=""
@@ -31,8 +32,8 @@ dns_cf_add() {
   fi
   fi
 
 
   #save the api key and email to the account conf file.
   #save the api key and email to the account conf file.
-  _saveaccountconf_mutable CF_Key "$CF_Key"
-  _saveaccountconf_mutable CF_Email "$CF_Email"
+  _savednsapiconf CF_Key "$CF_Key"
+  _savednsapiconf CF_Email "$CF_Email"
 
 
   _debug "First detect the root zone"
   _debug "First detect the root zone"
   if ! _get_root "$fulldomain"; then
   if ! _get_root "$fulldomain"; then
@@ -92,8 +93,8 @@ dns_cf_rm() {
   fulldomain=$1
   fulldomain=$1
   txtvalue=$2
   txtvalue=$2
 
 
-  CF_Key="${CF_Key:-$(_readaccountconf_mutable CF_Key)}"
-  CF_Email="${CF_Email:-$(_readaccountconf_mutable CF_Email)}"
+  _getdnsapiconf CF_Key
+  _getdnsapiconf CF_Email
   if [ -z "$CF_Key" ] || [ -z "$CF_Email" ]; then
   if [ -z "$CF_Key" ] || [ -z "$CF_Email" ]; then
     CF_Key=""
     CF_Key=""
     CF_Email=""
     CF_Email=""