3 ## Infoblox API integration by Jason Keller and Elijah Tenai
5 ## Report any bugs via https://github.com/jasonkeller/acme.sh
9 ## Nothing to see here, just some housekeeping
12 baseurlnObject
="https://$Infoblox_Server/wapi/v2.2.2/record:txt?name=$fulldomain&text=$txtvalue"
14 _info
"Using Infoblox API"
15 _debug fulldomain
"$fulldomain"
16 _debug txtvalue
"$txtvalue"
18 ## Check for the credentials
19 if [ -z "$Infoblox_Creds" ] ||
[ -z "$Infoblox_Server" ]; then
22 _err
"You didn't specify the credentials or server yet (Infoblox_Creds and Infoblox_Server)."
23 _err
"Please set them via EXPORT ([username:password] and [ip or hostname]) and try again."
27 ## Save the credentials to the account file
28 _saveaccountconf Infoblox_Creds
"$Infoblox_Creds"
29 _saveaccountconf Infoblox_Server
"$Infoblox_Server"
31 ## Base64 encode the credentials
32 Infoblox_CredsEncoded
=$
(printf "%b" "$Infoblox_Creds" | _base64
)
34 ## Construct the HTTP Authorization header
35 export _H1
="Accept-Language:en-US"
36 export _H2
="Authorization: Basic $Infoblox_CredsEncoded"
38 ## Add the challenge record to the Infoblox grid member
39 result
=$
(_post
"" "$baseurlnObject" "" "POST")
41 ## Let's see if we get something intelligible back from the unit
42 if echo "$result" |
egrep 'record:txt/.*:.*/default'; then
43 _info
"Successfully created the txt record"
46 _err
"Error encountered during record addition"
55 ## Nothing to see here, just some housekeeping
59 _info
"Using Infoblox API"
60 _debug fulldomain
"$fulldomain"
61 _debug txtvalue
"$txtvalue"
63 ## Base64 encode the credentials
64 Infoblox_CredsEncoded
=$
(printf "%b" "$Infoblox_Creds" | _base64
)
66 ## Construct the HTTP Authorization header
67 export _H1
="Accept-Language:en-US"
68 export _H2
="Authorization: Basic $Infoblox_CredsEncoded"
70 ## Does the record exist? Let's check.
71 baseurlnObject
="https://$Infoblox_Server/wapi/v2.2.2/record:txt?name=$fulldomain&text=$txtvalue&_return_type=xml-pretty"
72 result
=$
(_get
"$baseurlnObject")
74 ## Let's see if we get something intelligible back from the grid
75 if echo "$result" |
egrep 'record:txt/.*:.*/default'; then
76 ## Extract the object reference
77 objRef
=$
(printf "%b" "$result" | _egrep_o
'record:txt/.*:.*/default')
78 objRmUrl
="https://$Infoblox_Server/wapi/v2.2.2/$objRef"
79 ## Delete them! All the stale records!
80 rmResult
=$
(_post
"" "$objRmUrl" "" "DELETE")
81 ## Let's see if that worked
82 if echo "$rmResult" |
egrep 'record:txt/.*:.*/default'; then
83 _info
"Successfully deleted $objRef"
86 _err
"Error occurred during txt record delete"
91 _err
"Record to delete didn't match an existing record"
97 #################### Private functions below ##################################