removed extra newlines, change tab indent to 2 spaces
This commit is contained in:
parent
657ddf6d9e
commit
e2d74b4616
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
|
||||
## Will be called by acme.sh to add the txt record to your api system.
|
||||
## returns 0 means success, otherwise error.
|
||||
|
||||
@ -16,10 +15,8 @@
|
||||
## (EG: one.two.three.four.five.com -> one.two & three.four.five.com)
|
||||
##
|
||||
|
||||
|
||||
##################### Public functions #####################
|
||||
|
||||
|
||||
## Create the text record for validation.
|
||||
## Usage: fulldomain txtvalue
|
||||
## EG: "_acme-challenge.www.other.domain.com" "XKrxpRBosdq0HG9i01zxXp5CPBs"
|
||||
@ -40,8 +37,8 @@ dns_digitalocean_add() {
|
||||
_debug _domain "$_domain"
|
||||
|
||||
## Set the header with our post type and key auth key
|
||||
_H1="Content-Type: application/json"
|
||||
_H2="Authorization: Bearer $DO_API_KEY"
|
||||
export _H1="Content-Type: application/json"
|
||||
export _H2="Authorization: Bearer $DO_API_KEY"
|
||||
PURL='https://api.digitalocean.com/v2/domains/'$_domain'/records'
|
||||
PBODY='{"type":"TXT","name":"'$_sub_domain'","data":"'$txtvalue'"}'
|
||||
|
||||
@ -63,7 +60,6 @@ dns_digitalocean_add() {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
## Remove the txt record after validation.
|
||||
## Usage: fulldomain txtvalue
|
||||
## EG: "_acme-challenge.www.other.domain.com" "XKrxpRBosdq0HG9i01zxXp5CPBs"
|
||||
@ -84,8 +80,8 @@ dns_digitalocean_rm() {
|
||||
_debug _domain "$_domain"
|
||||
|
||||
## Set the header with our post type and key auth key
|
||||
_H1="Content-Type: application/json"
|
||||
_H2="Authorization: Bearer $DO_API_KEY"
|
||||
export _H1="Content-Type: application/json"
|
||||
export _H2="Authorization: Bearer $DO_API_KEY"
|
||||
## get URL for the list of domains
|
||||
## may get: "links":{"pages":{"last":".../v2/domains/DOM/records?page=2","next":".../v2/domains/DOM/records?page=2"}}
|
||||
GURL="https://api.digitalocean.com/v2/domains/$_domain/records"
|
||||
@ -136,10 +132,8 @@ dns_digitalocean_rm() {
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
##################### Private functions below #####################
|
||||
|
||||
|
||||
## Split the domain provided at "base_domain_start_position" from the FRONT
|
||||
## USAGE: fulldomain base_domain_start_position
|
||||
## EG: "_acme-challenge.two.three.four.domain.com" "3"
|
||||
@ -150,7 +144,7 @@ _get_base_domain() {
|
||||
# args
|
||||
domain=$1
|
||||
dom_point=$2
|
||||
sub_point=$(_math $dom_point - 1)
|
||||
sub_point=$(_math "$dom_point" - 1)
|
||||
_debug "split domain" "$domain"
|
||||
_debug "split dom_point" "$dom_point"
|
||||
_debug "split sub_point" "$sub_point"
|
||||
@ -159,8 +153,8 @@ _get_base_domain() {
|
||||
MAX_DOM=255
|
||||
|
||||
## cut in half and check
|
||||
_domain=$(printf "%s" "$domain" | cut -d . -f $dom_point-$MAX_DOM)
|
||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$sub_point)
|
||||
_domain=$(printf "%s" "$domain" | cut -d . -f "$dom_point"-"$MAX_DOM")
|
||||
_sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-"$sub_point")
|
||||
if [ -z "$_domain" ]; then
|
||||
## not valid
|
||||
_err "invalid split location"
|
||||
@ -178,4 +172,3 @@ _get_base_domain() {
|
||||
## all ok
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user