mirror of
				https://github.com/hiskang/acme.sh
				synced 2025-10-31 10:27:22 +00:00 
			
		
		
		
	Fix against POSIX standard.
This commit is contained in:
		
							parent
							
								
									168d712dec
								
							
						
					
					
						commit
						eeda3062e1
					
				| @ -17,8 +17,7 @@ dns_duckdns_add() { | |||||||
|   txtvalue=$2 |   txtvalue=$2 | ||||||
| 
 | 
 | ||||||
|   # We'll extract the domain/username from full domain |   # We'll extract the domain/username from full domain | ||||||
|   IFS='.' read -r -a fqdn <<< "$fulldomain" |   DuckDNS_domain=$(printf "%s\n" "$fulldomain" | rev | cut -d \. -f 3 | rev) | ||||||
|   DuckDNS_domain="${fqdn[-3]}" |  | ||||||
| 
 | 
 | ||||||
|   if [ -z "$DuckDNS_domain" ]; then |   if [ -z "$DuckDNS_domain" ]; then | ||||||
|     _err "Error extracting the domain." |     _err "Error extracting the domain." | ||||||
| @ -42,7 +41,7 @@ dns_duckdns_add() { | |||||||
| 
 | 
 | ||||||
|   # Now add the TXT record to DuckDNS |   # Now add the TXT record to DuckDNS | ||||||
|   _info "Trying to add TXT record" |   _info "Trying to add TXT record" | ||||||
|   if _duckdns_rest GET "$API_Params&txt=$txtvalue" && [ $response == "OK" ]; then |   if _duckdns_rest GET "$API_Params&txt=$txtvalue" && [ "$response" -eq "OK" ]; then | ||||||
|     _info "TXT record has been successfully added to your DuckDNS domain." |     _info "TXT record has been successfully added to your DuckDNS domain." | ||||||
|     _info "Note that all subdomains under this domain uses the same TXT record." |     _info "Note that all subdomains under this domain uses the same TXT record." | ||||||
|     return 0 |     return 0 | ||||||
| @ -60,7 +59,7 @@ dns_duckdns_rm() { | |||||||
| 
 | 
 | ||||||
|   # Now remove the TXT record from DuckDNS |   # Now remove the TXT record from DuckDNS | ||||||
|   _info "Trying to remove TXT record" |   _info "Trying to remove TXT record" | ||||||
|   if _duckdns_rest GET "$API_Params&txt=&clear=true" && [ $response == "OK" ]; then |   if _duckdns_rest GET "$API_Params&txt=&clear=true" && [ "$response" -eq "OK" ]; then | ||||||
|     _info "TXT record has been successfully removed from your DuckDNS domain." |     _info "TXT record has been successfully removed from your DuckDNS domain." | ||||||
|     return 0 |     return 0 | ||||||
|   else |   else | ||||||
| @ -80,7 +79,7 @@ _duckdns_rest() { | |||||||
|   _debug url "$url" |   _debug url "$url" | ||||||
| 
 | 
 | ||||||
|   # DuckDNS uses GET to update domain info |   # DuckDNS uses GET to update domain info | ||||||
|   if [ $method == "GET" ]; then |   if [ "$method" -eq "GET" ]; then | ||||||
|     response="$(_get "$url")" |     response="$(_get "$url")" | ||||||
|   else |   else | ||||||
|     _err "Unsupported method" |     _err "Unsupported method" | ||||||
|  | |||||||
| @ -45,15 +45,15 @@ dns_namecom_add() { | |||||||
|   _namecom_addtxt_json="{\"hostname\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\",\"ttl\":\"300\",\"priority\":\"10\"}" |   _namecom_addtxt_json="{\"hostname\":\"$_sub_domain\",\"type\":\"TXT\",\"content\":\"$txtvalue\",\"ttl\":\"300\",\"priority\":\"10\"}" | ||||||
|   if _namecom_rest POST "dns/create/$_domain" "$_namecom_addtxt_json"; then |   if _namecom_rest POST "dns/create/$_domain" "$_namecom_addtxt_json"; then | ||||||
|     retcode=$(printf "%s\n" "$response" | _egrep_o "\"code\":100") |     retcode=$(printf "%s\n" "$response" | _egrep_o "\"code\":100") | ||||||
|       if [ ! -z "$retcode" ]; then |     if [ ! -z "$retcode" ]; then | ||||||
|         _info "Successfully added TXT record, ready for validation." |       _info "Successfully added TXT record, ready for validation." | ||||||
|         _namecom_logout |       _namecom_logout | ||||||
|         return 0 |       return 0 | ||||||
|       else |     else | ||||||
|         _err "Unable to add the DNS record." |       _err "Unable to add the DNS record." | ||||||
|         _namecom_logout |       _namecom_logout | ||||||
|         return 1 |       return 1 | ||||||
|       fi |     fi | ||||||
|   fi |   fi | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -75,30 +75,30 @@ dns_namecom_rm() { | |||||||
|   # Get the record id. |   # Get the record id. | ||||||
|   if _namecom_rest GET "dns/list/$_domain"; then |   if _namecom_rest GET "dns/list/$_domain"; then | ||||||
|     retcode=$(printf "%s\n" "$response" | _egrep_o "\"code\":100") |     retcode=$(printf "%s\n" "$response" | _egrep_o "\"code\":100") | ||||||
|       if [ ! -z "$retcode" ]; then |     if [ ! -z "$retcode" ]; then | ||||||
|         _record_id=$(printf "%s\n" "$response" | _egrep_o "\"record_id\":\"[0-9]+\",\"name\":\"$fulldomain\",\"type\":\"TXT\"" | cut -d : -f 2 | cut -d \" -f 2) |       _record_id=$(printf "%s\n" "$response" | _egrep_o "\"record_id\":\"[0-9]+\",\"name\":\"$fulldomain\",\"type\":\"TXT\"" | cut -d : -f 2 | cut -d \" -f 2) | ||||||
|         _debug record_id "$_record_id" |       _debug record_id "$_record_id" | ||||||
|         _info "Successfully retrieved the record id for ACME challenge." |       _info "Successfully retrieved the record id for ACME challenge." | ||||||
|       else |     else | ||||||
|         _err "Unable to retrieve the record id." |       _err "Unable to retrieve the record id." | ||||||
|         _namecom_logout |       _namecom_logout | ||||||
|         return 1 |       return 1 | ||||||
|       fi |     fi | ||||||
|   fi |   fi | ||||||
| 
 | 
 | ||||||
|   # Remove the DNS record using record id. |   # Remove the DNS record using record id. | ||||||
|   _namecom_rmtxt_json="{\"record_id\":\"$_record_id\"}" |   _namecom_rmtxt_json="{\"record_id\":\"$_record_id\"}" | ||||||
|   if _namecom_rest POST "dns/delete/$_domain" "$_namecom_rmtxt_json"; then |   if _namecom_rest POST "dns/delete/$_domain" "$_namecom_rmtxt_json"; then | ||||||
|     retcode=$(printf "%s\n" "$response" | _egrep_o "\"code\":100") |     retcode=$(printf "%s\n" "$response" | _egrep_o "\"code\":100") | ||||||
|       if [ ! -z "$retcode" ]; then |     if [ ! -z "$retcode" ]; then | ||||||
|         _info "Successfully removed the TXT record." |       _info "Successfully removed the TXT record." | ||||||
|         _namecom_logout |       _namecom_logout | ||||||
|         return 0 |       return 0 | ||||||
|       else |     else | ||||||
|         _err "Unable to remove the DNS record." |       _err "Unable to remove the DNS record." | ||||||
|         _namecom_logout |       _namecom_logout | ||||||
|         return 1 |       return 1 | ||||||
|       fi |     fi | ||||||
|   fi |   fi | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -130,32 +130,32 @@ _namecom_login() { | |||||||
| 
 | 
 | ||||||
|   if _namecom_rest POST "login" "$namecom_login_json"; then |   if _namecom_rest POST "login" "$namecom_login_json"; then | ||||||
|     retcode=$(printf "%s\n" "$response" | _egrep_o "\"code\":100") |     retcode=$(printf "%s\n" "$response" | _egrep_o "\"code\":100") | ||||||
|       if [ ! -z "$retcode" ]; then |     if [ ! -z "$retcode" ]; then | ||||||
|         _info "Successfully logged in. Fetching session token..." |       _info "Successfully logged in. Fetching session token..." | ||||||
|         sessionkey=$(printf "%s\n" "$response" | _egrep_o "\"session_token\":\".+" | cut -d \" -f 4) |       sessionkey=$(printf "%s\n" "$response" | _egrep_o "\"session_token\":\".+" | cut -d \" -f 4) | ||||||
|         if [ ! -z "$sessionkey" ]; then |       if [ ! -z "$sessionkey" ]; then | ||||||
|           _debug sessionkey "$sessionkey" |         _debug sessionkey "$sessionkey" | ||||||
|           _info "Session key obtained." |         _info "Session key obtained." | ||||||
|         else |  | ||||||
|           _err "Unable to get session key." |  | ||||||
|           return 1 |  | ||||||
|         fi |  | ||||||
|       else |       else | ||||||
|         _err "Logging in failed." |         _err "Unable to get session key." | ||||||
|         return 1 |         return 1 | ||||||
|       fi |       fi | ||||||
|    fi |     else | ||||||
|  |       _err "Logging in failed." | ||||||
|  |       return 1 | ||||||
|  |     fi | ||||||
|  |   fi | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| _namecom_logout() { | _namecom_logout() { | ||||||
|   if _namecom_rest GET "logout"; then |   if _namecom_rest GET "logout"; then | ||||||
|     retcode=$(printf "%s\n" "$response" | _egrep_o "\"code\":100") |     retcode=$(printf "%s\n" "$response" | _egrep_o "\"code\":100") | ||||||
|       if [ ! -z "$retcode" ]; then |     if [ ! -z "$retcode" ]; then | ||||||
|         _info "Successfully logged out." |       _info "Successfully logged out." | ||||||
|       else |     else | ||||||
|         _err "Error logging out." |       _err "Error logging out." | ||||||
|         return 1 |       return 1 | ||||||
|       fi |     fi | ||||||
|   fi |   fi | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -171,13 +171,13 @@ _namecom_get_root() { | |||||||
|         return 1 |         return 1 | ||||||
|       fi |       fi | ||||||
| 
 | 
 | ||||||
|      if _contains "$response" "$host"; then |       if _contains "$response" "$host"; then | ||||||
|        _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) |         _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) | ||||||
|        _domain="$host" |         _domain="$host" | ||||||
|        return 0 |         return 0 | ||||||
|      fi |       fi | ||||||
|      p=$i |       p=$i | ||||||
|      i=$(_math "$i" + 1) |       i=$(_math "$i" + 1) | ||||||
|     done |     done | ||||||
|   fi |   fi | ||||||
|   return 1 |   return 1 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user