mirror of
				https://github.com/hiskang/acme.sh
				synced 2025-11-03 20:07:43 +00:00 
			
		
		
		
	fix identation dnsapi/dns_kinghost.sh
This commit is contained in:
		
							parent
							
								
									c6023782a4
								
							
						
					
					
						commit
						4d2a0697ed
					
				
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					.idea
 | 
				
			||||||
 | 
					ae.sh
 | 
				
			||||||
@ -17,79 +17,79 @@ KING_Api="https://api.kinghost.net/acme"
 | 
				
			|||||||
# Usage: add  _acme-challenge.www.domain.com   "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
 | 
					# Usage: add  _acme-challenge.www.domain.com   "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs"
 | 
				
			||||||
# Used to add txt record
 | 
					# Used to add txt record
 | 
				
			||||||
dns_kinghost_add() {
 | 
					dns_kinghost_add() {
 | 
				
			||||||
    fulldomain=$1
 | 
					  fulldomain=$1
 | 
				
			||||||
    txtvalue=$2
 | 
					  txtvalue=$2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    KINGHOST_Username="${KINGHOST_Username:-$(_readaccountconf_mutable KINGHOST_Username)}"
 | 
					  KINGHOST_Username="${KINGHOST_Username:-$(_readaccountconf_mutable KINGHOST_Username)}"
 | 
				
			||||||
    KINGHOST_Password="${KINGHOST_Password:-$(_readaccountconf_mutable KINGHOST_Password)}"
 | 
					  KINGHOST_Password="${KINGHOST_Password:-$(_readaccountconf_mutable KINGHOST_Password)}"
 | 
				
			||||||
    if [ -z "$KINGHOST_Username" ] || [ -z "$KINGHOST_Password" ]; then
 | 
					  if [ -z "$KINGHOST_Username" ] || [ -z "$KINGHOST_Password" ]; then
 | 
				
			||||||
        KINGHOST_Username=""
 | 
					    KINGHOST_Username=""
 | 
				
			||||||
        KINGHOST_Password=""
 | 
					    KINGHOST_Password=""
 | 
				
			||||||
        _err "You don't specify KingHost api password and email yet."
 | 
					    _err "You don't specify KingHost api password and email yet."
 | 
				
			||||||
        _err "Please create you key and try again."
 | 
					    _err "Please create you key and try again."
 | 
				
			||||||
        return 1
 | 
					    return 1
 | 
				
			||||||
    fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #save the credentials to the account conf file.
 | 
					  #save the credentials to the account conf file.
 | 
				
			||||||
    _saveaccountconf_mutable KINGHOST_Username  "$KINGHOST_Username"
 | 
					  _saveaccountconf_mutable KINGHOST_Username  "$KINGHOST_Username"
 | 
				
			||||||
    _saveaccountconf_mutable KINGHOST_Password  "$KINGHOST_Password"
 | 
					  _saveaccountconf_mutable KINGHOST_Password  "$KINGHOST_Password"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _debug "Getting txt records"
 | 
					  _debug "Getting txt records"
 | 
				
			||||||
    _kinghost_rest GET "dns" "name=$fulldomain&content=$txtvalue"
 | 
					  _kinghost_rest GET "dns" "name=$fulldomain&content=$txtvalue"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #This API call returns "status":"ok" if dns record does not exists
 | 
					  #This API call returns "status":"ok" if dns record does not exists
 | 
				
			||||||
    #We are creating a new txt record here, so we expect the "ok" status
 | 
					  #We are creating a new txt record here, so we expect the "ok" status
 | 
				
			||||||
    if ! echo "$response" | grep '"status":"ok"' >/dev/null; then
 | 
					  if ! echo "$response" | grep '"status":"ok"' >/dev/null; then
 | 
				
			||||||
        _err "Error"
 | 
					    _err "Error"
 | 
				
			||||||
        _err "$response"
 | 
					    _err "$response"
 | 
				
			||||||
        return 1
 | 
					    return 1
 | 
				
			||||||
    fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _kinghost_rest POST "dns" "name=$fulldomain&content=$txtvalue"
 | 
					  _kinghost_rest POST "dns" "name=$fulldomain&content=$txtvalue"
 | 
				
			||||||
    if ! echo "$response" | grep '"status":"ok"' >/dev/null; then
 | 
					  if ! echo "$response" | grep '"status":"ok"' >/dev/null; then
 | 
				
			||||||
        _err "Error"
 | 
					    _err "Error"
 | 
				
			||||||
        _err "$response"
 | 
					    _err "$response"
 | 
				
			||||||
        return 1
 | 
					    return 1
 | 
				
			||||||
    fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Usage: fulldomain txtvalue
 | 
					# Usage: fulldomain txtvalue
 | 
				
			||||||
# Used to remove the txt record after validation
 | 
					# Used to remove the txt record after validation
 | 
				
			||||||
dns_kinghost_rm() {
 | 
					dns_kinghost_rm() {
 | 
				
			||||||
    fulldomain=$1
 | 
					  fulldomain=$1
 | 
				
			||||||
    txtvalue=$2
 | 
					  txtvalue=$2
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    KINGHOST_Password="${KINGHOST_Password:-$(_readaccountconf_mutable KINGHOST_Password)}"
 | 
					  KINGHOST_Password="${KINGHOST_Password:-$(_readaccountconf_mutable KINGHOST_Password)}"
 | 
				
			||||||
    KINGHOST_Username="${KINGHOST_Username:-$(_readaccountconf_mutable KINGHOST_Username)}"
 | 
					  KINGHOST_Username="${KINGHOST_Username:-$(_readaccountconf_mutable KINGHOST_Username)}"
 | 
				
			||||||
        if [ -z "$KINGHOST_Password" ] || [ -z "$KINGHOST_Username" ]; then
 | 
					    if [ -z "$KINGHOST_Password" ] || [ -z "$KINGHOST_Username" ]; then
 | 
				
			||||||
        KINGHOST_Password=""
 | 
					    KINGHOST_Password=""
 | 
				
			||||||
        KINGHOST_Username=""
 | 
					    KINGHOST_Username=""
 | 
				
			||||||
        _err "You don't specify KingHost api key and email yet."
 | 
					    _err "You don't specify KingHost api key and email yet."
 | 
				
			||||||
        _err "Please create you key and try again."
 | 
					    _err "Please create you key and try again."
 | 
				
			||||||
        return 1
 | 
					    return 1
 | 
				
			||||||
    fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _debug "Getting txt records"
 | 
					  _debug "Getting txt records"
 | 
				
			||||||
    _kinghost_rest GET "dns" "name=$fulldomain&content=$txtvalue"
 | 
					  _kinghost_rest GET "dns" "name=$fulldomain&content=$txtvalue"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #This API call returns "status":"ok" if dns record does not exists
 | 
					  #This API call returns "status":"ok" if dns record does not exists
 | 
				
			||||||
    #We are removing a txt record here, so the record must exists
 | 
					  #We are removing a txt record here, so the record must exists
 | 
				
			||||||
    if echo "$response" | grep '"status":"ok"' >/dev/null; then
 | 
					  if echo "$response" | grep '"status":"ok"' >/dev/null; then
 | 
				
			||||||
        _err "Error"
 | 
					    _err "Error"
 | 
				
			||||||
        _err "$response"
 | 
					    _err "$response"
 | 
				
			||||||
        return 1
 | 
					    return 1
 | 
				
			||||||
    fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _kinghost_rest DELETE "dns" "name=$fulldomain&content=$txtvalue"
 | 
					  _kinghost_rest DELETE "dns" "name=$fulldomain&content=$txtvalue"
 | 
				
			||||||
    if ! echo "$response" | grep '"status":"ok"' >/dev/null; then
 | 
					  if ! echo "$response" | grep '"status":"ok"' >/dev/null; then
 | 
				
			||||||
        _err "Error"
 | 
					    _err "Error"
 | 
				
			||||||
        _err "$response"
 | 
					    _err "$response"
 | 
				
			||||||
        return 1
 | 
					    return 1
 | 
				
			||||||
    fi
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					  return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
####################  Private functions below ##################################
 | 
					####################  Private functions below ##################################
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user