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&view=$Infoblox_View"
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, server or infoblox view yet (Infoblox_Creds, Infoblox_Server and Infoblox_View)."
23 _err
"Please set them via EXPORT ([username:password], [ip or hostname]) and try again."
27 if [ -z "$Infoblox_View" ]; then
28 Infoblox_View
="default"
31 ## Save the credentials to the account file
32 _saveaccountconf Infoblox_Creds
"$Infoblox_Creds"
33 _saveaccountconf Infoblox_Server
"$Infoblox_Server"
34 _saveaccountconf Infoblox_View
"$Infoblox_View"
36 ## Base64 encode the credentials
37 Infoblox_CredsEncoded
=$
(printf "%b" "$Infoblox_Creds" | _base64
)
39 ## Construct the HTTP Authorization header
40 export _H1
="Accept-Language:en-US"
41 export _H2
="Authorization: Basic $Infoblox_CredsEncoded"
43 ## Add the challenge record to the Infoblox grid member
44 result
=$
(_post
"" "$baseurlnObject" "" "POST")
46 ## Let's see if we get something intelligible back from the unit
47 if echo "$result" |
egrep "record:txt/.*:.*/$Infoblox_View"; then
48 _info
"Successfully created the txt record"
51 _err
"Error encountered during record addition"
60 ## Nothing to see here, just some housekeeping
64 _info
"Using Infoblox API"
65 _debug fulldomain
"$fulldomain"
66 _debug txtvalue
"$txtvalue"
68 ## Base64 encode the credentials
69 Infoblox_CredsEncoded
=$
(printf "%b" "$Infoblox_Creds" | _base64
)
71 ## Construct the HTTP Authorization header
72 export _H1
="Accept-Language:en-US"
73 export _H2
="Authorization: Basic $Infoblox_CredsEncoded"
75 ## Does the record exist? Let's check.
76 baseurlnObject
="https://$Infoblox_Server/wapi/v2.2.2/record:txt?name=$fulldomain&text=$txtvalue&view=$Infoblox_View&_return_type=xml-pretty"
77 result
=$
(_get
"$baseurlnObject")
79 ## Let's see if we get something intelligible back from the grid
80 if echo "$result" |
egrep 'record:txt/.*:.*/default'; then
81 ## Extract the object reference
82 objRef
=$
(printf "%b" "$result" | _egrep_o
"record:txt/.*:.*/$Infoblox_View")
83 objRmUrl
="https://$Infoblox_Server/wapi/v2.2.2/$objRef"
84 ## Delete them! All the stale records!
85 rmResult
=$
(_post
"" "$objRmUrl" "" "DELETE")
86 ## Let's see if that worked
87 if echo "$rmResult" |
egrep "record:txt/.*:.*/$Infoblox_View"; then
88 _info
"Successfully deleted $objRef"
91 _err
"Error occurred during txt record delete"
96 _err
"Record to delete didn't match an existing record"
102 #################### Private functions below ##################################